forked from hswaw/hscloud
third_party/go/kubernetes: fix version reported in kubectl
Change-Id: I5a45158004280c8ce6ba04c18af93e8dbbc300e4
This commit is contained in:
parent
c3f36e9bf1
commit
e23717d520
2 changed files with 26 additions and 1 deletions
|
@ -14,8 +14,30 @@ function rev() {
|
|||
cd $1; git describe --always --match "v[0-9].*" --dirty
|
||||
}
|
||||
|
||||
# Get Kubernetes version by doing an ugly grep. This returns something line 'v1.19.3'.
|
||||
function kube_ver() {
|
||||
cd $1
|
||||
grep -A 10 io_k8s_kubernetes third_party/go/repositories.bzl | grep version | head -n 1 | cut -d '"' -f 2
|
||||
}
|
||||
|
||||
KUBE_MAJOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 1)
|
||||
KUBE_MINOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 2)
|
||||
KUBE_PATCH=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 3)
|
||||
|
||||
echo STABLE_BUILD_GERRIT-OAUTH-PROVIDER_LABEL $(rev .)
|
||||
echo STABLE_BUILD_OWNERS_LABEL $(rev .)
|
||||
echo STABLE_GIT_COMMIT $(git rev-parse HEAD)
|
||||
echo STABLE_GIT_VERSION $(rev .)
|
||||
echo STABLE_BUILDER $(id -un)@$(hostname -f):$(pwd)
|
||||
|
||||
# Kubernetes compatibility - see //third_party/go/kubernetes:version.bzl.
|
||||
echo STABLE_KUBERNETES_buildDate $(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
echo STABLE_KUBERNETES_gitCommit $(git rev-parse HEAD)
|
||||
echo STABLE_KUBERNETES_gitMajor $KUBE_MAJOR
|
||||
echo STABLE_KUBERNETES_gitMinor $KUBE_MINOR
|
||||
if git_status=$(git status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
|
||||
echo STABLE_KUBERNETES_gitTreeState clean
|
||||
else
|
||||
echo STABLE_KUBERNETES_gitTreeState dirty
|
||||
fi
|
||||
echo STABLE_KUBERNETES_gitVersion $(kube_ver .)-hscloud-$(rev .)
|
||||
|
|
5
third_party/go/kubernetes/version.bzl
vendored
5
third_party/go/kubernetes/version.bzl
vendored
|
@ -1,3 +1,6 @@
|
|||
# Compatibility for version_x_defs from k8s.io/component-base & co.
|
||||
# This makes all the defs be autopopulated from //bzl:workspace-status.sh.
|
||||
|
||||
def version_x_defs():
|
||||
stamp_pkgs = [
|
||||
"k8s.io/component-base/version",
|
||||
|
@ -19,5 +22,5 @@ def version_x_defs():
|
|||
x_defs = {}
|
||||
for pkg in stamp_pkgs:
|
||||
for var in stamp_vars:
|
||||
x_defs["%s.%s" % (pkg, var)] = "{%s}" % var
|
||||
x_defs["%s.%s" % (pkg, var)] = "{STABLE_KUBERNETES_%s}" % var
|
||||
return x_defs
|
||||
|
|
Loading…
Reference in a new issue