Skip to content

Commit

Permalink
Build krel from sources when not using default TOOL_* values
Browse files Browse the repository at this point in the history
This allos testing GCB by setting one of `TOOL_ORG`, `TOOL_REPO` or
`TOOL_REF`.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Aug 21, 2024
1 parent a7bd8b3 commit 05124ba
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
4 changes: 4 additions & 0 deletions gcb/fast-forward/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ steps:
- KREL_OUTPUT_PATH=/workspace/bin/krel
args:
- ./hack/get-krel
env:
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"

- name: gcr.io/k8s-staging-releng/k8s-cloud-builder:${_KUBE_CROSS_VERSION}
dir: "/workspace"
Expand Down
4 changes: 4 additions & 0 deletions gcb/obs-release/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ steps:
- KREL_OUTPUT_PATH=/workspace/bin/krel
args:
- ./hack/get-krel
env:
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"

- name: gcr.io/k8s-staging-releng/k8s-cloud-builder:${_KUBE_CROSS_VERSION}
dir: "/workspace"
Expand Down
4 changes: 4 additions & 0 deletions gcb/obs-stage/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ steps:
- KREL_OUTPUT_PATH=/workspace/bin/krel
args:
- ./hack/get-krel
env:
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"

- name: gcr.io/k8s-staging-releng/k8s-cloud-builder:${_KUBE_CROSS_VERSION}
dir: "/workspace"
Expand Down
4 changes: 4 additions & 0 deletions gcb/release/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ steps:
- KREL_OUTPUT_PATH=/workspace/bin/krel
args:
- ./hack/get-krel
env:
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"

- name: gcr.io/k8s-staging-releng/k8s-cloud-builder:${_KUBE_CROSS_VERSION}
dir: "/workspace"
Expand Down
4 changes: 4 additions & 0 deletions gcb/stage/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ steps:
- KREL_OUTPUT_PATH=/workspace/bin/krel
args:
- ./hack/get-krel
env:
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"

- name: gcr.io/k8s-staging-releng/k8s-cloud-builder:${_KUBE_CROSS_VERSION}
dir: "/workspace"
Expand Down
27 changes: 21 additions & 6 deletions hack/get-krel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set -o errexit
set -o nounset
set -o pipefail

env

curl_retry() {
curl -sSfL --retry 5 --retry-delay 3 "$@"
}
Expand All @@ -26,13 +28,26 @@ KREL_OUTPUT_PATH=${KREL_OUTPUT_PATH:-bin/krel}
echo "Using output path: $KREL_OUTPUT_PATH"
mkdir -p "$(dirname "$KREL_OUTPUT_PATH")"

LATEST_RELEASE=$(curl_retry https://api.github.com/repos/kubernetes/release/releases/latest | jq -r .tag_name)
echo "Using krel release: $LATEST_RELEASE"
DEFAULT_TOOL_ORG=kubernetes
DEFAULT_TOOL_REPO=release
DEFAULT_TOOL_REF=master

TOOL_ORG=${TOOL_ORG:-${DEFAULT_TOOL_ORG}}
TOOL_REPO=${TOOL_REPO:-${DEFAULT_TOOL_REPO}}
TOOL_REF=${TOOL_REF:-${DEFAULT_TOOL_REF}}

if [[ "$TOOL_ORG" == "$DEFAULT_TOOL_ORG" && "$TOOL_REPO" == "$DEFAULT_TOOL_REPO" && "$TOOL_REF" == "$DEFAULT_TOOL_REF" ]]; then
LATEST_RELEASE=$(curl_retry https://api.github.com/repos/kubernetes/release/releases/latest | jq -r .tag_name)
echo "Using krel release: $LATEST_RELEASE"

echo "Downloading krel from GCB bucket…"
GCB_URL="https://storage.googleapis.com/k8s-artifacts-sig-release/kubernetes/release/$LATEST_RELEASE/krel-amd64-linux"
curl_retry "$GCB_URL" -o "$KREL_OUTPUT_PATH"
chmod +x "$KREL_OUTPUT_PATH"
echo "Downloading krel from GCB bucket…"
GCB_URL="https://storage.googleapis.com/k8s-artifacts-sig-release/kubernetes/release/$LATEST_RELEASE/krel-amd64-linux"
curl_retry "$GCB_URL" -o "$KREL_OUTPUT_PATH"
chmod +x "$KREL_OUTPUT_PATH"
else
echo "Building krel from sources"
go build -o "$KREL_OUTPUT_PATH" ./cmd/krel
fi

echo "Done, output of 'krel version':"
"$KREL_OUTPUT_PATH" version

0 comments on commit 05124ba

Please sign in to comment.