| Jan Schär | 36f3b6d | 2025-05-20 09:05:12 +0000 | [diff] [blame] | 1 | diff --git a/version/BUILD.bazel b/version/BUILD.bazel |
| 2 | index d6aeae2..978a9d3 100644 |
| 3 | --- a/version/BUILD.bazel |
| 4 | +++ b/version/BUILD.bazel |
| 5 | @@ -7,6 +7,7 @@ go_library( |
| 6 | "dynamic.go", |
| 7 | "version.go", |
| 8 | ], |
| 9 | + embedsrcs = ["@@//build:kubernetes_stamp"], |
| 10 | importpath = "k8s.io/component-base/version", |
| 11 | visibility = ["//visibility:public"], |
| 12 | deps = [ |
| 13 | diff --git a/version/base.go b/version/base.go |
| 14 | index 4650011..c7250a7 100644 |
| 15 | --- a/version/base.go |
| 16 | +++ b/version/base.go |
| 17 | @@ -16,6 +16,8 @@ limitations under the License. |
| 18 | |
| 19 | package version |
| 20 | |
| 21 | +import _ "embed" |
| 22 | + |
| 23 | // Base version information. |
| 24 | // |
| 25 | // This is the fallback data used when version information from git is not |
| 26 | @@ -39,7 +41,9 @@ var ( |
| 27 | // them irrelevant. (Next we'll take it out, which may muck with |
| 28 | // scripts consuming the kubectl version output - but most of |
| 29 | // these should be looking at gitVersion already anyways.) |
| 30 | + //go:embed build/kubernetes_gitMajor.txt |
| 31 | gitMajor string // major version, always numeric |
| 32 | + //go:embed build/kubernetes_gitMinor.txt |
| 33 | gitMinor string // minor version, numeric possibly followed by "+" |
| 34 | |
| 35 | // semantic version, derived by build scripts (see |
| 36 | @@ -55,11 +59,15 @@ var ( |
| 37 | // NOTE: The $Format strings are replaced during 'git archive' thanks to the |
| 38 | // companion .gitattributes file containing 'export-subst' in this same |
| 39 | // directory. See also https://git-scm.com/docs/gitattributes |
| 40 | - gitVersion = "v0.0.0-master+$Format:%H$" |
| 41 | - gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) |
| 42 | - gitTreeState = "" // state of git tree, either "clean" or "dirty" |
| 43 | + //go:embed build/kubernetes_gitVersion.txt |
| 44 | + gitVersion string |
| 45 | + //go:embed build/kubernetes_gitCommit.txt |
| 46 | + gitCommit string // sha1 from git, output of $(git rev-parse HEAD) |
| 47 | + //go:embed build/kubernetes_gitTreeState.txt |
| 48 | + gitTreeState string // state of git tree, either "clean" or "dirty" |
| 49 | |
| 50 | - buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 51 | + //go:embed build/kubernetes_buildDate.txt |
| 52 | + buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 53 | ) |
| 54 | |
| 55 | const ( |