@@ -60,8 +60,8 @@ help: ## Display this help.
6060# Directories.
6161ROOT_DIR: =$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
6262TOOLS_DIR := hack/tools
63- TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
6463BIN_DIR := bin
64+ TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR ) /$(BIN_DIR ) )
6565
6666GOBUILD =go build
6767
@@ -82,37 +82,41 @@ KUBECTL := $(TOOLS_BIN_DIR)/kubectl
8282GOLANGCI_LINT_VERSION := "v1.52.2"
8383
8484$(CONTROLLER_GEN ) : $(TOOLS_DIR ) /go.mod # Build controller-gen from tools folder.
85- cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst hack/tools/,,$@ ) sigs.k8s.io/controller-tools/cmd/controller-gen
85+ cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst $( TOOLS_DIR ) / hack/tools/,,$@ ) sigs.k8s.io/controller-tools/cmd/controller-gen
8686
8787$(ENVSUBST ) : $(TOOLS_DIR ) /go.mod # Build envsubst from tools folder.
88- cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst hack/tools/,,$@ ) github.com/a8m/envsubst/cmd/envsubst
89-
90- $(KUSTOMIZE ) : $(TOOLS_DIR ) /go.mod # Build kustomize from tools folder.
91- cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(BIN_DIR ) /kustomize sigs.k8s.io/kustomize/kustomize/v4
88+ cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst $(TOOLS_DIR ) /hack/tools/,,$@ ) github.com/a8m/envsubst/cmd/envsubst
9289
9390$(GOLANGCI_LINT ) : # Build golangci-lint from tools folder.
9491 cd $(TOOLS_DIR ) ; ./get-golangci-lint.sh $(GOLANGCI_LINT_VERSION )
9592
9693$(SETUP_ENVTEST ) : $(TOOLS_DIR ) /go.mod # Build setup-envtest from tools folder.
97- cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst hack/tools/,,$@ ) sigs.k8s.io/controller-runtime/tools/setup-envtest
94+ cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst $( TOOLS_DIR ) / hack/tools/,,$@ ) sigs.k8s.io/controller-runtime/tools/setup-envtest
9895
9996$(GOIMPORTS ) :
100- cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst hack/tools/,,$@ ) golang.org/x/tools/cmd/goimports
97+ cd $(TOOLS_DIR ) ; $(GOBUILD ) -tags=tools -o $(subst $( TOOLS_DIR ) / hack/tools/,,$@ ) golang.org/x/tools/cmd/goimports
10198
10299$(GINKGO ) : $(TOOLS_DIR ) /go.mod
103- cd $(TOOLS_DIR ) && $(GOBUILD ) -tags tools -o $(subst hack/tools/,,$@ ) github.com/onsi/ginkgo/v2/ginkgo
104-
105- $(CLUSTERCTL ) : $(TOOLS_DIR ) /go.mod # # Build clusterctl binary
106- cd $(TOOLS_DIR ) ; $(GOBUILD ) -ldflags $(CLUSTERAPI_LDFLAGS ) -o $(subst hack/tools/,,$@ ) sigs.k8s.io/cluster-api/cmd/clusterctl
107- mkdir -p $(HOME ) /.cluster-api # create cluster api init directory, if not present
100+ cd $(TOOLS_DIR ) && $(GOBUILD ) -tags tools -o $(subst $(TOOLS_DIR ) /hack/tools/,,$@ ) github.com/onsi/ginkgo/v2/ginkgo
108101
109102$(KIND ) : $(TOOLS_DIR ) /go.mod
110- cd $(TOOLS_DIR ) && $(GOBUILD ) -tags tools -o $(subst hack/tools/,,$@ ) sigs.k8s.io/kind
103+ cd $(TOOLS_DIR ) && $(GOBUILD ) -tags tools -o $(subst $(TOOLS_DIR ) /hack/tools/,,$@ ) sigs.k8s.io/kind
104+
105+ $(CLUSTERCTL ) : $(TOOLS_DIR ) /go.mod # # Build clusterctl binary
106+ cd $(TOOLS_DIR ) ; $(GOBUILD ) -trimpath -ldflags $(CLUSTERAPI_LDFLAGS ) -o $(subst $(TOOLS_DIR ) /hack/tools/,,$@ ) sigs.k8s.io/cluster-api/cmd/clusterctl
107+ mkdir -p $(HOME ) /.cluster-api # create cluster api init directory, if not present
111108
112109$(KUBECTL ) :
113110 curl -L https://storage.googleapis.com/kubernetes-release/release/$(K8S_LATEST_VER ) /bin/$(OS ) /$(ARCH ) /kubectl -o $@
114111 chmod +x $@
115112
113+ KUSTOMIZE_VER := v4.5.2
114+ KUSTOMIZE_BIN := kustomize
115+ KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR ) /$(KUSTOMIZE_BIN ) -$(KUSTOMIZE_VER ) )
116+ KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v4
117+ $(KUSTOMIZE ) : # Build kustomize from tools folder.
118+ CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) $(KUSTOMIZE_PKG ) $(KUSTOMIZE_BIN ) $(KUSTOMIZE_VER )
119+
116120.PHONY : tools
117121tools : $(CONTROLLER_GEN ) $(ENVSUBST ) $(KUSTOMIZE ) $(SETUP_ENVTEST ) $(GOLANGCI_LINT ) $(GOIMPORTS ) $(GINKGO ) $(CLUSTERCTL ) $(KIND ) $(KUBECTL ) # # build all tools
118122
@@ -182,7 +186,7 @@ kind-test: test create-cluster fv ## Build docker image; start kind cluster; loa
182186
183187.PHONY : fv
184188fv : $(GINKGO ) # # Run Sveltos Controller tests using existing cluster
185- cd test/fv; ../../ $(GINKGO ) -nodes $(NUM_NODES ) --label-filter=' FV' --v --trace --randomize-all
189+ cd test/fv; $(GINKGO ) -nodes $(NUM_NODES ) --label-filter=' FV' --v --trace --randomize-all
186190
187191.PHONY : create-cluster
188192create-cluster : $(KIND ) $(CLUSTERCTL ) $(KUBECTL ) $(ENVSUBST ) # # Create a new kind cluster designed for development
@@ -251,18 +255,18 @@ deploy-projectsveltos: $(KUSTOMIZE)
251255 @echo 'Install libsveltos CRDs'
252256 $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_debuggingconfigurations.yaml
253257 $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_sveltosclusters.yaml
254- $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_addonconstraints .yaml
258+ $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_addoncompliances .yaml
255259
256260 # Install projectsveltos addon-controller components
257261 @echo 'Install projectsveltos addon-controller components'
258- cd config/manager && ../../ $(KUSTOMIZE) edit set image controller=${IMG}
262+ cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
259263 $(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f-
260264
261265 # Install sveltoscluster-manager
262266 $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/sveltoscluster-manager/$(TAG)/manifest/manifest.yaml
263267
264- # Install addon-constraint -controller
265- $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/addon-constraint -controller/$(TAG)/manifest/manifest.yaml
268+ # Install addon-compliance -controller
269+ $(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/addon-compliance -controller/$(TAG)/manifest/manifest.yaml
266270
267271 @echo "Waiting for projectsveltos addon-controller to be available..."
268272 $(KUBECTL) wait --for=condition=Available deployment/addon-controller -n projectsveltos --timeout=$(TIMEOUT)
@@ -326,7 +330,7 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specifi
326330
327331.PHONY : deploy
328332deploy : manifests $(KUSTOMIZE ) # # Deploy controller to the K8s cluster specified in ~/.kube/config.
329- cd config/manager && ../../ $(KUSTOMIZE ) edit set image controller=${IMG}
333+ cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
330334 $(KUSTOMIZE ) build config/default | $(ENVSUBST ) | $(KUBECTL ) apply -f -
331335
332336.PHONY : undeploy
0 commit comments