From a55d28560eed3d196e21ea8cb2fd4d8c7ae9f41d Mon Sep 17 00:00:00 2001 From: Nestor Acuna Blanco Date: Thu, 17 Oct 2024 15:24:43 +0200 Subject: [PATCH] refactor: suggestions from sonarcloud quality gate Signed-off-by: Nestor Acuna Blanco --- Dockerfile | 11 +++++++---- validator.Dockerfile | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 43c3ff176..5b2d6278f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,11 @@ ARG TARGET_ARCH RUN microdnf install -y make tar gzip which && microdnf clean all -RUN export ARCH=$(uname -m | sed 's/x86_64/amd64/'); curl -L https://go.dev/dl/go1.22.4.linux-${ARCH}.tar.gz | tar -C /usr/local -xzf - +RUN ARCH=$(uname -m | sed 's/x86_64/amd64/') && \ + curl -L https://go.dev/dl/go1.22.4.linux-${ARCH}.tar.gz -o go.tar.gz && \ + tar -C /usr/local -xzf go.tar.gz && \ + rm go.tar.gz + ENV PATH=$PATH:/usr/local/go/bin # Consume required variables so we can work with make @@ -38,9 +42,8 @@ COPY hack/csv-generator.go hack/csv-generator.go # Copy .golangci.yaml so we can run lint as part of the build process COPY .golangci.yaml .golangci.yaml -# Build the manager binary -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGET_ARCH} GO111MODULE=on make manager -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGET_ARCH} GO111MODULE=on make csv-generator +# Build the manager and csv-generator binaries +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGET_ARCH} GO111MODULE=on make manager csv-generator FROM --platform=linux/${TARGET_ARCH} registry.access.redhat.com/ubi9/ubi-micro diff --git a/validator.Dockerfile b/validator.Dockerfile index c1376e2f3..8521293d2 100644 --- a/validator.Dockerfile +++ b/validator.Dockerfile @@ -33,10 +33,12 @@ COPY internal/ internal/ COPY pkg/ pkg/ # Compile for the TARGET_ARCH -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGET_ARCH} GO111MODULE=on go build -a -ldflags="-X 'kubevirt.io/ssp-operator/internal/template-validator/version.COMPONENT=$COMPONENT'\ +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGET_ARCH} GO111MODULE=on go build \ +-a -ldflags="-X 'kubevirt.io/ssp-operator/internal/template-validator/version.COMPONENT=$COMPONENT'\ -X 'kubevirt.io/ssp-operator/internal/template-validator/version.VERSION=$VERSION'\ -X 'kubevirt.io/ssp-operator/internal/template-validator/version.BRANCH=$BRANCH'\ --X 'kubevirt.io/ssp-operator/internal/template-validator/version.REVISION=$REVISION'" -o kubevirt-template-validator internal/template-validator/main.go +-X 'kubevirt.io/ssp-operator/internal/template-validator/version.REVISION=$REVISION'" \ +-o kubevirt-template-validator internal/template-validator/main.go # Hack: Create an empty directory in the builder image and copy it to the target image to avoid triggering any architecture-specific commands RUN mkdir emptydir