Skip to content

Commit

Permalink
added docker img params
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed May 16, 2024
1 parent 0facfab commit 1a46e70
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 45 deletions.
79 changes: 39 additions & 40 deletions .buildkite/filebeat/scripts/packaging/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
17 changes: 12 additions & 5 deletions .buildkite/filebeat/scripts/packaging/packaging-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit 1a46e70

Please sign in to comment.