| diff --git a/pkg/version/BUILD.bazel b/pkg/version/BUILD.bazel |
| index a0ab203..1514297 100644 |
| --- a/pkg/version/BUILD.bazel |
| +++ b/pkg/version/BUILD.bazel |
| @@ -7,6 +7,7 @@ go_library( |
| "doc.go", |
| "version.go", |
| ], |
| + embedsrcs = ["@@//build:kubernetes_stamp"], |
| importpath = "k8s.io/client-go/pkg/version", |
| visibility = ["//visibility:public"], |
| deps = ["@io_k8s_apimachinery//pkg/version"], |
| diff --git a/pkg/version/base.go b/pkg/version/base.go |
| index 676d51d..c76789a 100644 |
| --- a/pkg/version/base.go |
| +++ b/pkg/version/base.go |
| @@ -16,6 +16,8 @@ limitations under the License. |
| |
| package version |
| |
| +import _ "embed" |
| + |
| // Base version information. |
| // |
| // This is the fallback data used when version information from git is not |
| @@ -39,8 +41,10 @@ var ( |
| // them irrelevant. (Next we'll take it out, which may muck with |
| // scripts consuming the kubectl version output - but most of |
| // these should be looking at gitVersion already anyways.) |
| - gitMajor string = "" // major version, always numeric |
| - gitMinor string = "" // minor version, numeric possibly followed by "+" |
| + //go:embed build/kubernetes_gitMajor.txt |
| + gitMajor string // major version, always numeric |
| + //go:embed build/kubernetes_gitMinor.txt |
| + gitMinor string // minor version, numeric possibly followed by "+" |
| |
| // semantic version, derived by build scripts (see |
| // https://github.com/kubernetes/sig-release/blob/master/release-engineering/versioning.md#kubernetes-release-versioning |
| @@ -56,9 +60,13 @@ var ( |
| // NOTE: The $Format strings are replaced during 'git archive' thanks to the |
| // companion .gitattributes file containing 'export-subst' in this same |
| // directory. See also https://git-scm.com/docs/gitattributes |
| - gitVersion string = "v0.0.0-master+$Format:%H$" |
| - gitCommit string = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) |
| - gitTreeState string = "" // state of git tree, either "clean" or "dirty" |
| + //go:embed build/kubernetes_gitVersion.txt |
| + gitVersion string |
| + //go:embed build/kubernetes_gitCommit.txt |
| + gitCommit string // sha1 from git, output of $(git rev-parse HEAD) |
| + //go:embed build/kubernetes_gitTreeState.txt |
| + gitTreeState string // state of git tree, either "clean" or "dirty" |
| |
| - buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| + //go:embed build/kubernetes_buildDate.txt |
| + buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| ) |