Skip to content

Commit cbdb405

Browse files
authored
re-introduce vendor to satisfy reproducible builds requirement (kedacore#3518)
Signed-off-by: Zbynek Roubalik <[email protected]>
1 parent 3b5e962 commit cbdb405

File tree

11,016 files changed

+3529982
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

11,016 files changed

+3529982
-515
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ apiserver.local.config/
3737
# VSCode specific files
3838
.vscode
3939

40-
# GO Vendor
41-
vendor
4240
cover.out
4341

4442
# GO debug binary

.golangci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ run:
77
- e2e
88
# timeout for analysis, e.g. 30s, 5m, default is 1m
99
timeout: 10m
10+
# skip vendor directory
11+
skip-dirs:
12+
- vendor
13+
modules-download-mode: vendor
1014
linters:
1115
# please, do not use `enable-all`: it's deprecated and will be removed soon.
1216
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
default_stages: [commit, push]
22
minimum_pre_commit_version: "1.20.0"
3+
exclude: (^vendor/|^pkg/generated/)
34
repos:
45
- repo: https://github.com/dnephin/pre-commit-golang
56
rev: v0.3.5

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
5353
- **General:** Add explicit seccompProfile type to securityContext config ([#3561](https://github.com/kedacore/keda/issues/3561))
5454
- **General:** Add `Min` column to ScaledJob visualization ([#3689](https://github.com/kedacore/keda/issues/3689))
5555
- **General:** Add support to use pod identities for authentication in Azure Key Vault ([#3813](https://github.com/kedacore/keda/issues/3813)
56+
- **General:** Reproducible builds ([#3509](https://github.com/kedacore/keda/issues/3509)
5657
- **Apache Kafka Scaler:** SASL/OAuthbearer Implementation ([#3681](https://github.com/kedacore/keda/issues/3681))
5758
- **Azure AD Pod Identity Authentication:** Improve error messages to emphasize problems around the integration with aad-pod-identity itself ([#3610](https://github.com/kedacore/keda/issues/3610))
5859
- **Azure Pipelines Scaler:** Improved speed of profiling large set of Job Requests from Azure Pipelines ([#3702](https://github.com/kedacore/keda/issues/3702))

Dockerfile

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ ARG GIT_VERSION=main
77

88
WORKDIR /workspace
99

10-
# Copy the Go Modules manifests
11-
COPY go.mod go.mod
12-
COPY go.sum go.sum
13-
# cache deps before building and copying source so that we don't need to re-download as much
14-
# and so that source changes don't invalidate our downloaded layer
15-
RUN go mod download
16-
1710
COPY Makefile Makefile
1811

1912
# Copy the go source
@@ -24,6 +17,9 @@ COPY adapter/ adapter/
2417
COPY apis/ apis/
2518
COPY controllers/ controllers/
2619
COPY pkg/ pkg/
20+
COPY vendor/ vendor/
21+
COPY go.mod go.mod
22+
COPY go.sum go.sum
2723

2824
# Build
2925
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/

Dockerfile.adapter

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ ARG GIT_VERSION=main
77

88
WORKDIR /workspace
99

10-
# Copy the Go Modules manifests
11-
COPY go.mod go.mod
12-
COPY go.sum go.sum
13-
# cache deps before building and copying source so that we don't need to re-download as much
14-
# and so that source changes don't invalidate our downloaded layer
15-
RUN go mod download
16-
1710
COPY Makefile Makefile
1811

1912
# Copy the go source
@@ -24,6 +17,9 @@ COPY adapter/ adapter/
2417
COPY apis/ apis/
2518
COPY controllers/ controllers/
2619
COPY pkg/ pkg/
20+
COPY vendor/ vendor/
21+
COPY go.mod go.mod
22+
COPY go.sum go.sum
2723

2824
RUN mkdir -p /apiserver.local.config/certificates && chmod -R 777 /apiserver.local.config
2925

Makefile

+38-42
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ GO_LDFLAGS="-X=github.com/kedacore/keda/v2/version.GitCommit=$(GIT_COMMIT) -X=gi
5050
COSIGN_FLAGS ?= -a GIT_HASH=${GIT_COMMIT} -a GIT_VERSION=${VERSION} -a BUILD_DATE=${DATE}
5151

5252
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
53-
ENVTEST_K8S_VERSION = 1.23
53+
ENVTEST_K8S_VERSION = 1.24
5454

5555
# Setting SHELL to bash allows bash commands to be executed by recipes.
5656
# This is a requirement for 'setup-envtest.sh' in the test target.
@@ -124,8 +124,7 @@ generate: controller-gen mockgen-gen ## Generate code containing DeepCopy, DeepC
124124
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
125125

126126
adapter/generated/openapi/zz_generated.openapi.go: go.mod go.sum ## Generate OpenAPI for KEDA Metrics Adapter.
127-
@OPENAPI_PATH=`go list -mod=readonly -m -f '{{.Dir}}' k8s.io/kube-openapi`; \
128-
go run $${OPENAPI_PATH}/cmd/openapi-gen/openapi-gen.go --logtostderr \
127+
go run vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go --logtostderr \
129128
-i k8s.io/metrics/pkg/apis/custom_metrics,k8s.io/metrics/pkg/apis/custom_metrics/v1beta1,k8s.io/metrics/pkg/apis/custom_metrics/v1beta2,k8s.io/metrics/pkg/apis/external_metrics,k8s.io/metrics/pkg/apis/external_metrics/v1beta1,k8s.io/metrics/pkg/apis/metrics,k8s.io/metrics/pkg/apis/metrics/v1beta1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/version,k8s.io/api/core/v1 \
130129
--build-tag autogenerated \
131130
-h ./hack/boilerplate.go.txt \
@@ -144,14 +143,10 @@ golangci: ## Run golangci against code.
144143
golangci-lint run
145144

146145
clientset-verify: ## Verify that generated client-go clientset, listers and informers are up to date.
147-
go mod vendor
148146
./hack/verify-codegen.sh
149-
rm -rf vendor
150147

151148
clientset-generate: ## Generate client-go clientset, listers and informers.
152-
go mod vendor
153149
./hack/update-codegen.sh
154-
rm -rf vendor
155150

156151
# Generate Liiklus proto
157152
pkg/scalers/liiklus/LiiklusService.pb.go: protoc-gen-go
@@ -172,10 +167,10 @@ pkg/mock/mock_scaling/mock_interface.go: pkg/scaling/scale_handler.go
172167
$(MOCKGEN) -destination=$@ -package=mock_scaling -source=$^
173168
pkg/mock/mock_scaler/mock_scaler.go: pkg/scalers/scaler.go
174169
$(MOCKGEN) -destination=$@ -package=mock_scalers -source=$^
175-
pkg/mock/mock_scale/mock_interfaces.go: $(shell go list -mod=readonly -f '{{ .Dir }}' -m k8s.io/client-go)/scale/interfaces.go
176-
$(MOCKGEN) -destination=$@ -package=mock_scale -source=$^
177-
pkg/mock/mock_client/mock_interfaces.go: $(shell go list -mod=readonly -f '{{ .Dir }}' -m sigs.k8s.io/controller-runtime)/pkg/client/interfaces.go
178-
$(MOCKGEN) -destination=$@ -package=mock_client -source=$^
170+
pkg/mock/mock_scale/mock_interfaces.go: vendor/k8s.io/client-go/scale/interfaces.go
171+
$(MOCKGEN) k8s.io/client-go/scale ScalesGetter,ScaleInterface > $@
172+
pkg/mock/mock_client/mock_interfaces.go: vendor/sigs.k8s.io/controller-runtime/pkg/client/interfaces.go
173+
$(MOCKGEN) sigs.k8s.io/controller-runtime/pkg/client Patch,Reader,Writer,StatusClient,StatusWriter,Client,WithWatch,FieldIndexer > $@
179174
pkg/scalers/liiklus/mocks/mock_liiklus.go:
180175
$(MOCKGEN) -destination=$@ github.com/kedacore/keda/v2/pkg/scalers/liiklus LiiklusServiceClient
181176

@@ -188,10 +183,10 @@ pkg/scalers/liiklus/mocks/mock_liiklus.go:
188183
build: generate fmt vet manager adapter ## Build Operator (manager) and Metrics Server (adapter) binaries.
189184

190185
manager: generate
191-
${GO_BUILD_VARS} go build -ldflags $(GO_LDFLAGS) -o bin/keda main.go
186+
${GO_BUILD_VARS} go build -ldflags $(GO_LDFLAGS) -mod=vendor -o bin/keda main.go
192187

193188
adapter: generate adapter/generated/openapi/zz_generated.openapi.go
194-
${GO_BUILD_VARS} go build -ldflags $(GO_LDFLAGS) -o bin/keda-adapter adapter/main.go
189+
${GO_BUILD_VARS} go build -ldflags $(GO_LDFLAGS) -mod=vendor -o bin/keda-adapter adapter/main.go
195190

196191
run: manifests generate ## Run a controller from your host.
197192
WATCH_NAMESPACE="" go run -ldflags $(GO_LDFLAGS) ./main.go $(ARGS)
@@ -267,36 +262,37 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
267262
undeploy: e2e-test-clean-crds ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
268263
$(KUSTOMIZE) build config/default | kubectl delete -f -
269264

265+
## Location to install dependencies to
266+
LOCALBIN ?= $(shell pwd)/bin
267+
$(LOCALBIN):
268+
mkdir -p $(LOCALBIN)
269+
270+
## Tool Binaries
271+
KUSTOMIZE ?= $(LOCALBIN)/kustomize
272+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
273+
ENVTEST ?= $(LOCALBIN)/setup-envtest
274+
MOCKGEN ?= $(LOCALBIN)/mockgen
275+
276+
.PHONY: controller-gen
277+
controller-gen: $(CONTROLLER_GEN) ## Install controller-gen from vendor dir if necessary.
278+
$(CONTROLLER_GEN): $(LOCALBIN)
279+
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen
280+
281+
.PHONY: kustomize
282+
kustomize: $(KUSTOMIZE) ## Install kustomize from vendor dir if necessary.
283+
$(KUSTOMIZE): $(LOCALBIN)
284+
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) go install sigs.k8s.io/kustomize/kustomize/v4
285+
286+
.PHONY: envtest
287+
envtest: $(ENVTEST) ## Install envtest-setup from vendor dir if necessary.
288+
$(ENVTEST): $(LOCALBIN)
289+
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest
290+
291+
.PHONY: mockgen
292+
mockgen: $(MOCKGEN) ## Install mockgen from vendor dir if necessary.
293+
$(MOCKGEN): $(LOCALBIN)
294+
test -s $(LOCALBIN)/mockgen || GOBIN=$(LOCALBIN) go install github.com/golang/mock/mockgen
270295

271-
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
272-
controller-gen: ## Download controller-gen locally if necessary.
273-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
274-
275-
KUSTOMIZE = $(shell pwd)/bin/kustomize
276-
kustomize: ## Download kustomize locally if necessary.
277-
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
278-
279-
ENVTEST = $(shell pwd)/bin/setup-envtest
280-
envtest: ## Download envtest-setup locally if necessary.
281-
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
282-
283-
MOCKGEN = $(shell pwd)/bin/mockgen
284-
mockgen: ## Download mockgen locally if necessary.
285-
$(call go-get-tool,$(MOCKGEN),github.com/golang/mock/[email protected])
286-
287-
# go-get-tool will 'go get' any package $2 and install it to $1.
288-
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
289-
define go-get-tool
290-
@[ -f $(1) ] || { \
291-
set -e ;\
292-
TMP_DIR=$$(mktemp -d) ;\
293-
cd $$TMP_DIR ;\
294-
go mod init tmp ;\
295-
echo "Downloading $(2)" ;\
296-
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
297-
rm -rf $$TMP_DIR ;\
298-
}
299-
endef
300296

301297
##################################################
302298
# General #

0 commit comments

Comments
 (0)