Skip to content

Commit

Permalink
fix: remove requirement for vendored dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: David van der Spek <[email protected]>
  • Loading branch information
davidspek committed Dec 10, 2024
1 parent 615da49 commit a4feb37
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
21 changes: 16 additions & 5 deletions multidimensional-pod-autoscaler/hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../../code-generator)}
GO_CMD=${1:-go}
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
REPO_ROOT="$(git rev-parse --show-toplevel)"
CODEGEN_PKG=$($GO_CMD list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator)
cd "${CURRENT_DIR}/.."

# shellcheck source=/dev/null
source "${CODEGEN_PKG}/kube_codegen.sh"

kube::codegen::gen_helpers \
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
--boilerplate "${SCRIPT_ROOT}"/hack/boilerplate.go.txt
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt"

echo "Ran gen helpers, moving on to generating client code..."

kube::codegen::gen_client \
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
--output-pkg k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/client \
--output-dir "$(dirname ${BASH_SOURCE})/../pkg/client" \
--boilerplate "${SCRIPT_ROOT}"/hack/boilerplate.go.txt \
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
--with-watch

echo "Generated client code, running `go mod tidy`..."

# We need to clean up the go.mod file since code-generator adds temporary library to the go.mod file.
"${GO_CMD}" mod tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 The Kubernetes Authors. All rights reserved
# Copyright 2018 The Kubernetes Authors. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,22 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder

ENV GOPATH=/gopath/
ENV PATH=$GOPATH/bin:$PATH
WORKDIR /workspace

COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

RUN go mod download

COPY common common
COPY pkg pkg

ARG TARGETOS TARGETARCH

RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/admission-controller -mod vendor -o admission-controller-$TARGETARCH
RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/admission-controller -o admission-controller-$TARGETARCH

FROM gcr.io/distroless/static:latest

ARG TARGETARCH

COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/admission-controller/admission-controller-$TARGETARCH /admission-controller
COPY --from=builder /workspace/pkg/admission-controller/admission-controller-$TARGETARCH /admission-controller

ENTRYPOINT ["/admission-controller"]
19 changes: 12 additions & 7 deletions multidimensional-pod-autoscaler/pkg/recommender/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder

ENV GOPATH=/gopath/
ENV PATH=$GOPATH/bin:$PATH
WORKDIR /workspace

COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

RUN go mod download

COPY common common
COPY pkg pkg

ARG TARGETOS TARGETARCH

RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/recommender -mod vendor -o recommender-$TARGETARCH
RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/recommender -o recommender-$TARGETARCH

FROM gcr.io/distroless/static:latest

ARG TARGETARCH

COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/recommender/recommender-$TARGETARCH /recommender
COPY --from=builder /workspace/pkg/recommender/recommender-$TARGETARCH /recommender

ENTRYPOINT ["/recommender"]
19 changes: 12 additions & 7 deletions multidimensional-pod-autoscaler/pkg/updater/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder

ENV GOPATH=/gopath/
ENV PATH=$GOPATH/bin:$PATH
WORKDIR /workspace

COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

RUN go mod download

COPY common common
COPY pkg pkg

ARG TARGETOS TARGETARCH

RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/updater -mod vendor -o updater-$TARGETARCH
RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/updater -o updater-$TARGETARCH

FROM gcr.io/distroless/static:latest

ARG TARGETARCH

COPY --from=builder /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/updater/updater-$TARGETARCH /updater
COPY --from=builder /workspace/pkg/updater/updater-$TARGETARCH /updater

ENTRYPOINT ["/updater"]

0 comments on commit a4feb37

Please sign in to comment.