Skip to content

Commit 6f73250

Browse files
authored
Merge pull request #4589 from akagami-harsh/update-k8s-version
✨ Add Makefile target to sync Kubernetes version
2 parents ea6a7fb + 4fb673d commit 6f73250

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ install: build ## Build and install the binary with the current source code. Use
6464
##@ Development
6565

6666
.PHONY: generate
67-
generate: generate-testdata generate-docs ## Update/generate all mock data. You should run this commands to update the mock data after your changes.
67+
generate: generate-testdata generate-docs update-k8s-version ## Update/generate all mock data. You should run this commands to update the mock data after your changes.
6868
go mod tidy
6969
make remove-spaces
7070

@@ -200,3 +200,15 @@ install-helm: ## Install the latest version of Helm locally
200200
.PHONY: helm-lint
201201
helm-lint: install-helm ## Lint the Helm chart in testdata
202202
helm lint testdata/project-v4-with-plugins/dist/chart
203+
204+
K8S_VERSION ?= $(shell go list -m -modfile=./testdata/project-v4/go.mod -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d.%d", $$3, $$4}')
205+
.PHONY: update-k8s-version
206+
update-k8s-version: ## Update Kubernetes API version in version.go and .goreleaser.yml
207+
@if [ -z "$(K8S_VERSION)" ]; then echo "Error: K8S_VERSION is empty"; exit 1; fi
208+
@echo "Updating Kubernetes version to $(K8S_VERSION)"
209+
@# Update version.go
210+
@sed -i.bak 's/kubernetesVendorVersion = .*/kubernetesVendorVersion = "$(K8S_VERSION)"/' cmd/version.go
211+
@# Update .goreleaser.yml
212+
@sed -i.bak 's/KUBERNETES_VERSION=.*/KUBERNETES_VERSION=$(K8S_VERSION)/' build/.goreleaser.yml
213+
@# Clean up backup files
214+
@find . -name "*.bak" -type f -delete

0 commit comments

Comments
 (0)