diff --git a/.gitignore b/.gitignore index eb467d2..a8e7cff 100644 --- a/.gitignore +++ b/.gitignore @@ -22,5 +22,6 @@ bin .vscode .version +config/begin/* cover.out diff --git a/Makefile b/Makefile index 2abaaee..b503b77 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright 2022-2023 Hewlett Packard Enterprise Development LP +# Copyright 2022-2024 Hewlett Packard Enterprise Development LP # Other additional copyright holders may be indicated within. # # The entirety of this work is licensed under the Apache License, @@ -29,8 +29,10 @@ # cray.hpe.com/dws-bundle:$VERSION and cray.hpe.com/dws-catalog:$VERSION. IMAGE_TAG_BASE ?= ghcr.io/dataworkflowservices/dws-test-driver +OVERLAY ?= top + # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.26.0 +ENVTEST_K8S_VERSION = 1.28.0 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -72,7 +74,8 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. - $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." +# $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." + echo .PHONY: fmt fmt: ## Run go fmt against code. @@ -145,15 +148,18 @@ ifndef ignore-not-found ignore-not-found = false endif +.PHONY: edit-image +edit-image: VERSION ?= $(shell cat .version) +edit-image: .version + $(KUSTOMIZE_IMAGE_TAG) config/begin $(OVERLAY) $(IMAGE_TAG_BASE) $(VERSION) + .PHONY: deploy -deploy: VERSION ?= $(shell cat .version) -deploy: .version kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMAGE_TAG_BASE}:${VERSION} - $(KUSTOMIZE) build config/top | kubectl apply -f - +deploy: kustomize edit-image ## Deploy controller to the K8s cluster specified in ~/.kube/config. + $(KUSTOMIZE) build config/begin | kubectl apply -f - .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/top | kubectl delete --ignore-not-found=$(ignore-not-found) -f - + $(KUSTOMIZE) build config/$(OVERLAY) | kubectl delete --ignore-not-found=$(ignore-not-found) -f - # Let .version be phony so that a git update to the workarea can be reflected # in it each time it's needed. @@ -178,6 +184,7 @@ clean-bin: fi ## Tool Binaries +KUSTOMIZE_IMAGE_TAG ?= ./hack/make-kustomization.sh KUSTOMIZE ?= $(LOCALBIN)/kustomize CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt index 6f41659..ff1fb5b 100644 --- a/hack/boilerplate.go.txt +++ b/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* -Copyright 2023 Hewlett Packard Enterprise Development LP. +Copyright 2024 Hewlett Packard Enterprise Development LP. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/hack/make-kustomization.sh b/hack/make-kustomization.sh new file mode 100755 index 0000000..78034df --- /dev/null +++ b/hack/make-kustomization.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright 2023 Hewlett Packard Enterprise Development LP +# Other additional copyright holders may be indicated within. +# +# The entirety of this work is licensed under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +OVERLAY_DIR=$1 +OVERLAY=$2 +IMAGE_TAG_BASE=$3 +TAG=$4 + +if [[ ! -d $OVERLAY_DIR ]] +then + mkdir "$OVERLAY_DIR" +fi + +cat < "$OVERLAY_DIR"/kustomization.yaml +resources: +- ../$OVERLAY + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: $IMAGE_TAG_BASE + newTag: $TAG +EOF +