Skip to content

Commit a1d5788

Browse files
mkolesniktpantelis
authored andcommitted
Extract get-subctl.sh to easily fetch subctl
This will be useful both for scripts and for `make shell` users who need to quickly get subctl for various operations Signed-off-by: Mike Kolesnik <[email protected]>
1 parent e96fbef commit a1d5788

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

Makefile.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ upgrade-e2e: deploy-latest deploy e2e
147147
# This uses make deploy, but forcefully ignores images so that images
148148
# are *not* rebuilt (we want to deploy the published images only)
149149
deploy-latest:
150-
curl -L get.submariner.io | VERSION=latest bash
151-
$(MAKE) -o images -o preload-images deploy SUBCTL=~/.local/bin/subctl IMAGE_TAG=subctl using=$(using)
150+
$(MAKE) -o images -o preload-images deploy SUBCTL_VERSION=latest IMAGE_TAG=subctl using=$(using)
152151

153152
##### LINTING TARGETS #####
154153
.PHONY: gitlint golangci-lint markdownlint packagedoc-lint shellcheck yamllint

package/Dockerfile.shipyard-dapper-base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/i
7979
find /go/bin /usr/local/libexec/docker/cli-plugins -type f -executable -newercc /proc \( -execdir upx ${UPX_LEVEL} {} \; -o -true \) && \
8080
go clean -cache -modcache
8181

82+
# Link get-subctl script so it can be easily run inside a shell
83+
RUN ln -s $SCRIPTS_DIR/get-subctl.sh /root/.local/bin/subctl
84+
8285
# Copy kubecfg to always run on the shell
8386
COPY scripts/shared/lib/kubecfg /etc/profile.d/kubecfg.sh
8487

release-notes/get-subctl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added a centralized script for getting `subctl`. It now impersonates `subctl` so that users who run `make shell` will have it downloaded the first time they try to use it.
2+
To influence the version being installed, the `SUBCTL_VERSION` variable can be set.

scripts/shared/deploy.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ declare_cidrs
137137
declare_kubeconfig
138138

139139
# Always get subctl since we're using moving versions, and having it in the image results in a stale cached one
140-
bash -c "curl -Ls https://get.submariner.io | VERSION=${CUTTING_EDGE} DESTDIR=/go/bin bash" ||
141-
bash -c "curl -Ls https://get.submariner.io | VERSION=devel DESTDIR=/go/bin bash"
140+
"${SCRIPTS_DIR}/get-subctl.sh"
142141

143142
load_deploytool "${DEPLOYTOOL}"
144143
deploytool_prereqs

scripts/shared/get-subctl.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# In case we're pretending to be `subctl`
6+
if [[ "${0##*/}" = subctl ]] && [[ -L "$0" ]]; then
7+
run_subctl=true
8+
9+
# Delete ourselves to ensure we don't run into issues with the new subctl
10+
rm -f "$0"
11+
fi
12+
13+
# Default to devel if we don't know what base branch were on
14+
curl -Ls --retry 3 https://get.submariner.io | VERSION="${SUBCTL_VERSION:-${BASE_BRANCH:-devel}}" bash
15+
16+
# If we're pretending to be subctl, run subctl with any given arguments
17+
[[ -z "${run_subctl}" ]] || subctl "$@"

scripts/shared/post_mortem.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function post_analyze() {
6565
### Main ###
6666

6767
declare_kubeconfig
68-
bash -c "curl -Ls https://get.submariner.io | VERSION=${CUTTING_EDGE} DESTDIR=/go/bin bash"
68+
"${SCRIPTS_DIR}/get-subctl.sh"
6969
for cluster in $(kind get clusters); do
7070
post_analyze
7171
done

0 commit comments

Comments
 (0)