From 1a46e70065207bf249b85d8060ae282aba2168e6 Mon Sep 17 00:00:00 2001 From: Olga Naidjonoka Date: Fri, 9 Feb 2024 12:06:18 +0200 Subject: [PATCH] added docker img params --- .../filebeat/scripts/packaging/package.sh | 79 +++++++++---------- .../scripts/packaging/packaging-env.sh | 17 ++-- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/.buildkite/filebeat/scripts/packaging/package.sh b/.buildkite/filebeat/scripts/packaging/package.sh index 6546db82df35..55a3159d8cbc 100755 --- a/.buildkite/filebeat/scripts/packaging/package.sh +++ b/.buildkite/filebeat/scripts/packaging/package.sh @@ -5,59 +5,58 @@ set -euo pipefail #source .buildkite/env-scripts/linux-env.sh source .buildkite/env-scripts/util.sh -#echo "--- Creating package" -#mage -d filebeat package - - -TAGS=("${BUILDKITE_COMMIT}") - +IMG_POSTFIX="-BK-SNAPSHOT" VARIANTS=("" "-ubi" "-oss") - -# IMAGES -SOURCE_NAMESPACE="beats" +VERSION="$(make get-version)" +SOURCE_TAG+="${VERSION}${IMG_POSTFIX}" BEAT_NAME="filebeat" -SOURCE="beats/${BEAT_NAME}${variant}" TARGET="observability-ci/${BEAT_NAME}" -# ARGS -REGISTRY="docker.elastic.co" -SNAPSHOT=true -VERSION="$(make get-version)", -images: images - -#VARIANTS -> foreach = IMAGES: image map with SOURCE, TARGET, ARCH - -#IMAGES -> foreach = tag and push -# registry: ${REGISTRY}, -# sourceTag: calculate_tags->sourceTag, -# targetTag: "${tag}" (non arm) // ${tag}-${image.arch} (arm) --> foreach $TAGS -# source: ${SOURCE}, -# target: ${TARGET} - - define_tags() { -echo "--- Defined tags" - if [ "$SNAPSHOT" = true ]; then - aliasVersion="${VERSION%.*}${IMG_POSTFIX}" - sourceTag+="${VERSION}${IMG_POSTFIX}" - fi + aliasVersion="${VERSION%.*}${IMG_POSTFIX}" + tags=("${BUILDKITE_COMMIT}") if is_pr; then - TAGS+=("pr-${GITHUB_PR_NUMBER}") + tags+=("pr-${GITHUB_PR_NUMBER}") else - TAGS+=("${sourceTag}" "${aliasVersion}") + tags+=("${SOURCE_TAG}" "${aliasVersion}") fi +} - local tag="" - for tag in "${TAGS[@]}"; do - echo "$tag" - done +check_is_arm() { + if [[ ${HW_TYPE} == "aarch64" || ${HW_TYPE} == "arm64" ]]; then + is_arm="-arm" + else + is_arm="" + fi } -#buildkite-agent annotate "Tag '$TAG' has been created." --style 'success' --context 'ctx-success' +define_tags + +for variant in "${VARIANTS[@]}"; do + echo "--- PARAMS for variant: $variant" + + check_is_arm + registry=${DOCKER_REGISTRY} + sourceTag=$SOURCE_TAG + source="beats/${BEAT_NAME}${variant}" + target=$TARGET + + echo "Registry: $registry" + echo "Source: $source" + echo "Source tag: $sourceTag" + echo "Target: $target" -echo "--- Calculating tags" -daefine_tags + for tag in "${tags[@]}"; do + targetTag=$tag${is_arm} + echo "Target tag: $targetTag" + done +done + +#echo "--- Creating package" +#mage -d filebeat package #echo "--- Setting git config" #set_git_config + +#buildkite-agent annotate "Tag '$TAG' has been created." --style 'success' --context 'ctx-success' diff --git a/.buildkite/filebeat/scripts/packaging/packaging-env.sh b/.buildkite/filebeat/scripts/packaging/packaging-env.sh index ab8f8f68257a..02c942361b4c 100755 --- a/.buildkite/filebeat/scripts/packaging/packaging-env.sh +++ b/.buildkite/filebeat/scripts/packaging/packaging-env.sh @@ -7,20 +7,27 @@ deploy/kubernetes/.*-kubernetes.yaml" packaging_changeset="^dev-tools/packaging/ ^.go-version" -DOCKER_REGISTRY="docker.elastic.co" -SNAPSHOT=true VERSION=$(make get-version | tr -d '\n') ONLY_DOCS=$(changeset_applies "$docs_changeset") PACKAGING_CHANGES=$(changeset_applies "$packaging_changeset") GO_MOD_CHANGES=$(changeset_applies "^go.mod") # Change the postfix to -SNAPSHOT, once Jenkins is disabled -IMG_POSTFIX="-BK-SNAPSHOT" + export PACKAGING_CHANGES export ONLY_DOCS export GO_MOD_CHANGES export DOCKER_REGISTRY -export SNAPSHOT export VERSION export REPO -export IMG_POSTFIX +#export IMG_POSTFIX + + +#VARIANTS -> foreach = IMAGES: image map with SOURCE, TARGET, ARCH + +#IMAGES -> foreach = tag and push +# registry: ${REGISTRY}, +# sourceTag: calculate_tags->sourceTag, +# targetTag: "${tag}" (non arm) // ${tag}-${image.arch} (arm) --> foreach $TAGS +# source: ${SOURCE}, +# target: ${TARGET}