2021-08-24 21:46:00 +03:00
REGISTRY ?= mcr.microsoft.com/oss/azure/workload-identity
2021-05-25 22:12:45 +03:00
PROXY_IMAGE_NAME := proxy
2021-05-01 00:51:28 +03:00
INIT_IMAGE_NAME := proxy-init
2021-05-22 00:17:04 +03:00
WEBHOOK_IMAGE_NAME := webhook
2022-12-14 02:13:02 +03:00
IMAGE_VERSION ?= v0.15.0
2021-05-01 00:51:28 +03:00
2021-07-16 00:52:25 +03:00
ORG_PATH := github.com/Azure
2021-08-24 21:46:00 +03:00
PROJECT_NAME := azure-workload-identity
2021-07-16 00:52:25 +03:00
BUILD_COMMIT := $( shell git rev-parse --short HEAD)
2021-10-12 02:50:45 +03:00
REPO_PATH := $( ORG_PATH) /$( PROJECT_NAME)
2021-07-16 00:52:25 +03:00
# build variables
BUILD_TIMESTAMP := $$ ( date +%Y-%m-%d-%H:%M)
BUILD_TIME_VAR := $( REPO_PATH) /pkg/version.BuildTime
BUILD_VERSION_VAR := $( REPO_PATH) /pkg/version.BuildVersion
VCS_VAR := $( REPO_PATH) /pkg/version.Vcs
2022-06-16 23:47:31 +03:00
PROXY_IMAGE_REGISTRY_VAR := $( REPO_PATH) /pkg/webhook.ProxyImageRegistry
PROXY_IMAGE_VERSION_VAR := $( REPO_PATH) /pkg/webhook.ProxyImageVersion
LDFLAGS ?= " -X $( BUILD_TIME_VAR) = $( BUILD_TIMESTAMP) -X $( BUILD_VERSION_VAR) = $( IMAGE_VERSION) -X $( VCS_VAR) = $( BUILD_COMMIT) -X $( PROXY_IMAGE_VERSION_VAR) = $( IMAGE_VERSION) -X $( PROXY_IMAGE_REGISTRY_VAR) = $( REGISTRY) "
2021-07-16 00:52:25 +03:00
2021-05-13 23:06:27 +03:00
PROXY_IMAGE := $( REGISTRY) /$( PROXY_IMAGE_NAME) :$( IMAGE_VERSION)
INIT_IMAGE := $( REGISTRY) /$( INIT_IMAGE_NAME) :$( IMAGE_VERSION)
2021-05-22 00:17:04 +03:00
WEBHOOK_IMAGE := $( REGISTRY) /$( WEBHOOK_IMAGE_NAME) :$( IMAGE_VERSION)
2021-05-01 00:51:28 +03:00
2021-10-12 02:50:45 +03:00
GOOS ?= $( shell go env GOOS)
GOARCH ?= $( shell go env GOARCH)
2021-07-13 22:02:30 +03:00
2021-05-05 03:06:06 +03:00
# Directories
ROOT_DIR := $( shell dirname $( realpath $( firstword $( MAKEFILE_LIST) ) ) )
BIN_DIR := $( abspath $( ROOT_DIR) /bin)
TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $( abspath $( TOOLS_DIR) /bin)
# Binaries
2021-05-11 00:28:14 +03:00
CONTROLLER_GEN_VER := v0.5.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $( TOOLS_BIN_DIR) /$( CONTROLLER_GEN_BIN) -$( CONTROLLER_GEN_VER)
2021-05-05 03:06:06 +03:00
E2E_TEST_BIN := e2e.test
E2E_TEST := $( BIN_DIR) /$( E2E_TEST_BIN)
2022-09-09 19:44:26 +03:00
GINKGO_VER := v2.1.6
2021-05-05 03:06:06 +03:00
GINKGO_BIN := ginkgo
GINKGO := $( TOOLS_BIN_DIR) /$( GINKGO_BIN) -$( GINKGO_VER)
2022-06-03 00:19:20 +03:00
KIND_VER := v0.14.0
2021-05-12 01:34:15 +03:00
KIND_BIN := kind
KIND := $( TOOLS_BIN_DIR) /$( KIND_BIN) -$( KIND_VER)
2021-11-30 03:50:27 +03:00
KUBECTL_VER := v1.22.4
2021-05-11 00:28:14 +03:00
KUBECTL_BIN := kubectl
KUBECTL := $( TOOLS_BIN_DIR) /$( KUBECTL_BIN) -$( KUBECTL_VER)
2021-05-05 03:06:06 +03:00
2021-05-11 00:28:14 +03:00
KUSTOMIZE_VER := v4.1.2
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $( TOOLS_BIN_DIR) /$( KUSTOMIZE_BIN) -$( KUSTOMIZE_VER)
2021-05-05 03:06:06 +03:00
2023-01-18 04:49:33 +03:00
GOLANGCI_LINT_VER := v1.50.0
2021-05-11 02:21:01 +03:00
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $( TOOLS_BIN_DIR) /$( GOLANGCI_LINT_BIN) -$( GOLANGCI_LINT_VER)
2021-05-12 01:34:15 +03:00
SHELLCHECK_VER := v0.7.2
SHELLCHECK_BIN := shellcheck
SHELLCHECK := $( TOOLS_BIN_DIR) /$( SHELLCHECK_BIN) -$( SHELLCHECK_VER)
2021-05-13 22:04:35 +03:00
ENVSUBST_VER := v1.2.0
ENVSUBST_BIN := envsubst
2021-09-06 23:53:47 +03:00
ENVSUBST := $( TOOLS_BIN_DIR) /$( ENVSUBST_BIN) -$( ENVSUBST_VER)
2021-05-13 22:04:35 +03:00
2021-07-13 22:02:30 +03:00
HELM_VER := v3.6.2
HELM_BIN := helm
HELM := $( TOOLS_BIN_DIR) /$( HELM_BIN) -$( HELM_VER)
2021-10-08 20:24:04 +03:00
MOCKGEN_VER := v1.6.0
MOCKGEN_BIN := mockgen
MOCKGEN := $( TOOLS_BIN_DIR) /$( MOCKGEN_BIN) -$( MOCKGEN_VER)
2021-05-11 00:28:14 +03:00
# Scripts
GO_INSTALL := ./hack/go-install.sh
2021-10-08 20:24:04 +03:00
## --------------------------------------
## Binaries
## --------------------------------------
2021-10-12 02:50:45 +03:00
EXTENSION.linux :=
EXTENSION.darwin :=
EXTENSION.windows := .exe
EXTENSION := $( EXTENSION.$( GOOS) )
bin/azwi-$(GOOS)-$(GOARCH)$(EXTENSION) :
GOOS = $( GOOS) GOARCH = $( GOARCH) go build -o $( BIN_DIR) /azwi-$( GOOS) -$( GOARCH) $( EXTENSION) -ldflags $( LDFLAGS) ./cmd/azwi
2021-10-08 20:24:04 +03:00
2021-11-09 21:48:35 +03:00
bin/azwi : bin /azwi -$( GOOS ) -$( GOARCH ) $( EXTENSION )
2021-12-08 02:25:12 +03:00
@if [ " $( GOOS) " = "windows" ] ; then \
cmd //c mklink $( subst /,\\ ,$( BIN_DIR) /azwi) $( subst /,\, $( BIN_DIR) /azwi-$( GOOS) -$( GOARCH) $( EXTENSION) ) ; \
else \
ln -sf $( BIN_DIR) /azwi-$( GOOS) -$( GOARCH) $( EXTENSION) $( BIN_DIR) /azwi; \
fi
2021-11-09 21:48:35 +03:00
2021-05-11 00:28:14 +03:00
## --------------------------------------
2021-05-13 23:06:27 +03:00
## Images
2021-05-11 00:28:14 +03:00
## --------------------------------------
OUTPUT_TYPE ?= type = registry
2021-10-07 18:46:05 +03:00
ALL_IMAGES ?= $( PROXY_IMAGE_NAME) $( INIT_IMAGE_NAME) $( WEBHOOK_IMAGE_NAME)
ALL_LINUX_ARCH ?= amd64 arm64
2021-05-01 00:51:28 +03:00
2021-10-07 18:46:05 +03:00
# split words on hyphen, access by 1-index
split-by-hyphen = $( word $2 ,$( subst -, ,$1 ) )
2021-05-22 00:17:04 +03:00
2021-10-07 18:46:05 +03:00
BUILDX_BUILDER_NAME ?= img-builder
QEMU_VERSION ?= 5.2.0-2
2021-05-13 23:06:27 +03:00
2021-10-28 00:24:32 +03:00
.PHONY : docker -buildx -builder
docker-buildx-builder :
2021-10-07 18:46:05 +03:00
@if ! docker buildx ls | grep $( BUILDX_BUILDER_NAME) ; then \
docker run --rm --privileged multiarch/qemu-user-static:$( QEMU_VERSION) --reset -p yes; \
docker buildx create --name $( BUILDX_BUILDER_NAME) --use; \
docker buildx inspect $( BUILDX_BUILDER_NAME) --bootstrap; \
fi
2021-10-28 00:24:32 +03:00
.PHONY : docker -build
docker-build : docker -buildx -builder
2021-10-07 18:46:05 +03:00
for img in $( ALL_IMAGES) ; do \
for arch in $( ALL_LINUX_ARCH) ; do \
IMAGE_NAME = $$ { img} ARCH = $$ { arch} $( MAKE) .image-$$ { img} -$$ { arch} ; \
done ; \
done
.image-% :
docker buildx build \
--build-arg LDFLAGS = $( LDFLAGS) \
--file docker/$( IMAGE_NAME) .Dockerfile \
--output= $( OUTPUT_TYPE) \
--platform= " linux/ $( ARCH) " \
--pull \
--tag $( REGISTRY) /$( IMAGE_NAME) :$( IMAGE_VERSION) -linux-$( ARCH) .
@if [ " $( ARCH) " = "amd64" ] && [ " $( OUTPUT_TYPE) " = "type=docker" ] ; then \
docker tag $( REGISTRY) /$( IMAGE_NAME) :$( IMAGE_VERSION) -linux-$( ARCH) $( REGISTRY) /$( IMAGE_NAME) :$( IMAGE_VERSION) ; \
fi
touch $@
.PHONY : docker -push -manifest
docker-push-manifest :
for img in $( ALL_IMAGES) ; do \
docker manifest create --amend $( REGISTRY) /$$ { img} :$( IMAGE_VERSION) $( foreach arch,$( ALL_LINUX_ARCH) ,$( REGISTRY) /$$ { img} :$( IMAGE_VERSION) -linux-$( arch) ) ; \
for arch in $( ALL_LINUX_ARCH) ; do docker manifest annotate --os linux --arch $$ { arch} $( REGISTRY) /$$ { img} :$( IMAGE_VERSION) $( REGISTRY) /$$ { img} :$( IMAGE_VERSION) -linux-$$ { arch} ; done ; \
docker manifest push --purge $( REGISTRY) /$$ { img} :$( IMAGE_VERSION) ; \
done
2021-05-22 00:17:04 +03:00
2021-05-04 22:30:57 +03:00
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
2021-05-11 00:28:14 +03:00
.PHONY : all
2021-05-04 22:30:57 +03:00
all : manager
# Build manager binary
2021-05-11 00:28:14 +03:00
.PHONY : manager
2021-05-04 22:30:57 +03:00
manager : generate fmt vet
2021-07-16 00:52:25 +03:00
go build -a -ldflags $( LDFLAGS) -o bin/manager cmd/webhook/main.go
2021-05-04 22:30:57 +03:00
2021-08-12 23:43:14 +03:00
# Build proxy binary
.PHONY : proxy
proxy : fmt vet
go build -a -ldflags $( LDFLAGS) -o bin/proxy cmd/proxy/main.go
2021-05-04 22:30:57 +03:00
# Run against the configured Kubernetes cluster in ~/.kube/config
2021-05-11 00:28:14 +03:00
.PHONY : run
2021-05-04 22:30:57 +03:00
run : generate fmt vet manifests
go run .cmd/webhook/main.go
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
2021-05-18 21:44:00 +03:00
ARC_CLUSTER ?= false
2021-10-30 00:29:25 +03:00
DEPLOYMENT_YAML ?= false
2021-05-18 21:44:00 +03:00
2021-05-11 00:28:14 +03:00
.PHONY : deploy
2021-05-13 22:04:35 +03:00
deploy : $( KUBECTL ) $( KUSTOMIZE ) $( ENVSUBST )
2021-07-20 01:32:46 +03:00
$( MAKE) manifests
2021-10-30 00:29:25 +03:00
@if [ " $( DEPLOYMENT_YAML) " = "true" ] ; then \
cat manifest_staging/deploy/azure-wi-webhook.yaml | $( ENVSUBST) | $( KUBECTL) apply -f -; \
else \
cd config/manager && $( KUSTOMIZE) edit set image manager = $( WEBHOOK_IMAGE) ; \
$( KUSTOMIZE) build ../default | $( ENVSUBST) | $( KUBECTL) apply -f -; \
fi
2021-08-24 21:46:00 +03:00
$( KUBECTL) wait --for= condition = Available --timeout= 5m -n azure-workload-identity-system deployment/azure-wi-webhook-controller-manager
2021-05-11 00:28:14 +03:00
2021-07-13 22:02:30 +03:00
.PHONY : uninstall -deploy
uninstall-deploy : $( KUBECTL ) $( KUSTOMIZE ) $( ENVSUBST )
2021-10-30 00:29:25 +03:00
@if [ " $( DEPLOYMENT_YAML) " = "true" ] ; then \
$( KUBECTL) apply -f manifest_staging/deploy/azure-wi-webhook.yaml; \
else \
$( KUSTOMIZE) build config/default | $( ENVSUBST) | $( KUBECTL) delete -f -; \
fi
2021-07-13 22:02:30 +03:00
2021-05-11 00:28:14 +03:00
## --------------------------------------
## Code Generation
## --------------------------------------
2021-05-04 22:30:57 +03:00
# Generate manifests e.g. CRD, RBAC etc.
2021-05-11 00:28:14 +03:00
.PHONY : manifests
2021-05-25 03:35:13 +03:00
manifests : $( CONTROLLER_GEN ) $( KUSTOMIZE )
2021-05-04 22:30:57 +03:00
$( CONTROLLER_GEN) $( CRD_OPTIONS) rbac:roleName= manager-role webhook paths = "./..."
2021-07-08 05:37:42 +03:00
rm -rf manifest_staging
mkdir -p manifest_staging/deploy
2021-08-24 21:46:00 +03:00
mkdir -p manifest_staging/charts/workload-identity-webhook
2021-07-08 05:37:42 +03:00
2021-08-24 21:46:00 +03:00
$( KUSTOMIZE) build config/default -o manifest_staging/deploy/azure-wi-webhook.yaml
2021-07-08 05:37:42 +03:00
$( KUSTOMIZE) build third_party/open-policy-agent/gatekeeper/helmify | go run third_party/open-policy-agent/gatekeeper/helmify/*.go
2021-05-11 00:28:14 +03:00
# Generate code
.PHONY : generate
2021-10-08 20:24:04 +03:00
generate : $( CONTROLLER_GEN ) $( MOCKGEN ) ## Runs Go related generate targets
2021-05-11 00:28:14 +03:00
$( CONTROLLER_GEN) object:headerFile= "hack/boilerplate.go.txt" paths = "./..."
2021-10-08 20:24:04 +03:00
go generate ./...
2021-05-11 00:28:14 +03:00
## --------------------------------------
## Tooling Binaries and Manifests
## --------------------------------------
$(CONTROLLER_GEN) :
GOBIN = $( TOOLS_BIN_DIR) $( GO_INSTALL) sigs.k8s.io/controller-tools/cmd/controller-gen $( CONTROLLER_GEN_BIN) $( CONTROLLER_GEN_VER)
$(GINKGO) :
2022-09-09 19:44:26 +03:00
GOBIN = $( TOOLS_BIN_DIR) $( GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $( GINKGO_BIN) $( GINKGO_VER)
2021-05-11 00:28:14 +03:00
2021-05-12 01:34:15 +03:00
$(KIND) :
GOBIN = $( TOOLS_BIN_DIR) $( GO_INSTALL) sigs.k8s.io/kind $( KIND_BIN) $( KIND_VER)
2021-05-11 00:28:14 +03:00
$(KUSTOMIZE) :
2021-09-06 23:53:47 +03:00
mkdir -p $( TOOLS_BIN_DIR)
rm -rf " $( SHELLCHECK) * "
curl -sfOL " https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F $( KUSTOMIZE_VER) /kustomize_ $( KUSTOMIZE_VER) _ $( GOOS) _ $( GOARCH) .tar.gz "
tar xf kustomize_${ KUSTOMIZE_VER } _$( GOOS) _$( GOARCH) .tar.gz
cp "kustomize" " $( KUSTOMIZE) "
ln -sf " $( KUSTOMIZE) " " $( TOOLS_BIN_DIR) / $( KUSTOMIZE_BIN) "
chmod +x " $( TOOLS_BIN_DIR) / $( KUSTOMIZE_BIN) " " $( KUSTOMIZE) "
rm -rf kustomize*
2021-05-11 00:28:14 +03:00
$(KUBECTL) :
mkdir -p $( TOOLS_BIN_DIR)
rm -f " $( KUBECTL) * "
2021-07-13 22:02:30 +03:00
curl -sfL https://storage.googleapis.com/kubernetes-release/release/$( KUBECTL_VER) /bin/$( GOOS) /$( GOARCH) /kubectl -o $( KUBECTL)
2021-05-11 00:28:14 +03:00
ln -sf " $( KUBECTL) " " $( TOOLS_BIN_DIR) / $( KUBECTL_BIN) "
chmod +x " $( TOOLS_BIN_DIR) / $( KUBECTL_BIN) " " $( KUBECTL) "
2021-05-11 02:21:01 +03:00
$(GOLANGCI_LINT) :
GOBIN = $( TOOLS_BIN_DIR) $( GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $( GOLANGCI_LINT_BIN) $( GOLANGCI_LINT_VER)
2021-10-07 18:46:05 +03:00
$(SHELLCHECK) : OS := $( shell uname | tr '[:upper :]' '[:lower :]')
$(SHELLCHECK) : ARCH := $( shell uname -m )
2021-05-12 01:34:15 +03:00
$(SHELLCHECK) :
mkdir -p $( TOOLS_BIN_DIR)
rm -rf " $( SHELLCHECK) * "
curl -sfOL " https://github.com/koalaman/shellcheck/releases/download/ $( SHELLCHECK_VER) /shellcheck- $( SHELLCHECK_VER) . $( OS) . $( ARCH) .tar.xz "
tar xf shellcheck-$( SHELLCHECK_VER) .$( OS) .$( ARCH) .tar.xz
cp " shellcheck- $( SHELLCHECK_VER) / $( SHELLCHECK_BIN) " " $( SHELLCHECK) "
ln -sf " $( SHELLCHECK) " " $( TOOLS_BIN_DIR) / $( SHELLCHECK_BIN) "
chmod +x " $( TOOLS_BIN_DIR) / $( SHELLCHECK_BIN) " " $( SHELLCHECK) "
rm -rf shellcheck*
2021-05-13 22:04:35 +03:00
$(ENVSUBST) :
GOBIN = $( TOOLS_BIN_DIR) $( GO_INSTALL) github.com/a8m/envsubst/cmd/envsubst $( ENVSUBST_BIN) $( ENVSUBST_VER)
2021-10-07 18:46:05 +03:00
$(HELM) : OS := $( shell uname | tr '[:upper :]' '[:lower :]')
2021-07-13 22:02:30 +03:00
$(HELM) :
curl -sfOL " https://get.helm.sh/helm- $( HELM_VER) - $( GOOS) - $( GOARCH) .tar.gz "
tar -zxvf helm-$( HELM_VER) -$( GOOS) -$( GOARCH) .tar.gz
cp " $( OS) - $( GOARCH) / $( HELM_BIN) " " $( HELM) "
ln -sf " $( HELM) " " $( TOOLS_BIN_DIR) / $( HELM_BIN) "
chmod +x " $( TOOLS_BIN_DIR) / $( HELM_BIN) " " $( HELM) "
rm -rf helm* $( OS) -$( GOARCH)
2021-10-08 20:24:04 +03:00
$(MOCKGEN) : ## Build mockgen from tools folder.
GOBIN = $( TOOLS_BIN_DIR) $( GO_INSTALL) github.com/golang/mock/mockgen $( MOCKGEN_BIN) $( MOCKGEN_VER)
2021-08-06 21:23:05 +03:00
## --------------------------------------
## E2E images
## --------------------------------------
2021-10-08 19:27:41 +03:00
MSAL_GO_E2E_IMAGE_NAME := msal-go-e2e
MSAL_GO_E2E_IMAGE := $( REGISTRY) /$( MSAL_GO_E2E_IMAGE_NAME) :$( IMAGE_VERSION)
2021-08-06 21:23:05 +03:00
.PHONY : docker -build -e 2e -msal -go
docker-build-e2e-msal-go :
docker buildx build --no-cache -t $( MSAL_GO_E2E_IMAGE) -f examples/msal-go/Dockerfile --platform= "linux/amd64" --output= $( OUTPUT_TYPE) examples/msal-go
2021-10-08 19:27:41 +03:00
touch .image-$( MSAL_GO_E2E_IMAGE_NAME) -amd64
2021-08-06 21:23:05 +03:00
2021-05-11 00:28:14 +03:00
## --------------------------------------
## Testing
## --------------------------------------
2021-05-04 22:30:57 +03:00
# Run go fmt against code
2021-05-11 00:28:14 +03:00
.PHONY : fmt
2021-05-04 22:30:57 +03:00
fmt :
go fmt ./...
# Run go vet against code
2021-05-11 00:28:14 +03:00
.PHONY : vet
2021-05-04 22:30:57 +03:00
vet :
go vet ./...
2021-05-11 00:28:14 +03:00
# Run tests
.PHONY : test
2021-12-11 02:19:26 +03:00
test : generate manifests
go test -v ./... -coverprofile cover.out
2021-05-05 03:06:06 +03:00
$(E2E_TEST) :
2022-10-27 22:50:56 +03:00
( cd test/e2e && go test -tags= e2e -c . -o $( E2E_TEST) )
2021-05-05 03:06:06 +03:00
2021-05-11 00:28:14 +03:00
# Ginkgo configurations
GINKGO_FOCUS ?=
GINKGO_SKIP ?=
2021-12-15 01:00:00 +03:00
GINKGO_NODES ?= 1
2021-05-11 00:28:14 +03:00
GINKGO_NO_COLOR ?= false
2021-07-23 20:12:09 +03:00
GINKGO_TIMEOUT ?= 5m
2022-09-09 19:44:26 +03:00
GINKGO_ARGS ?= -focus= " $( GINKGO_FOCUS) " -skip= " $( GINKGO_SKIP) " -nodes= $( GINKGO_NODES) -no-color= $( GINKGO_NO_COLOR) -timeout= $( GINKGO_TIMEOUT)
2021-05-11 00:28:14 +03:00
# E2E configurations
KUBECONFIG ?= $( HOME) /.kube/config
2021-08-12 23:43:14 +03:00
E2E_ARGS := -kubeconfig= $( KUBECONFIG) -report-dir= $( PWD) /_artifacts \
-e2e.arc-cluster= $( ARC_CLUSTER) \
2022-07-01 06:56:14 +03:00
-e2e.token-exchange-image= $( MSAL_GO_E2E_IMAGE)
2021-07-17 00:36:59 +03:00
E2E_EXTRA_ARGS ?=
2021-05-05 03:06:06 +03:00
.PHONY : test -e 2e -run
test-e2e-run : $( E 2E_TEST ) $( GINKGO )
2021-05-18 21:44:00 +03:00
$( GINKGO) -v -trace $( GINKGO_ARGS) \
2021-07-17 00:36:59 +03:00
$( E2E_TEST) -- $( E2E_ARGS) $( E2E_EXTRA_ARGS)
2021-05-05 03:06:06 +03:00
.PHONY : test -e 2e
2021-07-13 22:02:30 +03:00
test-e2e : $( KUBECTL ) $( HELM )
2021-05-11 00:28:14 +03:00
./scripts/ci-e2e.sh
## --------------------------------------
## Kind
## --------------------------------------
2021-08-24 21:46:00 +03:00
KIND_CLUSTER_NAME ?= azure-workload-identity
2021-05-12 01:34:15 +03:00
2021-05-11 00:28:14 +03:00
.PHONY : kind -create
2021-05-12 01:34:15 +03:00
kind-create : $( KIND ) $( KUBECTL )
./scripts/create-kind-cluster.sh
2021-06-18 20:03:27 +03:00
2021-10-08 19:27:41 +03:00
.PHONY : kind -load -images
kind-load-images :
-[ -f .image-$( WEBHOOK_IMAGE_NAME) -amd64 ] && $( KIND) load docker-image $( WEBHOOK_IMAGE) --name $( KIND_CLUSTER_NAME)
-[ -f .image-$( PROXY_IMAGE_NAME) -amd64 ] && $( KIND) load docker-image $( PROXY_IMAGE) --name $( KIND_CLUSTER_NAME)
-[ -f .image-$( INIT_IMAGE_NAME) -amd64 ] && $( KIND) load docker-image $( INIT_IMAGE) --name $( KIND_CLUSTER_NAME)
-[ -f .image-$( MSAL_GO_E2E_IMAGE_NAME) -amd64 ] && $( KIND) load docker-image $( MSAL_GO_E2E_IMAGE) --name $( KIND_CLUSTER_NAME)
2021-05-11 00:28:14 +03:00
.PHONY : kind -delete
2021-05-12 01:34:15 +03:00
kind-delete : $( KIND )
$( KIND) delete cluster --name= $( KIND_CLUSTER_NAME) || true
2021-05-11 00:28:14 +03:00
## --------------------------------------
## Cleanup
## --------------------------------------
2021-05-05 03:06:06 +03:00
.PHONY : clean
clean :
2021-05-11 00:28:14 +03:00
@rm -rf $( BIN_DIR)
2021-10-07 18:46:05 +03:00
@rm -rf .image-*
2021-05-11 02:21:01 +03:00
## --------------------------------------
## Linting
## --------------------------------------
.PHONY : lint
lint : $( GOLANGCI_LINT )
$( GOLANGCI_LINT) run -v
2021-07-13 22:02:30 +03:00
.PHONY : helm -lint
helm-lint : $( HELM )
2021-08-24 21:46:00 +03:00
$( HELM) lint manifest_staging/charts/workload-identity-webhook
2021-07-13 22:02:30 +03:00
2021-05-12 01:34:15 +03:00
.PHONY : lint -full
2021-05-11 02:21:01 +03:00
lint-full : $( GOLANGCI_LINT ) ## Run slower linters to detect possible issues
$( GOLANGCI_LINT) run -v --fast= false
2021-05-12 01:34:15 +03:00
.PHONY : shellcheck
shellcheck : $( SHELLCHECK )
$( SHELLCHECK) */*.sh
2021-05-25 03:35:13 +03:00
## --------------------------------------
## Release
## --------------------------------------
2021-07-08 05:37:42 +03:00
2021-08-07 01:11:23 +03:00
release-manifest : $( KUSTOMIZE )
2021-08-05 02:00:48 +03:00
@sed -i -e 's/^IMAGE_VERSION ?= .*/IMAGE_VERSION ?= ${NEW_VERSION}/' ./Makefile
cd config/manager && $( KUSTOMIZE) edit set image manager = $( REGISTRY) /$( WEBHOOK_IMAGE_NAME) :$( NEW_VERSION)
2021-07-08 05:37:42 +03:00
@sed -i -e " s/appVersion: .*/appVersion: ${ NEW_VERSION } / " ./third_party/open-policy-agent/gatekeeper/helmify/static/Chart.yaml
@sed -i -e " s/version: .*/version: $$ (echo ${ NEW_VERSION } | cut -c2-)/ " ./third_party/open-policy-agent/gatekeeper/helmify/static/Chart.yaml
@sed -i -e " s/release: .*/release: ${ NEW_VERSION } / " ./third_party/open-policy-agent/gatekeeper/helmify/static/values.yaml
@sed -i -e 's/Current release version: `.*`/Current release version: `' " ${ NEW_VERSION } " '`/' ./third_party/open-policy-agent/gatekeeper/helmify/static/README.md
2021-10-14 05:19:07 +03:00
@sed -i -e 's/proxy-init:.*/proxy-init:${NEW_VERSION}/' ./examples/migration/pod-with-proxy-init-and-proxy-sidecar.yaml
@sed -i -e 's/proxy:.*/proxy:${NEW_VERSION}/' ./examples/migration/pod-with-proxy-init-and-proxy-sidecar.yaml
@sed -i -e 's/proxy-init:[^"]*/proxy-init:${NEW_VERSION}/' ./test/e2e/e2e_test.go
@sed -i -e 's/proxy:[^"]*/proxy:${NEW_VERSION}/' ./test/e2e/e2e_test.go
2021-10-29 01:44:00 +03:00
@sed -i -e 's|download/v.*/azure-wi-webhook.yaml|download/${NEW_VERSION}/azure-wi-webhook.yaml|' ./docs/book/src/installation/mutating-admission-webhook.md
@sed -i -e 's|azwi@v.*|azwi@${NEW_VERSION}|' ./docs/book/src/installation/azwi.md
2022-05-05 23:15:17 +03:00
@sed -i -e 's|imageTag = .*|imageTag = "${NEW_VERSION}"|' ./pkg/cmd/podidentity/detect.go
2021-07-08 05:37:42 +03:00
$( MAKE) manifests
2021-05-25 03:35:13 +03:00
.PHONY : promote -staging -manifest
2021-07-28 23:41:28 +03:00
promote-staging-manifest : #promote staging manifests to release dir
2021-05-25 03:35:13 +03:00
@rm -rf deploy
@cp -r manifest_staging/deploy .
2021-08-24 21:46:00 +03:00
@rm -rf charts/workload-identity-webhook
2021-07-08 05:37:42 +03:00
@cp -r manifest_staging/charts .