Description
Which component are you using?:
/area cluster-autoscaler
Is your feature request designed to solve a problem? If so describe the problem this feature should solve.:
Right now cluster-autoscaler/hack/update-deps.sh bumps internal CA version variable to match k8s dependency version. This later requires a manual change: while we want CA version with k8s minor version, patch versions are independent, so each time requires a revert to <last known patch> + 1
.
Describe the solution you'd like.:
Don't populate ClusterAutoscalerVersion in the code at all (use a placeholder value like "dev" instead). Derive the right value at build time based on current tag / commit. Something along the lines of:
#!/bin/bash
# 1. Try to get the exact tag.
# The '2>/dev/null' silences errors if no tag is found.
if tag=$(git describe --exact-match --tags 2>/dev/null); then
# 2. If a tag is found, strip the prefix.
# This uses shell parameter expansion to remove 'cluster-autoscaler-' from the start.
VERSION=${tag#cluster-autoscaler-}
else
# 3. If no tag is found, fall back to the full commit hash.
VERSION=$(git rev-parse HEAD)
fi
# 4. Build CA, injecting the VERSION variable.
echo "Building with version: ${VERSION}"
go build -ldflags="-X 'version.ClusterAutoscalerVersion=${VERSION}'" .
Describe any alternative solutions you've considered.:
Additional context.: