File tree 4 files changed +53
-27
lines changed
multidimensional-pod-autoscaler
4 files changed +53
-27
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,29 @@ set -o errexit
18
18
set -o nounset
19
19
set -o pipefail
20
20
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} /.."
23
26
27
+ # shellcheck source=/dev/null
24
28
source " ${CODEGEN_PKG} /kube_codegen.sh"
25
29
26
30
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..."
29
35
30
36
kube::codegen::gen_client \
31
37
" $( dirname ${BASH_SOURCE} ) /../pkg/apis" \
32
38
--output-pkg k8s.io/autoscaler/multidimensional-pod-autoscaler/pkg/client \
33
39
--output-dir " $( dirname ${BASH_SOURCE} ) /../pkg/client" \
34
- --boilerplate " ${SCRIPT_ROOT} " /hack/boilerplate.go .txt \
40
+ --boilerplate " ${REPO_ROOT} /hack/boilerplate/boilerplate.generatego .txt" \
35
41
--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 number Diff line number Diff line change 1
- # Copyright 2024 The Kubernetes Authors. All rights reserved
1
+ # Copyright 2018 The Kubernetes Authors. All rights reserved
2
2
#
3
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
4
# you may not use this file except in compliance with the License.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder
15
+ FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder
16
16
17
- ENV GOPATH=/gopath/
18
- ENV PATH=$GOPATH/bin:$PATH
17
+ WORKDIR /workspace
19
18
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
22
27
23
28
ARG TARGETOS TARGETARCH
24
29
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
26
31
27
32
FROM gcr.io/distroless/static:latest
28
33
29
34
ARG TARGETARCH
30
35
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
32
37
33
38
ENTRYPOINT ["/admission-controller" ]
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder
15
+ FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder
16
16
17
- ENV GOPATH=/gopath/
18
- ENV PATH=$GOPATH/bin:$PATH
17
+ WORKDIR /workspace
19
18
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
22
27
23
28
ARG TARGETOS TARGETARCH
24
29
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
26
31
27
32
FROM gcr.io/distroless/static:latest
28
33
29
34
ARG TARGETARCH
30
35
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
32
37
33
38
ENTRYPOINT ["/recommender" ]
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- FROM --platform=$BUILDPLATFORM golang:1.23.3 AS builder
15
+ FROM --platform=$BUILDPLATFORM golang:1.23.4 AS builder
16
16
17
- ENV GOPATH=/gopath/
18
- ENV PATH=$GOPATH/bin:$PATH
17
+ WORKDIR /workspace
19
18
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
22
27
23
28
ARG TARGETOS TARGETARCH
24
29
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
26
31
27
32
FROM gcr.io/distroless/static:latest
28
33
29
34
ARG TARGETARCH
30
35
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
32
37
33
38
ENTRYPOINT ["/updater" ]
You can’t perform that action at this time.
0 commit comments