| diff --git a/version/BUILD.bazel b/version/BUILD.bazel |
| index d6aeae2..978a9d3 100644 |
| --- a/version/BUILD.bazel |
| +++ b/version/BUILD.bazel |
| @@ -7,6 +7,7 @@ go_library( |
| "dynamic.go", |
| "version.go", |
| ], |
| + embedsrcs = ["@@//build:kubernetes_stamp"], |
| importpath = "k8s.io/component-base/version", |
| visibility = ["//visibility:public"], |
| deps = [ |
| diff --git a/version/base.go b/version/base.go |
| index 4650011..c7250a7 100644 |
| --- a/version/base.go |
| +++ b/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,7 +41,9 @@ 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.) |
| + //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 |
| @@ -55,11 +59,15 @@ 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 = "v0.0.0-master+$Format:%H$" |
| - gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) |
| - gitTreeState = "" // 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 = "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') |
| ) |
| |
| const ( |