@@ -60,8 +60,8 @@ help: ## Display this help.
60
60
# Directories.
61
61
ROOT_DIR: =$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
62
62
TOOLS_DIR := hack/tools
63
- TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
64
63
BIN_DIR := bin
64
+ TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR ) /$(BIN_DIR ) )
65
65
66
66
GOBUILD =go build
67
67
@@ -82,37 +82,41 @@ KUBECTL := $(TOOLS_BIN_DIR)/kubectl
82
82
GOLANGCI_LINT_VERSION := "v1.52.2"
83
83
84
84
$(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
86
86
87
87
$(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
92
89
93
90
$(GOLANGCI_LINT ) : # Build golangci-lint from tools folder.
94
91
cd $(TOOLS_DIR ) ; ./get-golangci-lint.sh $(GOLANGCI_LINT_VERSION )
95
92
96
93
$(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
98
95
99
96
$(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
101
98
102
99
$(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
108
101
109
102
$(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
111
108
112
109
$(KUBECTL ) :
113
110
curl -L https://storage.googleapis.com/kubernetes-release/release/$(K8S_LATEST_VER ) /bin/$(OS ) /$(ARCH ) /kubectl -o $@
114
111
chmod +x $@
115
112
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
+
116
120
.PHONY : tools
117
121
tools : $(CONTROLLER_GEN ) $(ENVSUBST ) $(KUSTOMIZE ) $(SETUP_ENVTEST ) $(GOLANGCI_LINT ) $(GOIMPORTS ) $(GINKGO ) $(CLUSTERCTL ) $(KIND ) $(KUBECTL ) # # build all tools
118
122
@@ -182,7 +186,7 @@ kind-test: test create-cluster fv ## Build docker image; start kind cluster; loa
182
186
183
187
.PHONY : fv
184
188
fv : $(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
186
190
187
191
.PHONY : create-cluster
188
192
create-cluster : $(KIND ) $(CLUSTERCTL ) $(KUBECTL ) $(ENVSUBST ) # # Create a new kind cluster designed for development
@@ -251,18 +255,18 @@ deploy-projectsveltos: $(KUSTOMIZE)
251
255
@echo 'Install libsveltos CRDs'
252
256
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/libsveltos/$(TAG)/config/crd/bases/lib.projectsveltos.io_debuggingconfigurations.yaml
253
257
$(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
255
259
256
260
# Install projectsveltos addon-controller components
257
261
@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}
259
263
$(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f-
260
264
261
265
# Install sveltoscluster-manager
262
266
$(KUBECTL) apply -f https://raw.githubusercontent.com/projectsveltos/sveltoscluster-manager/$(TAG)/manifest/manifest.yaml
263
267
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
266
270
267
271
@echo "Waiting for projectsveltos addon-controller to be available..."
268
272
$(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
326
330
327
331
.PHONY : deploy
328
332
deploy : 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}
330
334
$(KUSTOMIZE ) build config/default | $(ENVSUBST ) | $(KUBECTL ) apply -f -
331
335
332
336
.PHONY : undeploy
0 commit comments