generated from siderolabs/project-template-kubernetes-controller
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: bump deps, implement unit tests
Implement unit-tests for the controller. Bump dependencies. Signed-off-by: Artem Chernyshev <[email protected]>
- Loading branch information
Showing
12 changed files
with
1,183 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,10 @@ ENV GO111MODULE on | |
ENV GOPROXY https://proxy.golang.org | ||
ENV GOCACHE /.cache/go-build | ||
ENV GOMODCACHE /.cache/mod | ||
RUN --mount=type=cache,target=/.cache go install sigs.k8s.io/controller-tools/cmd/[email protected] | ||
RUN --mount=type=cache,target=/.cache go install k8s.io/code-generator/cmd/[email protected] | ||
ARG CONTROLLER_GEN_VERSION | ||
ARG CONVERSION_GEN_VERSION | ||
RUN --mount=type=cache,target=/.cache go install sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_GEN_VERSION} | ||
RUN --mount=type=cache,target=/.cache go install k8s.io/code-generator/cmd/conversion-gen@${CONVERSION_GEN_VERSION} | ||
WORKDIR /src | ||
COPY ./go.mod ./ | ||
COPY ./go.sum ./ | ||
|
@@ -47,6 +49,14 @@ RUN --mount=type=cache,target=/.cache controller-gen object:headerFile=./hack/bo | |
FROM scratch AS generate | ||
COPY --from=generate-build /src/api /api | ||
|
||
# runs unit-tests | ||
FROM build AS unit-tests-run | ||
ARG TESTPKGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS} | ||
|
||
FROM scratch AS unit-tests | ||
COPY --from=unit-tests-run /src/coverage.txt /coverage.txt | ||
|
||
FROM --platform=${BUILDPLATFORM} alpine:3.13 AS release-build | ||
ADD https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv4.1.0/kustomize_v4.1.0_linux_amd64.tar.gz . | ||
RUN tar -xf kustomize_v4.1.0_linux_amd64.tar.gz -C /usr/local/bin && rm kustomize_v4.1.0_linux_amd64.tar.gz | ||
|
@@ -82,4 +92,4 @@ COPY --from=pkg-ca-certificates / / | |
COPY --from=pkg-fhs / / | ||
COPY --from=binary /manager /manager | ||
LABEL org.opencontainers.image.source https://github.com/siderolabs/cluster-api-control-plane-provider-talos | ||
ENTRYPOINT [ "/manager" ] | ||
ENTRYPOINT [ "/manager" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.