Merge "Fix for Templater latest image"

This commit is contained in:
Zuul 2021-04-29 15:22:52 +00:00 committed by Gerrit Code Review
commit c55258f6cb
16 changed files with 70 additions and 49 deletions
Makefile
krm-functions
cloud-init
kubeval-validator
replacement-transformer
templater
toolbox

@ -170,13 +170,10 @@ ifeq ($(PUBLISH), true)
@docker push $(DOCKER_IMAGE) @docker push $(DOCKER_IMAGE)
endif endif
# Use specific Dockerfile instead of general one to make image for kubeval-validator and toolbox
docker-image-toolbox: DOCKER_CMD_FLAGS+=-f krm-functions/toolbox/Dockerfile
docker-image-kubeval-validator: DOCKER_CMD_FLAGS+=-f krm-functions/kubeval-validator/image/Dockerfile
.PHONY: $(PLUGINS_IMAGE_TGT) .PHONY: $(PLUGINS_IMAGE_TGT)
$(PLUGINS_IMAGE_TGT): $(PLUGINS_IMAGE_TGT):
$(eval plugin_name=$(subst docker-image-,,$@)) $(eval plugin_name=$(subst docker-image-,,$@))
@docker build . $(DOCKER_CMD_FLAGS) \ @docker build $(PLUGINS_DIR)/$(plugin_name) $(DOCKER_CMD_FLAGS) \
--label $(LABEL) \ --label $(LABEL) \
--label "org.opencontainers.image.revision=$(COMMIT)" \ --label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \

@ -1,4 +1,6 @@
FROM gcr.io/gcp-runtimes/go1-builder:1.15 as builder ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15
ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0
FROM ${GO_IMAGE} as builder
# Inject custom root certificate authorities if needed # Inject custom root certificate authorities if needed
# Docker does not have a good conditional copy statement and requires that a source file exists # Docker does not have a good conditional copy statement and requires that a source file exists
@ -14,6 +16,6 @@ RUN /usr/local/go/bin/go mod download
COPY main.go . COPY main.go .
RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./ RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./
FROM alpine:latest FROM ${PLUGINS_RELEASE_IMAGE} as release
COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function
CMD ["/usr/local/bin/config-function"] CMD ["/usr/local/bin/config-function"]

@ -19,45 +19,44 @@ USE_PROXY ?= false
.PHONY: build .PHONY: build
build: build:
(cd image && go build -v -o $(GOBIN)/config-function .) (go build -v -o $(GOBIN)/config-function .)
.PHONY: all .PHONY: all
all: generate license build fix vet fmt test lint tidy all: generate license build fix vet fmt test lint tidy
.PHONY: fix .PHONY: fix
fix: fix:
(cd image && go fix ./...) (go fix .)
.PHONY: fmt .PHONY: fmt
fmt: fmt:
(cd image && go fmt ./...) (go fmt .)
.PHONY: generate .PHONY: generate
generate: generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo) (which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...) (GOBIN=$(GOBIN) go generate .)
.PHONY: tidy .PHONY: tidy
tidy: tidy:
(cd image && go mod tidy) (go mod tidy)
.PHONY: fix .PHONY: fix
lint: lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1) (which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...) ($(GOBIN)/golangci-lint run .)
.PHONY: test .PHONY: test
test: test:
(cd image && go test -cover ./...) (go test -cover .)
.PHONY: vet .PHONY: vet
vet: vet:
(cd image && go vet ./...) (go vet .)
.PHONY: image .PHONY: image
image: image:
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
cd image && \
docker build . --network=host \ docker build . --network=host \
--build-arg http_proxy=$(PROXY) \ --build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \
@ -68,7 +67,6 @@ ifeq ($(USE_PROXY), true)
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)
else else
cd image && \
docker build . --network=host \ docker build . --network=host \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)

@ -0,0 +1,6 @@
# Additional Docker image root certificate authorities
If you require additional certificate authorities for your Docker image:
* Add ASCII PEM encoded .crt files to this directory
* The files will be copied into your docker image at build time.
To update manually copy the .crt files to /usr/local/share/ca-certificates/ and run sudo update-ca-certificates.

@ -3,7 +3,7 @@ module opendev.org/airship/airshipctl/functions/cloud-init/image
go 1.14 go 1.14
require ( require (
opendev.org/airship/airshipctl v0.0.0-20210217205206-b8a4b6ad734c opendev.org/airship/airshipctl v0.0.0-20210421143147-014e24cd1591
sigs.k8s.io/kustomize/kyaml v0.10.0 sigs.k8s.io/kustomize/kyaml v0.10.0
sigs.k8s.io/kustomize/api v0.7.2 sigs.k8s.io/kustomize/api v0.7.2
) )

@ -4,10 +4,10 @@ FROM ${GO_IMAGE} as function
ENV PATH "/usr/local/go/bin:$PATH" ENV PATH "/usr/local/go/bin:$PATH"
ENV CGO_ENABLED=0 ENV CGO_ENABLED=0
WORKDIR /go/src/ WORKDIR /go/src/
COPY krm-functions/kubeval-validator/image/go.mod . COPY image/go.mod .
COPY krm-functions/kubeval-validator/image/go.sum . COPY image/go.sum .
RUN go mod download RUN go mod download
COPY krm-functions/kubeval-validator/image/main.go . COPY image/main.go .
RUN go build -v -o /usr/local/bin/config-function ./ RUN go build -v -o /usr/local/bin/config-function ./
FROM ${PLUGINS_RELEASE_IMAGE} as release FROM ${PLUGINS_RELEASE_IMAGE} as release
@ -24,5 +24,5 @@ RUN echo "**** install Python ****" && \
RUN pip3 install 'ruamel.yaml==0.16.13' 'openapi2jsonschema==0.9.0' openapi-spec-validator RUN pip3 install 'ruamel.yaml==0.16.13' 'openapi2jsonschema==0.9.0' openapi-spec-validator
COPY --from=function /usr/local/bin/config-function /usr/local/bin/config-function COPY --from=function /usr/local/bin/config-function /usr/local/bin/config-function
COPY krm-functions/kubeval-validator/image/extract-openapi.py /usr/local/bin/ COPY image/extract-openapi.py /usr/local/bin/
CMD ["config-function"] CMD ["config-function"]

@ -1,4 +1,6 @@
FROM gcr.io/gcp-runtimes/go1-builder:1.15 as builder ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15
ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0
FROM ${GO_IMAGE} as builder
# Inject custom root certificate authorities if needed # Inject custom root certificate authorities if needed
# Docker does not have a good conditional copy statement and requires that a source file exists # Docker does not have a good conditional copy statement and requires that a source file exists
@ -14,6 +16,6 @@ RUN /usr/local/go/bin/go mod download
COPY main.go . COPY main.go .
RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./ RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./
FROM alpine:latest FROM ${PLUGINS_RELEASE_IMAGE} as release
COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function
CMD ["/usr/local/bin/config-function"] CMD ["/usr/local/bin/config-function"]

@ -19,45 +19,44 @@ USE_PROXY ?= false
.PHONY: build .PHONY: build
build: build:
(cd image && go build -v -o $(GOBIN)/config-function .) (go build -v -o $(GOBIN)/config-function .)
.PHONY: all .PHONY: all
all: generate license build fix vet fmt test lint tidy all: generate license build fix vet fmt test lint tidy
.PHONY: fix .PHONY: fix
fix: fix:
(cd image && go fix ./...) (go fix .)
.PHONY: fmt .PHONY: fmt
fmt: fmt:
(cd image && go fmt ./...) (go fmt .)
.PHONY: generate .PHONY: generate
generate: generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo) (which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...) (GOBIN=$(GOBIN) go generate .)
.PHONY: tidy .PHONY: tidy
tidy: tidy:
(cd image && go mod tidy) (go mod tidy)
.PHONY: fix .PHONY: fix
lint: lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1) (which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...) ($(GOBIN)/golangci-lint run .)
.PHONY: test .PHONY: test
test: test:
(cd image && go test -cover ./...) (go test -cover .)
.PHONY: vet .PHONY: vet
vet: vet:
(cd image && go vet ./...) (go vet .)
.PHONY: image .PHONY: image
image: image:
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
cd image && \
docker build . --network=host \ docker build . --network=host \
--build-arg http_proxy=$(PROXY) \ --build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \
@ -68,7 +67,6 @@ ifeq ($(USE_PROXY), true)
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)
else else
cd image && \
docker build . --network=host \ docker build . --network=host \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)

@ -0,0 +1,6 @@
# Additional Docker image root certificate authorities
If you require additional certificate authorities for your Docker image:
* Add ASCII PEM encoded .crt files to this directory
* The files will be copied into your docker image at build time.
To update manually copy the .crt files to /usr/local/share/ca-certificates/ and run sudo update-ca-certificates.

@ -3,6 +3,6 @@ module opendev.org/airship/airshipctl/functions/replacement-transformer/image
go 1.14 go 1.14
require ( require (
opendev.org/airship/airshipctl v0.0.0-20201007215749-76e4d3f48c5a opendev.org/airship/airshipctl v0.0.0-20210421143147-014e24cd1591
sigs.k8s.io/kustomize/kyaml v0.7.1 sigs.k8s.io/kustomize/kyaml v0.7.1
) )

@ -1,4 +1,6 @@
FROM gcr.io/gcp-runtimes/go1-builder:1.15 as builder ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15
ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0
FROM ${GO_IMAGE} as builder
# Inject custom root certificate authorities if needed # Inject custom root certificate authorities if needed
# Docker does not have a good conditional copy statement and requires that a source file exists # Docker does not have a good conditional copy statement and requires that a source file exists
@ -14,6 +16,6 @@ RUN /usr/local/go/bin/go mod download
COPY main.go . COPY main.go .
RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./ RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./
FROM alpine:latest FROM ${PLUGINS_RELEASE_IMAGE} as release
COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function
CMD ["/usr/local/bin/config-function"] CMD ["/usr/local/bin/config-function"]

@ -19,45 +19,44 @@ USE_PROXY ?= false
.PHONY: build .PHONY: build
build: build:
(cd image && go build -v -o $(GOBIN)/config-function .) (go build -v -o $(GOBIN)/config-function .)
.PHONY: all .PHONY: all
all: generate license build fix vet fmt test lint tidy all: generate license build fix vet fmt test lint tidy
.PHONY: fix .PHONY: fix
fix: fix:
(cd image && go fix ./...) (go fix .)
.PHONY: fmt .PHONY: fmt
fmt: fmt:
(cd image && go fmt ./...) (go fmt .)
.PHONY: generate .PHONY: generate
generate: generate:
(which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo) (which $(GOBIN)/mdtogo || go get sigs.k8s.io/kustomize/cmd/mdtogo)
(cd image && GOBIN=$(GOBIN) go generate ./...) (GOBIN=$(GOBIN) go generate .)
.PHONY: tidy .PHONY: tidy
tidy: tidy:
(cd image && go mod tidy) (go mod tidy)
.PHONY: fix .PHONY: fix
lint: lint:
(which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1) (which $(GOBIN)/golangci-lint || go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.19.1)
(cd image && $(GOBIN)/golangci-lint run ./...) ($(GOBIN)/golangci-lint run .)
.PHONY: test .PHONY: test
test: test:
(cd image && go test -cover ./...) (go test -cover .)
.PHONY: vet .PHONY: vet
vet: vet:
(cd image && go vet ./...) (go vet .)
.PHONY: image .PHONY: image
image: image:
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
cd image && \
docker build . --network=host \ docker build . --network=host \
--build-arg http_proxy=$(PROXY) \ --build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \
@ -68,7 +67,6 @@ ifeq ($(USE_PROXY), true)
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)
else else
cd image && \
docker build . --network=host \ docker build . --network=host \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)

@ -0,0 +1,6 @@
# Additional Docker image root certificate authorities
If you require additional certificate authorities for your Docker image:
* Add ASCII PEM encoded .crt files to this directory
* The files will be copied into your docker image at build time.
To update manually copy the .crt files to /usr/local/share/ca-certificates/ and run sudo update-ca-certificates.

@ -3,6 +3,6 @@ module opendev.org/airship/airshipctl/functions/templater/image
go 1.14 go 1.14
require ( require (
opendev.org/airship/airshipctl v0.0.0-20201007215749-76e4d3f48c5a opendev.org/airship/airshipctl v0.0.0-20210421143147-014e24cd1591
sigs.k8s.io/kustomize/kyaml v0.7.1 sigs.k8s.io/kustomize/kyaml v0.7.1
) )

@ -20,9 +20,9 @@ RUN chmod +x /kubectl /calicoctl
FROM ${GO_IMAGE} as builder FROM ${GO_IMAGE} as builder
ENV CGO_ENABLED=0 ENV CGO_ENABLED=0
WORKDIR /go/src/ WORKDIR /go/src/
COPY krm-functions/toolbox/image/go.mod . COPY image/go.mod .
RUN /usr/local/go/bin/go mod download RUN /usr/local/go/bin/go mod download
COPY krm-functions/toolbox/main.go . COPY main.go .
RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./ RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./
FROM ${PLUGINS_RELEASE_IMAGE} as release FROM ${PLUGINS_RELEASE_IMAGE} as release

@ -0,0 +1,6 @@
# Additional Docker image root certificate authorities
If you require additional certificate authorities for your Docker image:
* Add ASCII PEM encoded .crt files to this directory
* The files will be copied into your docker image at build time.
To update manually copy the .crt files to /usr/local/share/ca-certificates/ and run sudo update-ca-certificates.