GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color debug() { if [[ -n "$DEBUG" ]]; then local prompt="$1" shift local message="$*" if [[ -n "$message" ]] ; then message=": $message" fi echo -e "🐛 \033[0;36m[DEBUG] ${prompt}\033[0m${message}" fi } error() { local prompt="$1" shift local message="$*" if [[ -n "$message" ]] ; then message=": $message" fi echo -e "${RED}❌ ${prompt}:${NC}${message}" exit 1 } step() { local prompt="$1" shift local message="$*" if [[ -n "$message" ]] ; then message=": $message" fi echo -e "${YELLOW}🔄 ${prompt}${NC}${message}" } success() { local prompt="$1" shift local message="$*" if [[ -n "$message" ]] ; then message=": $message" fi echo -e "${GREEN}✅ ${prompt}${NC}${message}" } check_command() { local command="$1" if [[ -z $(which ${command}) ]] ; then error "Missing command" "${command}" fi } # buildAnnotations [] buildAnnotations() { local dockerfile="$1" local tag="$2" local commit="${3:-}" if [[ ! -f "$dockerfile" ]]; then error "Dockerfile not found" "$dockerfile" fi local annotations="" # Parser les labels OCI existants while IFS= read -r line; do # Match LABEL org.opencontainers.image.* if [[ "$line" =~ ^LABEL[[:space:]]+org\.opencontainers\.image\.([a-zA-Z0-9._-]+)=\"([^\"]*)\" ]]; then local key="org.opencontainers.image.${BASH_REMATCH[1]}" local value="${BASH_REMATCH[2]}" annotations="$annotations --annotation $key=\"$value\"" fi done < "$dockerfile" # Ajouter date de build annotations="$annotations --annotation org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" # Ajouter le tag de version if [[ -n "$tag" ]]; then annotations="$annotations --annotation org.opencontainers.image.version=$tag" fi # Ajouter le commit git si fourni if [[ -n "$commit" ]]; then annotations="$annotations --annotation org.opencontainers.image.revision=$commit" fi echo "$annotations" }