Skip to content

Commit

Permalink
Build setup-envtest in hack/tools
Browse files Browse the repository at this point in the history
This makes the build of setup-envtest consistent with the other tools
built in hack/tools. By moving the dependency to go.mod, it also allows
the build to work correctly when using enforced vendoring.
  • Loading branch information
mdbooth committed Oct 3, 2023
1 parent c73d55d commit fcb4e22
Show file tree
Hide file tree
Showing 6 changed files with 423 additions and 13 deletions.
13 changes: 1 addition & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes

# Setup-envtest
SETUP_ENVTEST_VER := v0.0.0-20221201045826-d9912251cd81
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest

# Kubebuilder
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.25.0
Expand Down Expand Up @@ -224,12 +219,6 @@ managers:
manager-openstack-infrastructure: ## Build manager binary.
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .

$(SETUP_ENVTEST): # Build setup-envtest from tools folder.
GOBIN=$(abspath $(TOOLS_BIN_DIR)) $(GO_INSTALL) $(SETUP_ENVTEST_PKG) $(SETUP_ENVTEST_BIN) $(SETUP_ENVTEST_VER)

.PHONY: $(SETUP_ENVTEST_BIN)
$(SETUP_ENVTEST_BIN): $(SETUP_ENVTEST) ## Build a local copy of setup-envtest.

## --------------------------------------
##@ Linting
## --------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endif
export GOPROXY

$(TOOLS_BIN_DIR)/%: $(TOOLS_DIR_DEPS)
make -C $(TOOLS_DIR) $(subst $(TOOLS_DIR)/,,$@)
$(MAKE) -C $(TOOLS_DIR) $(subst $(TOOLS_DIR)/,,$@)

## --------------------------------------
##@ Help
Expand Down
4 changes: 4 additions & 0 deletions hack/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ ENVSUBST := $(BIN_DIR)/envsubst
$(ENVSUBST): go.mod go.sum | $(BIN_DIR) # Build envsubst from tools folder.
go build -tags=tools -o $@ github.com/a8m/envsubst/cmd/envsubst

SETUP_ENVTEST := $(BIN_DIR)/setup-envtest
$(SETUP_ENVTEST): go.mod go.sum | $(BIN_DIR)
go build -tags=tools -o $@ sigs.k8s.io/controller-runtime/tools/setup-envtest

GH_SHARE := $(SHARE_DIR)/gh

$(GH_SHARE): $(SHARE_DIR)
Expand Down
6 changes: 6 additions & 0 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/onsi/ginkgo/v2 v2.9.4
k8s.io/code-generator v0.28.0
sigs.k8s.io/cluster-api/hack/tools v0.0.0-20221129083400-679ae3e9e6b6
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20230926180527-c93e2abcb28e
sigs.k8s.io/controller-tools v0.13.0
sigs.k8s.io/kustomize/kustomize/v5 v5.1.1
)
Expand All @@ -21,6 +22,7 @@ require (
github.com/fatih/color v1.15.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/zapr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
Expand All @@ -47,10 +49,14 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
Expand Down
Loading

0 comments on commit fcb4e22

Please sign in to comment.