From 0888e4498fd3d2e554a4cad3866087d09a5a6854 Mon Sep 17 00:00:00 2001 From: Eriks Zelenka Date: Thu, 11 Jan 2024 19:36:51 +0200 Subject: [PATCH] Fix typo --- .github/workflows/ci.yaml | 98 +++++++++++++++++++++++++++++++++++++++ Makefile | 9 ++-- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1ad0dfc7..457ef220 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -82,3 +82,101 @@ jobs: - name: Unit tests and envtest integration tests run: make test + + # k3d integration tests + - name: In cluster integration tests + run: | + export GNUPGHOME="$(mktemp -d)" + cat >$GNUPGHOME/foo < config/samples/isindir_v1alpha3_sopssecret.enc.yaml + file config/samples/isindir_v1alpha3_sopssecret.enc.yaml + echo "=====================================" + cat config/samples/isindir_v1alpha3_sopssecret.enc.yaml + echo "=====================================" + kubectl apply -f config/samples/isindir_v1alpha3_sopssecret.enc.yaml --namespace sops + sleep 3 + nohup make run & + sleep 150 + kubectl get sops --namespace sops + echo + kubectl get secrets --namespace sops + echo + export SECRETS_NUMBER=$( kubectl get secrets --namespace sops --no-headers \ + | awk '$0 !~ /default-token/ { print $1; }' \ + | wc -l ) + if [[ $SECRETS_NUMBER -ne 5 ]]; then + echo "Expected number of secrets in sops namespace is 5 - Failed" + tail -40 nohup.out + exit 1 + fi + # Check specific k8s for amount of data entries + ## my-secret-name-0 + export DATA_ENTRIES=$( kubectl get secrets my-secret-name-0 --namespace sops --no-headers \ + | awk '{print $3}' ) + if [[ $DATA_ENTRIES -ne 2 ]]; then + echo "Expected number of data entries in my-secret-name-0 is 2 - Failed" + tail -40 nohup.out + exit 1 + fi + ## my-secret-name-1 + export DATA_ENTRIES=$( kubectl get secrets my-secret-name-1 --namespace sops --no-headers \ + | awk '{print $3}' ) + if [[ $DATA_ENTRIES -ne 3 ]]; then + echo "Expected number of data entries in my-secret-name-1 is 3 - Failed" + tail -40 nohup.out + exit 1 + fi + ## my-secret-name-2 + export DATA_ENTRIES=$( kubectl get secrets my-secret-name-2 --namespace sops --no-headers \ + | awk '{print $3}' ) + if [[ $DATA_ENTRIES -ne 2 ]]; then + echo "Expected number of data entries in my-secret-name-2 is 2 - Failed" + tail -40 nohup.out + exit 1 + fi + # Delete to check GC works + kubectl delete -f config/samples/isindir_v1alpha3_sopssecret.enc.yaml --namespace sops + sleep 15 + kubectl get sops --namespace sops + echo + kubectl get secrets --namespace sops + echo + export SECRETS_NUMBER=$( kubectl get secrets --namespace sops \ + | awk '$0!~/default-token/ && $0!~/NAME/ { print $1; }' \ + | wc -l ) + if [[ $SECRETS_NUMBER -ne 0 ]]; then + echo "Expected number of secrets in sops namespace is 0 - Failed" + exit 1 + fi + rm -fr $GNUPGHOME + + - name: Docker build + run: | + make docker-login + make docker-cross-build diff --git a/Makefile b/Makefile index 055c684d..8dd6d9aa 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CONTROLLER_GEN_VERSION := "v0.14.0" # https://github.com/kubernetes-sigs/controller-runtime/releases CONTROLLER_RUNTIME_VERSION := "v0.16.3" # https://github.com/kubernetes-sigs/kustomize/releases -KUSTOMIZE_VERSION := "v5.2.1" +KUSTOMIZE_VERSION := "v5.3.0" # use `setup-envtest list` to obtain the list of available versions # until fixed, can't use newer version, see: # https://github.com/kubernetes-sigs/controller-runtime/issues/1571 @@ -240,8 +240,8 @@ setup-ginkgo: ## Download ginkgo locally # go-install-tool will 'go install' any package $2 and install it to $1 PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) define go-install-tool -[ -f $(1) ] || { \ -set -ex ;\ +@[ -f $(1) ] || { \ +set -e ;\ TMP_DIR=$$(mktemp -d) ;\ cp -p .tool-versions $$TMP_DIR ;\ cd $$TMP_DIR ;\ @@ -259,8 +259,9 @@ define go-get-tool @[ -f $(1) ] || { \ set -e ;\ TMP_DIR=$$(mktemp -d) ;\ +cp -p .tool-versions $$TMP_DIR ;\ cd $$TMP_DIR ;\ -go mod init tmp ;\ +$(GO) mod init tmp ;\ echo "Downloading $(2)" ;\ GOBIN=$(PROJECT_DIR)/bin $(GO) get $(2) ;\ rm -rf $$TMP_DIR ;\