Skip to content

Commit a4feb37

Browse files
committed
fix: remove requirement for vendored dependencies
Signed-off-by: David van der Spek <[email protected]>
1 parent 615da49 commit a4feb37

File tree

4 files changed

+53
-27
lines changed

4 files changed

+53
-27
lines changed

multidimensional-pod-autoscaler/hack/update-codegen.sh

+16-5
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,29 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

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

27+
# shellcheck source=/dev/null
2428
source "${CODEGEN_PKG}/kube_codegen.sh"
2529

2630
kube::codegen::gen_helpers \
27-
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
28-
--boilerplate "${SCRIPT_ROOT}"/hack/boilerplate.go.txt
31+
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
32+
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt"
33+
34+
echo "Ran gen helpers, moving on to generating client code..."
2935

3036
kube::codegen::gen_client \
3137
"$(dirname ${BASH_SOURCE})/../pkg/apis" \
3238
--output-pkg k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/client \
3339
--output-dir "$(dirname ${BASH_SOURCE})/../pkg/client" \
34-
--boilerplate "${SCRIPT_ROOT}"/hack/boilerplate.go.txt \
40+
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
3541
--with-watch
42+
43+
echo "Generated client code, running `go mod tidy`..."
44+
45+
# We need to clean up the go.mod file since code-generator adds temporary library to the go.mod file.
46+
"${GO_CMD}" mod tidy
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The Kubernetes Authors. All rights reserved
1+
# Copyright 2018 The Kubernetes Authors. All rights reserved
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,22 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

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

17-
ENV GOPATH=/gopath/
18-
ENV PATH=$GOPATH/bin:$PATH
17+
WORKDIR /workspace
1918

20-
COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
21-
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
19+
# Copy the Go Modules manifests
20+
COPY go.mod go.mod
21+
COPY go.sum go.sum
22+
23+
RUN go mod download
24+
25+
COPY common common
26+
COPY pkg pkg
2227

2328
ARG TARGETOS TARGETARCH
2429

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

2732
FROM gcr.io/distroless/static:latest
2833

2934
ARG TARGETARCH
3035

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

3338
ENTRYPOINT ["/admission-controller"]

multidimensional-pod-autoscaler/pkg/recommender/Dockerfile

+12-7
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

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

17-
ENV GOPATH=/gopath/
18-
ENV PATH=$GOPATH/bin:$PATH
17+
WORKDIR /workspace
1918

20-
COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
21-
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
19+
# Copy the Go Modules manifests
20+
COPY go.mod go.mod
21+
COPY go.sum go.sum
22+
23+
RUN go mod download
24+
25+
COPY common common
26+
COPY pkg pkg
2227

2328
ARG TARGETOS TARGETARCH
2429

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

2732
FROM gcr.io/distroless/static:latest
2833

2934
ARG TARGETARCH
3035

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

3338
ENTRYPOINT ["/recommender"]

multidimensional-pod-autoscaler/pkg/updater/Dockerfile

+12-7
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,27 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

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

17-
ENV GOPATH=/gopath/
18-
ENV PATH=$GOPATH/bin:$PATH
17+
WORKDIR /workspace
1918

20-
COPY . /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
21-
WORKDIR /gopath/src/k8s.io/autoscaler/multidimensional-pod-autoscaler
19+
# Copy the Go Modules manifests
20+
COPY go.mod go.mod
21+
COPY go.sum go.sum
22+
23+
RUN go mod download
24+
25+
COPY common common
26+
COPY pkg pkg
2227

2328
ARG TARGETOS TARGETARCH
2429

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

2732
FROM gcr.io/distroless/static:latest
2833

2934
ARG TARGETARCH
3035

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

3338
ENTRYPOINT ["/updater"]

0 commit comments

Comments
 (0)