From 4821fcc39db18aa062820ee0fe5ba3278b407537 Mon Sep 17 00:00:00 2001 From: Andrew Melnick Date: Tue, 23 Jul 2024 15:17:50 -0600 Subject: [PATCH] Switch to make-env for build env managment, add script to run in dockerfile --- .github/workflows/cd.yaml | 127 +++++---------------- .github/workflows/ci.yaml | 60 +++------- Dockerfile | 6 +- Makefile | 143 ++++++++++++----------- build-env.sh | 50 ++++++++ e2e_suite_test.go | 38 ++++--- make-env.Dockerfile | 185 ++++++++++++++++++++++++++++++ make-env.Makefile | 233 ++++++++++++++++++++++++++++++++++++++ make-env.yaml | 88 ++++++++++++++ set-chart-versions.sh | 28 +++++ 10 files changed, 723 insertions(+), 235 deletions(-) create mode 100755 build-env.sh create mode 100644 make-env.Dockerfile create mode 100644 make-env.Makefile create mode 100644 make-env.yaml create mode 100755 set-chart-versions.sh diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 9f8e7c2..2c56bfd 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -17,16 +17,10 @@ env: HELM_REPO: "oci://ghcr.io/${{ github.repository }}/charts" - GO_VERSION: 1.20.4 - GOPRIVATE: 'github.com/meln5674/*' - HELM_VERSION: v3.12.0 - COSIGN_VERSION: v1.13.0 - YQ_VERSION: v4.27.2 - jobs: lint: # runs-on: ubuntu-latest @@ -38,12 +32,6 @@ jobs: # Checkout - name: Checkout repository uses: actions/checkout@v3 - - # Install deps - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: '${{ env.HELM_VERSION }}' - uses: actions/setup-go@v4 with: @@ -51,24 +39,12 @@ jobs: - name: Install Dependencies run: | - make deps + make -j deps all-helm-tools chart-deps # Run Linter - name: Lint standalone chart run: | - cd deploy/helm/mlflow-oidc-proxy - ../../../bin/helm dependency build - ../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0 - - name: Lint omnibus dependencies chart - run: | - cd deploy/helm/mlflow-multitenant-deps - ../../../bin/helm lint . - ../../../bin/helm template . - - name: Lint omnibus chart - run: | - cd deploy/helm/mlflow-multitenant - ../../../bin/helm dependency build - ../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0 + make helm-hog test: # runs-on: ubuntu-latest @@ -83,36 +59,25 @@ jobs: with: submodules: true - - # Install Deps - # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: '${{ env.HELM_VERSION }}' - - uses: actions/setup-go@v4 - with: - go-version: '^${{ env.GO_VERSION }}' + - name: Setup Build Environment + run: | + ./build-env.sh echo Done - name: Install Dependencies run: | - make deps - bin/helm dependency build deploy/helm/mlflow-oidc-proxy - bin/helm dependency build deploy/helm/mlflow-multitenant - bin/helm dependency build deploy/helm/mlflow-multitenant-deps + ./build-env.sh make -j deps all-test-tools all-e2e-tools chart-deps # Tests - name: Unit Tests run: | - make test + ./build-env.sh make test - name: End-to-End Tests run: | - make e2e IS_CI=1 + ./build-env.sh make e2e IS_CI=1 docker: @@ -148,22 +113,6 @@ jobs: - name: Setup Docker buildx uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: '${{ env.HELM_VERSION }}' - - - uses: actions/setup-go@v4 - with: - go-version: '^${{ env.GO_VERSION }}' - - - name: Install Dependencies - run: | - make deps - - - # Configuration/metdata - # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} @@ -244,54 +193,34 @@ jobs: git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Setup Build Environment + run: | + ./build-env.sh echo Done - # Install Deps - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: '${{ env.HELM_VERSION }}' - - - name: Install YQ - uses: chrisdickinson/setup-yq@latest - with: - yq-version: '${{ env.YQ_VERSION }}' + - name: Install Dependencies + run: | + ./build-env.sh make -j all-helm-tools + ./build-env.sh helm repo add jetstack https://charts.jetstack.io + ./build-env.sh helm repo add zalando https://opensource.zalando.com/postgres-operator/charts/postgres-operator + ./build-env.sh make -j chart-deps + - name: Log into Registry + run: | + ./build-env.sh helm registry login "${REGISTRY}" -u "${GITHUB_ACTOR}" -p "${GITHUB_TOKEN}" + - name: Package Charts + env: + GIT_TAG: '${{ steps.tagName.outputs.tag }}' + run: | + ./build-env.sh ./set-chart-versions "${HELM_REPO}" "${GIT_TAG}" "${GITHUB_SHA}" + ./build-env.sh make -j charts # Release charts - name: Push Charts env: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' run: | - set -x - - helm registry login "${REGISTRY}" -u "${GITHUB_ACTOR}" -p "${GITHUB_TOKEN}" - - GIT_TAG="${{ steps.tagName.outputs.tag }}" - CHART_APPVERSION="${GIT_TAG:-${GITHUB_SHA}}" - if [ -n "${GIT_TAG}" ]; then - NEW_VERSION_EXPR='"'"${GIT_TAG}"'"' - else - NEW_VERSION_EXPR='.version + "-'"${GITHUB_SHA}"'"' - fi - mkdir -p deploy/helm - for chart in mlflow-oidc-proxy mlflow-multitenant-deps mlflow-multitenant; do - yq -i '.version = '"${NEW_VERSION_EXPR}"'' "deploy/helm/${chart}/Chart.yaml" + for chart in bin/charts/*.tgz ; do + helm push "${chart}" "${HELM_REPO}" done - yq -i '.appVersion = "'"${CHART_APPVERSION}"'"' "deploy/helm/mlflow-oidc-proxy/Chart.yaml" - STANDALONE_CHART_VERSION="$(yq '.version' 'deploy/helm/mlflow-oidc-proxy/Chart.yaml')" - yq -i '(.dependencies[] | select(.name == "mlflow-oidc-proxy")).version |= "'"${STANDALONE_CHART_VERSION}"'"' 'deploy/helm/mlflow-multitenant/Chart.yaml' - yq -i '(.dependencies[] | select(.name == "mlflow-oidc-proxy")).repository |= "'"${HELM_REPO}"'"' 'deploy/helm/mlflow-multitenant/Chart.yaml' - helm repo add jetstack https://charts.jetstack.io - helm repo add zalando https://opensource.zalando.com/postgres-operator/charts/postgres-operator - helm dependency build deploy/helm/mlflow-multitenant-deps - helm package deploy/helm/mlflow-oidc-proxy/ --destination bin - helm package deploy/helm/mlflow-multitenant-deps/ --destination bin - helm push bin/mlflow-oidc-proxy-*.tgz "${HELM_REPO}" - helm push bin/mlflow-multitenant-deps-*.tgz "${HELM_REPO}" - rm -rf bin/*.tgz # The wildcard below matches the deps chart, this is a hack-y workaround - helm dependency build deploy/helm/mlflow-multitenant - helm package deploy/helm/mlflow-multitenant/ --destination bin - helm push bin/mlflow-multitenant-*.tgz "${HELM_REPO}" - diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ee97fe1..40ef056 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,16 +18,10 @@ env: HELM_REPO: "oci://ghcr.io/${{ github.repository }}/charts" - GO_VERSION: 1.20.4 - GOPRIVATE: 'github.com/meln5674/*' - HELM_VERSION: v3.12.0 - COSIGN_VERSION: v1.13.0 - YQ_VERSION: v4.27.2 - jobs: lint: # runs-on: ubuntu-latest @@ -40,36 +34,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - # Install deps - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: '${{ env.HELM_VERSION }}' - - - uses: actions/setup-go@v4 - with: - go-version: '^${{ env.GO_VERSION }}' + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + - name: Setup Build Environment + run: | + ./build-env.sh echo Done + - name: Install Dependencies run: | - make deps + ./build-env.sh make -j deps all-helm-tools chart-deps # Run Linter - name: Lint standalone chart run: | - cd deploy/helm/mlflow-oidc-proxy - ../../../bin/helm dependency build - ../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0 - - name: Lint omnibus dependencies chart - run: | - cd deploy/helm/mlflow-multitenant-deps - ../../../bin/helm lint . - ../../../bin/helm template . - - name: Lint omnibus chart - run: | - cd deploy/helm/mlflow-multitenant - ../../../bin/helm dependency build - ../../../bin/helm-hog test --no-apply --batch --auto-remove-success --parallel=0 + ./build-env.sh make helm-hog test: # runs-on: ubuntu-latest @@ -84,33 +63,22 @@ jobs: with: submodules: true - - # Install Deps - # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: '${{ env.HELM_VERSION }}' - - - uses: actions/setup-go@v4 - with: - go-version: '^${{ env.GO_VERSION }}' + - name: Setup Build Environment + run: | + ./build-env.sh echo Done - name: Install Dependencies run: | - make deps - bin/helm dependency build deploy/helm/mlflow-oidc-proxy - bin/helm dependency build deploy/helm/mlflow-multitenant - bin/helm dependency build deploy/helm/mlflow-multitenant-deps + ./build-env.sh make -j deps all-test-tools all-e2e-tools chart-deps # Tests - name: Unit Tests run: | - make test + ./build-env.sh make test - name: End-to-End Tests run: | - make e2e IS_CI=1 + ./build-env.sh make e2e IS_CI=1 diff --git a/Dockerfile b/Dockerfile index f83a055..cce7af2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,11 @@ FROM golang:1.18 AS build WORKDIR /usr/src/mlflow-oidc-proxy -COPY main.go go.mod go.sum ./ -COPY pkg ./pkg +COPY go.mod go.sum ./ +RUN go mod download +COPY main.go ./ +COPY pkg ./pkg RUN GCO_ENABLED=0 GOOS=linux go build -a -ldflags="-w -extldflags "-static"" -tags netgo main.go FROM alpine:3.16 AS certs diff --git a/Makefile b/Makefile index 5b18fbe..ba31d89 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,21 @@ +include make-env.Makefile + +CHART_DIR=deploy/helm + + +.PHONY: deps +deps: + go mod download + .PHONY: vet -vet: +vet: deps go vet ./... TEST_SUITES ?= ./pkg/proxy TEST_FLAGS ?= --race --trace -p -E2E_TEST_SUITES ?= ./ -E2E_TEST_FLAGS ?= --race --trace -vv --flake-attempts=5 # --until-it-fails --fail-fast - -coverprofile.out: deps - bin/ginkgo run --cover --coverpkg=./,./pkg/proxy/ $(TEST_FLAGS) $(TEST_SUITES) +coverprofile.out: deps all-test-tools + $(GINKGO) run --cover --coverpkg=./,./pkg/proxy/ $(TEST_FLAGS) $(TEST_SUITES) .PHONY: test test: coverprofile.out @@ -18,74 +24,65 @@ test: coverprofile.out show-coverage: coverprofile.out go tool cover -html=coverprofile.out -.PHONY: e2e -e2e: deps - bin/ginkgo run --cover --coverpkg=./,./pkg/proxy/ $(E2E_TEST_FLAGS) $(E2E_TEST_SUITES) - -LOCALBIN ?= bin -# $(LOCALBIN): -# mkdir -p $(LOCALBIN) - -GINKGO_URL ?= $(shell grep ginkgo go.mod | awk '{ print $$1 "/ginkgo@" $$2 }') -GINKGO ?= $(LOCALBIN)/ginkgo -$(GINKGO): - mkdir -p $(shell dirname $(GINKGO)) - GOBIN=/tmp/ go install $(GINKGO_URL) - mv /tmp/ginkgo $(GINKGO) - touch $(GINKGO) - -KUBECTL_MIRROR ?= https://dl.k8s.io/release -KUBECTL_VERSION ?= v1.25.11 -KUBECTL_URL ?= $(KUBECTL_MIRROR)/$(KUBECTL_VERSION)/bin/$(shell go env GOOS)/$(shell go env GOARCH)/kubectl -KUBECTL ?= $(LOCALBIN)/kubectl -$(KUBECTL): - mkdir -p $(shell dirname $(KUBECTL)) - curl -vfL $(KUBECTL_URL) > $(KUBECTL) - chmod +x $(KUBECTL) - touch $(KUBECTL) - - -HELM_MIRROR ?= https://get.helm.sh -HELM_VERSION ?= v3.12.2 -ifeq ($(shell go env GOOS),windows) -HELM_URL ?= $(HELM_MIRROR)/helm-$(HELM_VERSION)-$(shell go env GOOS)-$(shell go env GOARCH).zip -else -HELM_URL ?= $(HELM_MIRROR)/helm-$(HELM_VERSION)-$(shell go env GOOS)-$(shell go env GOARCH).tar.gz -endif - -HELM ?= $(LOCALBIN)/helm -$(HELM): - mkdir -p $(shell dirname $(HELM)) -ifeq ($(shell go env GOOS),windows) - curl -vfL $(HELM_URL) > $(HELM).zip - unzip $(HELM).zip -j -d /tmp/ -x helm-windows-$(go env GOARCH)/helm - mv helm-windows-$(go env GOARCH)/helm $(LOCALBIN) -else - curl -vfL $(HELM_URL) | tar xz -C /tmp/ $(shell go env GOOS)-$(shell go env GOARCH)/helm - mv /tmp/$(shell go env GOOS)-$(shell go env GOARCH)/helm $(HELM) -endif - touch $(HELM) - - -KIND_MIRROR ?= https://github.com/kubernetes-sigs/kind/releases/download -KIND_VERSION ?= v0.17.0 -KIND_URL ?= $(KIND_MIRROR)/$(KIND_VERSION)/kind-$(shell go env GOOS)-$(shell go env GOARCH) -KIND ?= $(LOCALBIN)/kind -$(KIND): - mkdir -p $(shell dirname $(KIND)) - curl -vfL $(KIND_URL) > $(KIND) - chmod +x $(KIND) - -HELM_HOG_VERSION ?= 3af9ec621dcc359e38e966a255571a39beefe624 -HELM_HOG ?= $(LOCALBIN)/helm-hog -$(HELM_HOG): - mkdir -p $(shell dirname $(HELM_HOG)) - GOBIN=/tmp go install github.com/meln5674/helm-hog@$(HELM_HOG_VERSION) - mv /tmp/helm-hog $(HELM_HOG) +E2E_TEST_SUITES ?= ./ +E2E_TEST_FLAGS ?= --race --trace -vv --flake-attempts=5 # --until-it-fails --fail-fast -.PHONY: deps -deps: $(GINKGO) $(KUBECTL) $(HELM) $(KIND) $(HELM_HOG) - go mod download +.PHONY: e2e +e2e: deps all-e2e-tools + helm dep build $(CHART_DIR)/mlflow-oidc-proxy + helm dep build $(CHART_DIR)/mlflow-multitenant + helm dep build $(CHART_DIR)/mlflow-multitenant-deps + $(GINKGO) run --cover --coverpkg=./,./pkg/proxy/ $(E2E_TEST_FLAGS) $(E2E_TEST_SUITES) bin/mlflow-oidc-proxy: go build -o bin/mlflow-oidc-proxy main.go + + +MLFLOW_OIDC_PROXY_CHART_VERSION=$(shell yq .version $(CHART_DIR)/mlflow-oidc-proxy/Chart.yaml) +MLFLOW_MULTITENANT_CHART_VERSION=$(shell yq .version $(CHART_DIR)/mlflow-multitenant/Chart.yaml) +MLFLOW_MULTITENANT_DEPS_CHART_VERSION=$(shell yq .version $(CHART_DIR)/mlflow-multitenant-deps/Chart.yaml) + +$(CHART_DIR)/mlflow-oidc-proxy/Chart.lock: $(CHART_DIR)/mlflow-oidc-proxy/Chart.yaml + $(HELM) dependency update $(CHART_DIR)/mlflow-oidc-proxy + +$(CHART_DIR)/mlflow-multitenant/Chart.lock: $(CHART_DIR)/mlflow-multitenant/Chart.yaml + $(HELM) dependency update $(CHART_DIR)/mlflow-multitenant + +$(CHART_DIR)/mlflow-multitenant-deps/Chart.lock: $(CHART_DIR)/mlflow-multitenant-deps/Chart.yaml + $(HELM) dependency update $(CHART_DIR)/mlflow-multitenant-deps + +CHART_LOCKS=\ + $(CHART_DIR)/mlflow-oidc-proxy/Chart.lock \ + $(CHART_DIR)/mlflow-multitenant/Chart.lock \ + $(CHART_DIR)/mlflow-multitenant-deps/Chart.lock \ + +.PHONY: chart-deps +chart-deps: + cd $(CHART_DIR)/mlflow-oidc-proxy ; helm dependency build + cd $(CHART_DIR)/mlflow-multitenant ; helm dependency build + cd $(CHART_DIR)/mlflow-multitenant-deps ; helm dependency build + +.PHONY: helm-hog +helm-hog: all-helm-tools $(CHART_LOCKS) + cd $(CHART_DIR)/mlflow-oidc-proxy ; $(LOCALBIN)/helm-hog test --no-apply --batch --auto-remove-success --parallel=0 + cd $(CHART_DIR)/mlflow-multitenant ; $(LOCALBIN)/helm-hog test --no-apply --batch --auto-remove-success --parallel=0 + cd $(CHART_DIR)/mlflow-multitenant-deps ; $(LOCALBIN)/helm lint ; $(LOCALBIN)/helm template . + +bin/charts/mlflow-oidc-proxy-$(MLFLOW_OIDC_PROXY_CHART_VERISON).tgz: all-helm-tools $(CHART_DIR)/mlflow-oidc-proxy/Chart.lock + helm package $(CHART_DIR)/mlflow-oidc-proxy --destination bin/charts + +bin/charts/mlflow-multitenant-$(MLFLOW_MULTITENANT_CHART_VERISON).tgz: all-helm-tools $(CHART_DIR)/mlflow-multitenant/Chart.lock + helm package $(CHART_DIR)/mlflow-multitenant --destination bin/charts + +bin/charts/mlflow-multitenant-deps-$(MLFLOW_MULTITENANT_DEPS_CHART_VERISON).tgz: all-helm-tools $(CHART_DIR)/mlflow-multitenant-deps/Chart.lock + helm package $(CHART_DIR)/mlflow-multitenant-deps --destination bin/charts + +CHARTS=\ + bin/charts/mlflow-oidc-proxy-$(MLFLOW_OIDC_PROXY_CHART_VERISON).tgz \ + bin/charts/mlflow-multitenant-$(MLFLOW_MULTITENANT_CHART_VERISON).tgz \ + bin/charts/mlflow-multitenant-deps-$(MLFLOW_MULTITENANT_DEPS_CHART_VERISON).tgz \ + +.PHONY: charts +charts: $(CHARTS) + + diff --git a/build-env.sh b/build-env.sh new file mode 100755 index 0000000..febc7a5 --- /dev/null +++ b/build-env.sh @@ -0,0 +1,50 @@ +#!/bin/bash -xeu + +GOPATH=${GOPATH:-~/go} + +BOOTSTRAP_GO_IMAGE=docker.io/library/golang:1.19 + +run_flags=( + --rm + --network=host + --dns-opt='options single-request' + -e GOPATH + -e HOME + -e GOPRIVATE + -e GONOSUMDB + -e GOPROXY + -v ${HOME}:${HOME} + -v ${GOPATH}:${GOPATH} + -v ${PWD}:${PWD} + -v /var/run/docker.sock:/var/run/docker.sock + -w ${PWD} + -u $(id -u):$(id -g) --group-add $(getent group docker | awk -F ':' '{ print $3 }') +) + + +GO_ARCH=$(docker run "${run_flags[@]}" "${BOOTSTRAP_GO_IMAGE}" go env GOARCH) +GO_OS=$(docker run "${run_flags[@]}" "${BOOTSTRAP_GO_IMAGE}" go env GOOS) +GINKGO_VERSION=$(docker run "${run_flags[@]}" "${BOOTSTRAP_GO_IMAGE}" go mod edit -print | grep ginkgo | cut -d ' ' -f2) + +build_flags=( + -f make-env.Dockerfile + --build-arg GO_ARCH="${GO_ARCH}" + --build-arg GO_OS="${GO_OS}" + --build-arg GINKGO_VERSION="${GINKGO_VERSION}" +) + +docker build "${build_flags[@]}" . + +build_flags+=( -q ) +image=$(docker build "${build_flags[@]}" .) + +run_flags+=( -it ) + +cmd=( "$@" ) + +if [ -z "${1:-}" ]; then + cmd=( bash ) +fi + +docker run "${run_flags[@]}" "${image}" "${cmd[@]}" + diff --git a/e2e_suite_test.go b/e2e_suite_test.go index af130ea..b67ef03 100644 --- a/e2e_suite_test.go +++ b/e2e_suite_test.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "os" + "path/filepath" "strings" "sync" "testing" @@ -40,6 +41,26 @@ var ( sharedLocalPathProvisionerImageID gingk8s.ThirdPartyImageID ) +var ( + localbin = os.Getenv("LOCALBIN") + localKubectl = gingk8s.KubectlCommand{ + Command: []string{filepath.Join(localbin, "kubectl")}, + } + localHelm = gingk8s.HelmCommand{ + Command: []string{filepath.Join(localbin, "helm")}, + } + localKind = gingk8s.KindCommand{Command: []string{filepath.Join(localbin, "kind")}} + gopts = gingk8s.SuiteOpts{ + // NoSuiteCleanup: true, + // NoSpecCleanup: true, + Kubectl: &localKubectl, + Helm: &localHelm, + Manifests: &localKubectl, + // NoCacheImages: os.Getenv("IS_CI") != "", + KLogFlags: []string{"-v", "10"}, + } +) + var _ = BeforeSuite(func(ctx context.Context) { var err error @@ -52,21 +73,8 @@ var _ = BeforeSuite(func(ctx context.Context) { Expect(os.WriteFile("modules/oauth2-proxy/Dockerfile", []byte(oauth2Dockerfile), 0x755)) gk8s = gingk8s.ForSuite(GinkgoT()) - localKubectl := &gingk8s.KubectlCommand{ - Command: []string{"bin/kubectl"}, - } - gk8s.Options(gingk8s.SuiteOpts{ - // NoSuiteCleanup: true, - // NoSpecCleanup: true, - Kubectl: localKubectl, - Helm: &gingk8s.HelmCommand{ - Command: []string{"bin/helm"}, - }, - Manifests: localKubectl, - // NoCacheImages: os.Getenv("IS_CI") != "", - KLogFlags: []string{"-v", "10"}, - }) + gk8s.Options(gopts) keycloakSetupScript, err = os.ReadFile("integration-test/keycloak-setup.sh") Expect(err).ToNot(HaveOccurred()) @@ -129,7 +137,7 @@ var _ = BeforeSuite(func(ctx context.Context) { var ( cluster = gingk8s.KindCluster{ Name: "mlflow-oidc-proxy", - KindCommand: &gingk8s.KindCommand{Command: []string{"bin/kind"}}, + KindCommand: &localKind, TempDir: "integration-test", ConfigFilePath: "integration-test/kind.config", ConfigFileTemplatePath: "integration-test/kind.config.template", diff --git a/make-env.Dockerfile b/make-env.Dockerfile new file mode 100644 index 0000000..294baf0 --- /dev/null +++ b/make-env.Dockerfile @@ -0,0 +1,185 @@ + +ARG DOCKER_ARCH=x86_64 +ARG GO_ARCH=$(shell go env GOARCH) +ARG GO_OS=$(shell go env GOOS) +ARG MAKE_ENV_BASE64=base64 +ARG MAKE_ENV_CHMOD=chmod +ARG MAKE_ENV_CURL=curl +ARG MAKE_ENV_GO=go +ARG MAKE_ENV_LN=ln +ARG MAKE_ENV_MKDIR=mkdir +ARG MAKE_ENV_MV=mv +ARG MAKE_ENV_RM=rm +ARG MAKE_ENV_TAR=tar +ARG MAKE_ENV_TOUCH=touch +ARG MAKE_ENV_UNZIP=unzip +FROM docker.io/alpine/curl:8.8.0 AS make-env-docker +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS +ARG DOCKER_MIRROR=https://download.docker.com/linux/static/stable +ARG DOCKER_VERSION=27.1.0 + +ARG DOCKER_URL=${DOCKER_MIRROR}/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz +RUN ${MAKE_ENV_MKDIR} -p /opt/make-env/download /opt/make-env/bin \ + && ${MAKE_ENV_CURL} -vfL ${DOCKER_URL} | tar -x -z -C /opt/make-env/download docker/docker \ + && ${MAKE_ENV_MV} /opt/make-env/download/docker/docker /opt/make-env/bin/docker \ + && ${MAKE_ENV_CHMOD} +x /opt/make-env/bin/docker +FROM docker.io/alpine/curl:8.8.0 AS make-env-docker-buildx +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS +ARG DOCKER_BUILDX_MIRROR=https://github.com/docker/buildx/releases/download +ARG DOCKER_BUILDX_VERSION=v0.16.1 + +ARG DOCKER_BUILDX_URL=${DOCKER_BUILDX_MIRROR}/${DOCKER_BUILDX_VERSION}/buildx-${DOCKER_BUILDX_VERSION}.${GO_OS}-${GO_ARCH} + +RUN ${MAKE_ENV_MKDIR} -p /opt/make-env/download /opt/make-env/bin \ + && ${MAKE_ENV_CURL} -vfL ${DOCKER_BUILDX_URL} -o /opt/make-env/bin/docker-buildx \ + && ${MAKE_ENV_CHMOD} +x /opt/make-env/bin/docker-buildx +FROM docker.io/library/golang:1.19 AS make-env-ginkgo +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS +ARG GINKGO_VERSION=$(shell go mod edit -print | grep ginkgo | cut -d ' ' -f2) + +RUN GOBIN=/opt/make-env/bin \ + ${MAKE_ENV_GO} install \ + github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION} +FROM docker.io/alpine/curl:8.8.0 AS make-env-helm +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS +ARG HELM_MIRROR=https://dl.k8s.io/release +ARG HELM_VERSION=v3.12.2 + +ARG HELM_URL=https://get.helm.sh/helm-${HELM_VERSION}-${GO_OS}-${GO_ARCH}.tar.gz +RUN ${MAKE_ENV_MKDIR} -p /opt/make-env/download /opt/make-env/bin \ + && ${MAKE_ENV_CURL} -vfL ${HELM_URL} | tar -x -z -C /opt/make-env/download ${GO_OS}-${GO_ARCH}/helm \ + && ${MAKE_ENV_MV} /opt/make-env/download/${GO_OS}-${GO_ARCH}/helm /opt/make-env/bin/helm \ + && ${MAKE_ENV_CHMOD} +x /opt/make-env/bin/helm +FROM docker.io/library/golang:1.19 AS make-env-helm-hog +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS + +RUN GOBIN=/opt/make-env/bin \ + ${MAKE_ENV_GO} install \ + github.com/meln5674/helm-hog@3af9ec621dcc359e38e966a255571a39beefe624 +FROM docker.io/alpine/curl:8.8.0 AS make-env-kind +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS +ARG KIND_MIRROR=https://github.com/kubernetes-sigs/kind/releases/download +ARG KIND_VERSION=v0.17.0 + +ARG KIND_URL=${KIND_MIRROR}/${KIND_VERSION}/kind-${GO_OS}-${GO_ARCH} + +RUN ${MAKE_ENV_MKDIR} -p /opt/make-env/download /opt/make-env/bin \ + && ${MAKE_ENV_CURL} -vfL ${KIND_URL} -o /opt/make-env/bin/kind \ + && ${MAKE_ENV_CHMOD} +x /opt/make-env/bin/kind +FROM docker.io/alpine/curl:8.8.0 AS make-env-kubectl +ARG MAKE_ENV_BASE64 +ARG MAKE_ENV_CHMOD +ARG MAKE_ENV_CURL +ARG MAKE_ENV_GO +ARG MAKE_ENV_LN +ARG MAKE_ENV_MKDIR +ARG MAKE_ENV_MV +ARG MAKE_ENV_RM +ARG MAKE_ENV_TAR +ARG MAKE_ENV_TOUCH +ARG MAKE_ENV_UNZIP +ARG DOCKER_ARCH +ARG GO_ARCH +ARG GO_OS +ARG KUBECTL_MIRROR=https://dl.k8s.io/release +ARG KUBECTL_VERSION=v1.25.11 + +ARG KUBECTL_URL=${KUBECTL_MIRROR}/${KUBECTL_VERSION}/bin/${GO_OS}/${GO_ARCH}/kubectl + +RUN ${MAKE_ENV_MKDIR} -p /opt/make-env/download /opt/make-env/bin \ + && ${MAKE_ENV_CURL} -vfL ${KUBECTL_URL} -o /opt/make-env/bin/kubectl \ + && ${MAKE_ENV_CHMOD} +x /opt/make-env/bin/kubectl + +FROM docker.io/library/golang:1.20.4 +ARG LOCALBIN=/usr/bin +ENV LOCALBIN=${LOCALBIN} +ENV PATH=${PATH}:${LOCALBIN} +COPY --from=make-env-docker /opt/make-env/bin/. ${LOCALBIN}/ +COPY --from=make-env-docker-buildx /opt/make-env/bin/. ${LOCALBIN}/ +COPY --from=make-env-ginkgo /opt/make-env/bin/. ${LOCALBIN}/ +COPY --from=make-env-helm /opt/make-env/bin/. ${LOCALBIN}/ +COPY --from=make-env-helm-hog /opt/make-env/bin/. ${LOCALBIN}/ +COPY --from=make-env-kind /opt/make-env/bin/. ${LOCALBIN}/ +COPY --from=make-env-kubectl /opt/make-env/bin/. ${LOCALBIN}/ +RUN mkdir -p /usr/lib/docker/cli-plugins \ + && ln -s ${LOCALBIN}/docker-buildx /usr/lib/docker/cli-plugins/ + + diff --git a/make-env.Makefile b/make-env.Makefile new file mode 100644 index 0000000..329e8aa --- /dev/null +++ b/make-env.Makefile @@ -0,0 +1,233 @@ + +DOCKER_ARCH ?= x86_64 +GO_ARCH ?= $(shell go env GOARCH) +GO_OS ?= $(shell go env GOOS) +MAKE_ENV_BASE64 ?= $(shell command -v base64) +$(MAKE_ENV_BASE64): +ifeq ($(MAKE_ENV_BASE64),) + echo "MAKE_ENV_BASE64 does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_BASE64) >/dev/null +endif +MAKE_ENV_CHMOD ?= $(shell command -v chmod) +$(MAKE_ENV_CHMOD): +ifeq ($(MAKE_ENV_CHMOD),) + echo "MAKE_ENV_CHMOD does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_CHMOD) >/dev/null +endif +MAKE_ENV_CURL ?= $(shell command -v curl) +$(MAKE_ENV_CURL): +ifeq ($(MAKE_ENV_CURL),) + echo "MAKE_ENV_CURL does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_CURL) >/dev/null +endif +MAKE_ENV_GO ?= $(shell command -v go) +$(MAKE_ENV_GO): +ifeq ($(MAKE_ENV_GO),) + echo "MAKE_ENV_GO does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_GO) >/dev/null +endif +MAKE_ENV_LN ?= $(shell command -v ln) +$(MAKE_ENV_LN): +ifeq ($(MAKE_ENV_LN),) + echo "MAKE_ENV_LN does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_LN) >/dev/null +endif +MAKE_ENV_MKDIR ?= $(shell command -v mkdir) +$(MAKE_ENV_MKDIR): +ifeq ($(MAKE_ENV_MKDIR),) + echo "MAKE_ENV_MKDIR does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_MKDIR) >/dev/null +endif +MAKE_ENV_RM ?= $(shell command -v rm) +$(MAKE_ENV_RM): +ifeq ($(MAKE_ENV_RM),) + echo "MAKE_ENV_RM does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_RM) >/dev/null +endif +MAKE_ENV_TAR ?= $(shell command -v tar) +$(MAKE_ENV_TAR): +ifeq ($(MAKE_ENV_TAR),) + echo "MAKE_ENV_TAR does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_TAR) >/dev/null +endif +MAKE_ENV_TOUCH ?= $(shell command -v touch) +$(MAKE_ENV_TOUCH): +ifeq ($(MAKE_ENV_TOUCH),) + echo "MAKE_ENV_TOUCH does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_TOUCH) >/dev/null +endif +MAKE_ENV_UNZIP ?= $(shell command -v unzip) +$(MAKE_ENV_UNZIP): +ifeq ($(MAKE_ENV_UNZIP),) + echo "MAKE_ENV_UNZIP does not exist/is not on the path" + exit 1 +else + stat $(MAKE_ENV_UNZIP) >/dev/null +endif +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + $(MAKE_ENV_MKDIR) -p $(LOCALBIN) + $(MAKE_ENV_TOUCH) $(LOCALBIN) +$(LOCALBIN)/: $(LOCALBIN) + + +DOCKER ?= $(LOCALBIN)/docker +DOCKER_MIRROR ?= https://download.docker.com/linux/static/stable +DOCKER_VERSION ?= 27.1.0 + +DOCKER_URL ?= $(DOCKER_MIRROR)/$(DOCKER_ARCH)/docker-$(DOCKER_VERSION).tgz +$(DOCKER): + + $(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0) + $(MAKE_ENV_CURL) -vfL $(DOCKER_URL) | tar -x -z -C $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0) docker/docker + $(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0)/docker/docker + $(MAKE_ENV_RM) -f $(DOCKER) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0)/docker/docker $(DOCKER) + +.PHONY: docker +docker: $(DOCKER) + + + +DOCKER_BUILDX ?= $(LOCALBIN)/docker-buildx +DOCKER_BUILDX_MIRROR ?= https://github.com/docker/buildx/releases/download +DOCKER_BUILDX_VERSION ?= v0.16.1 + +DOCKER_BUILDX_URL ?= $(DOCKER_BUILDX_MIRROR)/$(DOCKER_BUILDX_VERSION)/buildx-$(DOCKER_BUILDX_VERSION).$(GO_OS)-$(GO_ARCH) +$(DOCKER_BUILDX): + + $(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http + $(MAKE_ENV_CURL) -vfL $(DOCKER_BUILDX_URL) -o $(LOCALBIN)/.make-env/http$(shell echo $(DOCKER_BUILDX_URL) | base64 -w0) + $(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http$(shell echo $(DOCKER_BUILDX_URL) | base64 -w0) + $(MAKE_ENV_RM) -f $(DOCKER_BUILDX) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http$(shell echo $(DOCKER_BUILDX_URL) | base64 -w0) $(DOCKER_BUILDX) + +.PHONY: docker-buildx +docker-buildx: $(DOCKER_BUILDX) + + + +GINKGO ?= $(LOCALBIN)/ginkgo +GINKGO_VERSION ?= $(shell go mod edit -print | grep ginkgo | cut -d ' ' -f2) +$(GINKGO): $(MAKE_ENV_GO) + GOBIN=$(LOCALBIN)/.make-env/go/github.com/onsi/ginkgo/v2/ginkgo/$(GINKGO_VERSION) \ + $(MAKE_ENV_GO) install \ + github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION) + $(MAKE_ENV_RM) -f $(GINKGO) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/go/github.com/onsi/ginkgo/v2/ginkgo/$(GINKGO_VERSION)/ginkgo $(GINKGO) +.PHONY: ginkgo +ginkgo: $(GINKGO) + + + +HELM ?= $(LOCALBIN)/helm +HELM_MIRROR ?= https://dl.k8s.io/release +HELM_VERSION ?= v3.12.2 + +HELM_URL ?= https://get.helm.sh/helm-$(HELM_VERSION)-$(GO_OS)-$(GO_ARCH).tar.gz +$(HELM): + + $(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0) + $(MAKE_ENV_CURL) -vfL $(HELM_URL) | tar -x -z -C $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0) $(GO_OS)-$(GO_ARCH)/helm + $(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0)/$(GO_OS)-$(GO_ARCH)/helm + $(MAKE_ENV_RM) -f $(HELM) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0)/$(GO_OS)-$(GO_ARCH)/helm $(HELM) + +.PHONY: helm +helm: $(HELM) + + + +HELM_HOG ?= $(LOCALBIN)/helm-hog +$(HELM_HOG): $(MAKE_ENV_GO) + GOBIN=$(LOCALBIN)/.make-env/go/github.com/meln5674/helm-hog/3af9ec621dcc359e38e966a255571a39beefe624 \ + $(MAKE_ENV_GO) install \ + github.com/meln5674/helm-hog@3af9ec621dcc359e38e966a255571a39beefe624 + $(MAKE_ENV_RM) -f $(HELM_HOG) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/go/github.com/meln5674/helm-hog/3af9ec621dcc359e38e966a255571a39beefe624/helm-hog $(HELM_HOG) +.PHONY: helm-hog +helm-hog: $(HELM_HOG) + + + +KIND ?= $(LOCALBIN)/kind +KIND_MIRROR ?= https://github.com/kubernetes-sigs/kind/releases/download +KIND_VERSION ?= v0.17.0 + +KIND_URL ?= $(KIND_MIRROR)/$(KIND_VERSION)/kind-$(GO_OS)-$(GO_ARCH) +$(KIND): + + $(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http + $(MAKE_ENV_CURL) -vfL $(KIND_URL) -o $(LOCALBIN)/.make-env/http$(shell echo $(KIND_URL) | base64 -w0) + $(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http$(shell echo $(KIND_URL) | base64 -w0) + $(MAKE_ENV_RM) -f $(KIND) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http$(shell echo $(KIND_URL) | base64 -w0) $(KIND) + +.PHONY: kind +kind: $(KIND) + + + +KUBECTL ?= $(LOCALBIN)/kubectl +KUBECTL_MIRROR ?= https://dl.k8s.io/release +KUBECTL_VERSION ?= v1.25.11 + +KUBECTL_URL ?= $(KUBECTL_MIRROR)/$(KUBECTL_VERSION)/bin/$(GO_OS)/$(GO_ARCH)/kubectl +$(KUBECTL): + + $(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http + $(MAKE_ENV_CURL) -vfL $(KUBECTL_URL) -o $(LOCALBIN)/.make-env/http$(shell echo $(KUBECTL_URL) | base64 -w0) + $(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http$(shell echo $(KUBECTL_URL) | base64 -w0) + $(MAKE_ENV_RM) -f $(KUBECTL) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http$(shell echo $(KUBECTL_URL) | base64 -w0) $(KUBECTL) + +.PHONY: kubectl +kubectl: $(KUBECTL) + + + +YQ ?= $(LOCALBIN)/yq +YQ_MIRROR ?= github.com/mikefarah/yq/releases/download +YQ_VERSION ?= v4.44.1 + +YQ_URL ?= https://$(YQ_MIRROR)/$(YQ_VERSION)/yq_$(GO_OS)_$(GO_ARCH).tar.gz +$(YQ): + + $(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0) + $(MAKE_ENV_CURL) -vfL $(YQ_URL) | tar -x -z -C $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0) ./yq_$(GO_OS)_$(GO_ARCH) + $(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0)/./yq_$(GO_OS)_$(GO_ARCH) + $(MAKE_ENV_RM) -f $(YQ) + $(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0)/./yq_$(GO_OS)_$(GO_ARCH) $(YQ) + +.PHONY: yq +yq: $(YQ) + +.PHONY: all-e2e-tools +all-e2e-tools: $(GINKGO) $(KUBECTL) $(HELM) $(DOCKER) $(KIND) $(HELM_HOG) + +.PHONY: all-helm-tools +all-helm-tools: $(YQ) $(HELM) $(HELM_HOG) $(DOCKER) $(KIND) + +.PHONY: all-test-tools +all-test-tools: $(GINKGO) + +make-env.Makefile: make-env.yaml + make-env --config 'make-env.yaml' --out 'make-env.Makefile' diff --git a/make-env.yaml b/make-env.yaml new file mode 100644 index 0000000..f140265 --- /dev/null +++ b/make-env.yaml @@ -0,0 +1,88 @@ +vars: + goOS: $(shell go env GOOS) + goArch: $(shell go env GOARCH) + dockerArch: x86_64 + + +tools: + yq: + http: + url: 'https://{{ .Vars.mirror }}/{{ .Vars.version }}/yq_{{ .Vars.goOS }}_{{ .Vars.goArch }}.tar.gz' + tar: + compression: gzip + path: './yq_{{ .Vars.goOS }}_{{ .Vars.goArch }}' + vars: + mirror: github.com/mikefarah/yq/releases/download + version: v4.44.1 + ginkgo: + go: + module: github.com/onsi/ginkgo/v2 + subPath: ginkgo + version: '{{ .Vars.version }}' + vars: + version: $(shell go mod edit -print | grep ginkgo | cut -d ' ' -f2) + kubectl: + http: + url: '{{ .Vars.mirror }}/{{ .Vars.version }}/bin/{{ .Vars.goOS }}/{{ .Vars.goArch }}/kubectl' + vars: + mirror: https://dl.k8s.io/release + version: v1.25.11 + helm: + http: + url: 'https://get.helm.sh/helm-{{ .Vars.version }}-{{ .Vars.goOS }}-{{ .Vars.goArch }}.tar.gz' + tar: + compression: gzip + path: '{{ .Vars.goOS }}-{{ .Vars.goArch }}/helm' + vars: + mirror: https://dl.k8s.io/release + version: v3.12.2 + docker: + http: + url: '{{ .Vars.mirror }}/{{ .Vars.dockerArch }}/docker-{{ .Vars.version }}.tgz' + tar: + compression: gzip + path: docker/docker + vars: + mirror: https://download.docker.com/linux/static/stable + version: 27.1.0 + docker-buildx: + http: + url: '{{ .Vars.mirror }}/{{ .Vars.version }}/buildx-{{ .Vars.version }}.{{ .Vars.goOS }}-{{ .Vars.goArch }}' + vars: + mirror: https://github.com/docker/buildx/releases/download + version: v0.16.1 + kind: + http: + url: '{{ .Vars.mirror }}/{{ .Vars.version }}/kind-{{ .Vars.goOS }}-{{ .Vars.goArch }}' + vars: + mirror: https://github.com/kubernetes-sigs/kind/releases/download + version: v0.17.0 + helm-hog: + go: + module: github.com/meln5674/helm-hog + version: 3af9ec621dcc359e38e966a255571a39beefe624 + +toolSets: + all-test-tools: + - ginkgo + all-e2e-tools: + - ginkgo + - kubectl + - helm + - docker + - kind + - helm-hog + all-helm-tools: + - yq + - helm + - helm-hog + - docker + - kind + +dockerfile: + from: docker.io/library/golang:1.20.4 + goImage: docker.io/library/golang:1.19 + curlImage: docker.io/alpine/curl:8.8.0 + postCopy: | + RUN mkdir -p /usr/lib/docker/cli-plugins \ + && ln -s ${LOCALBIN}/docker-buildx /usr/lib/docker/cli-plugins/ diff --git a/set-chart-versions.sh b/set-chart-versions.sh new file mode 100755 index 0000000..cc6d083 --- /dev/null +++ b/set-chart-versions.sh @@ -0,0 +1,28 @@ +#!/bin/bash -xeu + +# This script sets the chart versions, given a destination helm repository, git commit SHA, and optionally a git tag. +# If the tag is empty, each chart version is set to the current version, suffixed with that sha +# If the tag is non-empty, each chart version is set to that tag +# Because the multitenant chart depends on the standalone chart, the provided repo is set as the dependency url +# Finally, the appVersion of each is set to the tag, if present, else the sha, with no prefix or suffix + +HELM_REPO=$1 +GIT_SHA=$2 +GIT_TAG=${3:-} + +CHART_DIR=${CHART_DIR:-deploy/helm} +YQ=${YQ:-yq} + +CHART_APPVERSION="${GIT_TAG:-${GIT_SHA}}" +if [ -n "${GIT_TAG}" ]; then + NEW_VERSION_EXPR='"'"${GIT_TAG}"'"' +else + NEW_VERSION_EXPR='.version + "-'"${GIT_SHA}"'"' +fi +for chart in mlflow-oidc-proxy mlflow-multitenant-deps mlflow-multitenant; do + ${YQ} -i '.version = '"${NEW_VERSION_EXPR}"'' "${CHART_DIR}/${chart}/Chart.yaml" +done +${YQ} -i '.appVersion = "'"${CHART_APPVERSION}"'"' "${CHART_DIR}/mlflow-oidc-proxy/Chart.yaml" +STANDALONE_CHART_VERSION="$(yq '.version' "${CHART_DIR}/mlflow-oidc-proxy/Chart.yaml")" +${YQ} -i '(.dependencies[] | select(.name == "mlflow-oidc-proxy")).version |= "'"${STANDALONE_CHART_VERSION}"'"' "${CHART_DIR}/mlflow-multitenant/Chart.yaml" +${YQ} -i '(.dependencies[] | select(.name == "mlflow-oidc-proxy")).repository |= "'"${HELM_REPO}"'"' "${CHART_DIR}/mlflow-multitenant/Chart.yaml"