@@ -19,6 +19,7 @@ IMAGE_PREFIX ?= ghcr.io/sovereigncloudstack
1919STAGING_IMAGE = $(CONTROLLER_SHORT ) -staging
2020BUILDER_IMAGE = $(IMAGE_PREFIX ) /$(CONTROLLER_SHORT ) -builder
2121BUILDER_IMAGE_VERSION = $(shell cat .builder-image-version.txt)
22+ HACK_TOOLS_BIN_VERSION = $(shell cat ./hack/tools/bin/version.txt)
2223
2324SHELL = /usr/bin/env bash -o pipefail
2425.SHELLFLAGS = -ec
@@ -80,16 +81,19 @@ MGT_CLUSTER_KUBECONFIG ?= ".mgt-cluster-kubeconfig.yaml"
8081
8182# Kubebuilder.
8283export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.25.0
84+ # versions
85+ CTLPTL_VERSION := 0.8.25
8386
8487# #@ Binaries
8588# ###########
8689# Binaries #
8790# ###########
91+ # need in CI for releasing
8892CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR ) /controller-gen)
89- controller-gen : $(CONTROLLER_GEN ) # # Build a local copy of controller-gen
9093$(CONTROLLER_GEN ) : # Build controller-gen from tools folder.
9194 go install sigs.k8s.io/controller-tools/cmd/
[email protected] 9295
96+ # need this in CI for releasing
9397KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR ) /kustomize)
9498kustomize : $(KUSTOMIZE ) # # Build a local copy of kustomize
9599$(KUSTOMIZE ) : # Build kustomize from tools folder.
@@ -114,24 +118,10 @@ $(SETUP_ENVTEST): # Build setup-envtest from tools folder.
114118CTLPTL := $(abspath $(TOOLS_BIN_DIR ) /ctlptl)
115119ctlptl : $(CTLPTL ) # # Build a local copy of ctlptl
116120$(CTLPTL ) :
117- go install github.com/tilt-dev/ctlptl/cmd/
[email protected] 118-
119- CLUSTERCTL := $(abspath $(TOOLS_BIN_DIR ) /clusterctl)
120- clusterctl : $(CLUSTERCTL ) # # Build a local copy of clusterctl
121- $(CLUSTERCTL ) :
122- curl -sSLf https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.0/clusterctl-$$(go env GOOS ) -$$(go env GOARCH ) -o $(CLUSTERCTL )
123- chmod a+rx $(CLUSTERCTL )
124-
125- KIND := $(abspath $(TOOLS_BIN_DIR ) /kind)
126- kind : $(KIND ) # # Build a local copy of kind
127- $(KIND ) :
128- go install sigs.k8s.io/
[email protected] 121+ curl -sSL https://github.com/tilt-dev/ctlptl/releases/download/v$(CTLPTL_VERSION ) /ctlptl.$(CTLPTL_VERSION ) .linux.x86_64.tar.gz | tar xz -C $(TOOLS_BIN_DIR ) ctlptl
129122
130123KUBECTL := $(abspath $(TOOLS_BIN_DIR ) /kubectl)
131- kubectl : $(KUBECTL ) # # Build a local copy of kubectl
132- $(KUBECTL ) :
133- curl -fsSL " https://dl.k8s.io/release/v1.27.3/bin/$$ (go env GOOS)/$$ (go env GOARCH)/kubectl" -o $(KUBECTL )
134- chmod a+rx $(KUBECTL )
124+
135125
136126HELM := $(abspath $(TOOLS_BIN_DIR ) /helm)
137127helm : $(HELM ) # # Build a local copy of helm
@@ -181,7 +171,7 @@ $(GOTESTSUM):
181171 go install gotest.tools/
[email protected] 182172
183173
184- all-tools : $( KIND ) $( KUBECTL ) $( CLUSTERCTL ) $(CTLPTL ) $(SETUP_ENVTEST ) $(ENVSUBST ) $(KUSTOMIZE ) $(CONTROLLER_GEN )
174+ all-tools : get-dependencies $(CTLPTL ) $(SETUP_ENVTEST ) $(ENVSUBST ) $(KUSTOMIZE ) $(CONTROLLER_GEN )
185175 echo ' done'
186176
187177# #@ Development
@@ -197,7 +187,7 @@ delete-bootstrap-cluster: $(CTLPTL) ## Deletes Kind-dev Cluster
197187 $(CTLPTL ) delete registry cso-registry
198188
199189.PHONY : cluster
200- cluster : $(CTLPTL ) $(KUBECTL ) # # Creates kind-dev Cluster
190+ cluster : get-dependencies $(CTLPTL ) $(KUBECTL ) # # Creates kind-dev Cluster
201191 @# Fail early. Background: After Tilt started, changing .envrc has no effect for processes
202192 @# started via Tilt. That's why this should fail early.
203193 ./hack/kind-dev.sh
@@ -282,12 +272,6 @@ set-manifest-pull-policy:
282272 $(info Updating kustomize pull policy file for default resource)
283273 sed -i' ' -e ' s@imagePullPolicy: .*@imagePullPolicy: ' " $( PULL_POLICY) " ' @' $(TARGET_RESOURCE )
284274
285- builder-image-promote-latest :
286- ./hack/ensure-env-variables.sh USERNAME PASSWORD
287- skopeo copy --src-creds=$(USERNAME ) :$(PASSWORD ) --dest-creds=$(USERNAME ) :$(PASSWORD ) \
288- docker://$(BUILDER_IMAGE ) :$(BUILDER_IMAGE_VERSION ) \
289- docker://$(BUILDER_IMAGE ) :latest
290-
291275# #@ Binary
292276# #########
293277# Binary #
@@ -545,5 +529,31 @@ create-workload-cluster-docker: $(ENVSUBST) $(KUBECTL)
545529 cat .cluster.yaml | $(ENVSUBST ) - | $(KUBECTL ) apply -f -
546530
547531.PHONY : tilt-up
548- tilt-up : env-vars-for-wl-cluster $( ENVSUBST ) $(KUBECTL ) $( KUSTOMIZE ) $(TILT ) cluster # # Start a mgt-cluster & Tilt. Installs the CRDs and deploys the controllers
532+ tilt-up : env-vars-for-wl-cluster get-dependencies $(ENVSUBST ) $(TILT ) cluster # # Start a mgt-cluster & Tilt. Installs the CRDs and deploys the controllers
549533 EXP_CLUSTER_RESOURCE_SET=true $(TILT ) up --port=10351
534+
535+ BINARIES = clusterctl controller-gen helm kind kubectl kustomize trivy
536+ get-dependencies :
537+ ifeq ($(BUILD_IN_CONTAINER ) ,true)
538+ docker run --rm -t -i \
539+ -v $(shell pwd):/src/cluster-stack-operator \
540+ $(BUILDER_IMAGE):$(BUILDER_IMAGE_VERSION) $@;
541+ else
542+ @if [ "$(HACK_TOOLS_BIN_VERSION)" != "$(BUILDER_IMAGE_VERSION)" ]; then \
543+ echo "Updating binaries"; \
544+ rm -rf hack/tools/bin; \
545+ mkdir -p $(TOOLS_BIN_DIR); \
546+ cp ./.builder-image-version.txt $(TOOLS_BIN_DIR)/version.txt; \
547+ for tool in $(BINARIES); do \
548+ if command -v $$tool > /dev/null; then \
549+ cp `command -v $$tool` $(TOOLS_BIN_DIR); \
550+ echo "copied $$tool to $(TOOLS_BIN_DIR)"; \
551+ else \
552+ echo "$$tool not found"; \
553+ fi; \
554+ done; \
555+ else \
556+ echo "No action required"; \
557+ echo "Binaries are up to date"; \
558+ fi
559+ endif
0 commit comments