diff --git a/AlpineTest.Dockerfile b/AlpineTest.Dockerfile index 647584ad3..a326a6cb4 100644 --- a/AlpineTest.Dockerfile +++ b/AlpineTest.Dockerfile @@ -1,24 +1,25 @@ FROM --platform=$BUILDPLATFORM alpine:3 # variable "HELM_VERSION" and "PLUGIN_VERSION" must be passed as docker environment variables during the image build -# docker build --load --no-cache --platform linux/amd64 --build-arg HELM_VERSION=3.13.0 -t alpine/helm-unittest:test -f AlpineTest.Dockerfile . +# docker buildx build --load --no-cache --platform linux/amd64 --build-arg HELM_VERSION=3.13.0 -t alpine/helm-unittest:test -f AlpineTest.Dockerfile . -COPY plugin.yaml /helm-unittest/plugin.yaml -COPY install-binary.sh /helm-unittest/install-binary.sh +ADD plugin.yaml helm-unittest/plugin.yaml +ADD install-binary.sh helm-unittest/install-binary.sh +ADD untt helm-unittest/untt ARG BUILDPLATFORM ARG TARGETOS ARG TARGETARCH ARG HELM_VERSION -#ENV SKIP_BIN_DOWNLOAD=1 +ENV SKIP_BIN_INSTALL=1 ENV HELM_BASE_URL="https://get.helm.sh" ENV HELM_TAR_FILE="helm-v${HELM_VERSION}-${TARGETOS}-${TARGETARCH}.tar.gz" ENV PLUGIN_URL="helm-unittest" # Install the plugin for all users ENV HELM_DATA_HOME=/usr/local/share/helm -RUN apk add --update --no-cache curl ca-certificates git && \ +RUN apk add --update --no-cache curl ca-certificates git libc6-compat && \ curl -L ${HELM_BASE_URL}/${HELM_TAR_FILE} |tar xvz && \ mv ${TARGETOS}-${TARGETARCH}/helm /usr/bin/helm && \ chmod +x /usr/bin/helm && \ @@ -27,13 +28,14 @@ RUN apk add --update --no-cache curl ca-certificates git && \ apk del curl git && \ rm -f /var/cache/apk/* ; -RUN addgroup -S helmgroup && \ - adduser -S helmuser -G helmgroup +RUN addgroup -g 1000 -S helmgroup && \ + adduser -u 1000 -S helmuser -G helmgroup USER helmuser WORKDIR /apps -VOLUME [ "/apps" ] + +VOLUME ["/apps"] ENTRYPOINT ["helm", "unittest"] CMD ["--help"] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e0b38c97e..35e353e5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,8 +23,8 @@ RUN apk add --update --no-cache curl ca-certificates git bash && \ apk del curl git bash && \ rm -f /var/cache/apk/* -RUN addgroup -S helmgroup && \ - adduser -S helmuser -G helmgroup +RUN addgroup -g 1000 -S helmgroup && \ + adduser -u 1000 -S helmuser -G helmgroup USER helmuser diff --git a/Fedora.Dockerfile b/Fedora.Dockerfile index 36c649ac6..b24da2b04 100644 --- a/Fedora.Dockerfile +++ b/Fedora.Dockerfile @@ -1,20 +1,21 @@ FROM --platform=$BUILDPLATFORM fedora:40 # variable "HELM_VERSION" must be passed as docker environment variables during the image build -# docker build --no-cache --platform linux/amd64 --build-arg HELM_VERSION=3.13.0 -t fedora/helm-unittest:test -f Fedora.Dockerfile . +# docker buildx build --load --no-cache --platform linux/amd64 --build-arg HELM_VERSION=3.13.0 -t fedora/helm-unittest:test -f Fedora.Dockerfile . -ADD ./plugin.yaml ~/plugin.yaml -ADD ./plugin-dbg.yaml ~/plugin-dbg.yaml -ADD ./install-binary.sh ~/install-binary.sh +ADD plugin.yaml helm-unittest/plugin.yaml +ADD install-binary.sh helm-unittest/install-binary.sh +ADD untt helm-unittest/untt ARG BUILDPLATFORM ARG TARGETOS ARG TARGETARCH ARG HELM_VERSION +ENV SKIP_BIN_INSTALL=1 ENV HELM_BASE_URL="https://get.helm.sh" ENV HELM_TAR_FILE="helm-v${HELM_VERSION}-${TARGETOS}-${TARGETARCH}.tar.gz" -ENV PLUGIN_URL="~" +ENV PLUGIN_URL="helm-unittest" # Install the plugin for all users ENV HELM_DATA_HOME=/usr/local/share/helm @@ -27,8 +28,8 @@ RUN yum install -y git && \ yum remove -y git && \ rm -rf /var/cache/yum/* ; -RUN groupadd -r helmgroup \ - && useradd -r helmuser -g helmgroup +RUN groupadd -g 1000 -r helmgroup \ + && useradd -u 1000 -r helmuser -g helmgroup USER helmuser diff --git a/Makefile b/Makefile index 0c27e9969..3b758c574 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ # borrowed from https://github.com/technosophos/helm-template -GO ?= go HELM_3_PLUGINS := $(shell bash -c 'eval $$(helm env); echo $$HELM_PLUGINS') HELM_PLUGIN_DIR := $(HELM_3_PLUGINS)/helm-unittest HELM_VERSION := 3.14.0 @@ -14,7 +13,6 @@ TEST_NAMES ?=basic \ failing-template \ full-snapshot \ global-double-setting \ - invalidbasic \ nested_glob \ with-document-select \ with-files \ @@ -83,18 +81,18 @@ dockerdist: .PHONY: go-dependency dependency: ## Dependency maintanance - @$(GO) get -u ./... - @$(GO) mod tidy + go get -u ./... + go mod tidy .PHONY: dockerimage dockerimage: ## Build docker image - docker buildx build --no-cache --load --platform linux/amd64 --build-arg HELM_VERSION=$(HELM_VERSION) -t $(DOCKER):$(VERSION) -f AlpineTest.Dockerfile . + docker buildx build --load --no-cache --platform linux/amd64 --build-arg HELM_VERSION=$(HELM_VERSION) -t $(DOCKER):$(VERSION) -f Fedora.Dockerfile . .PHONY: test-docker test-docker: dockerimage ## Execute 'helm unittests' in container @for f in $(TEST_NAMES); do \ echo "running helm unit tests in folder '$${f}'"; \ docker run \ - -v $(PROJECT_DIR)/test/data/v3/$${f}:/apps/:Z \ + -v $(PROJECT_DIR)/test/data/v3/$${f}:/apps \ -it --rm $(DOCKER):$(VERSION) -f tests/*.yaml .;\ done diff --git a/pkg/unittest/snapshot/factory.go b/pkg/unittest/snapshot/factory.go index 47af4cf04..b22773a5e 100644 --- a/pkg/unittest/snapshot/factory.go +++ b/pkg/unittest/snapshot/factory.go @@ -31,7 +31,7 @@ func ensureDir(path string) error { info, err := os.Stat(path) if err != nil { if os.IsNotExist(err) { - return os.Mkdir(path, os.ModePerm) + return os.Mkdir(path, 0755) } return err }