base.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright 2014 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package version
  14. // Base version information.
  15. //
  16. // This is the fallback data used when version information from git is not
  17. // provided via go ldflags. It provides an approximation of the Kubernetes
  18. // version for ad-hoc builds (e.g. `go build`) that cannot get the version
  19. // information from git.
  20. //
  21. // If you are looking at these fields in the git tree, they look
  22. // strange. They are modified on the fly by the build process. The
  23. // in-tree values are dummy values used for "git archive", which also
  24. // works for GitHub tar downloads.
  25. //
  26. // When releasing a new Kubernetes version, this file is updated by
  27. // build/mark_new_version.sh to reflect the new version, and then a
  28. // git annotated tag (using format vX.Y where X == Major version and Y
  29. // == Minor version) is created to point to the commit that updates
  30. // pkg/version/base.go
  31. var (
  32. // TODO: Deprecate gitMajor and gitMinor, use only gitVersion
  33. // instead. First step in deprecation, keep the fields but make
  34. // them irrelevant. (Next we'll take it out, which may muck with
  35. // scripts consuming the kubectl version output - but most of
  36. // these should be looking at gitVersion already anyways.)
  37. gitMajor string = "" // major version, always numeric
  38. gitMinor string = "" // minor version, numeric possibly followed by "+"
  39. // semantic version, derived by build scripts (see
  40. // https://git.k8s.io/community/contributors/design-proposals/release/versioning.md
  41. // for a detailed discussion of this field)
  42. //
  43. // TODO: This field is still called "gitVersion" for legacy
  44. // reasons. For prerelease versions, the build metadata on the
  45. // semantic version is a git hash, but the version itself is no
  46. // longer the direct output of "git describe", but a slight
  47. // translation to be semver compliant.
  48. // NOTE: The $Format strings are replaced during 'git archive' thanks to the
  49. // companion .gitattributes file containing 'export-subst' in this same
  50. // directory. See also https://git-scm.com/docs/gitattributes
  51. gitVersion string = "v0.0.0-master+$Format:%h$"
  52. gitCommit string = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)
  53. gitTreeState string = "" // state of git tree, either "clean" or "dirty"
  54. buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
  55. )