Skip to content

Commit c8bf404

Browse files
Merge pull request #130019 from yongruilin/version-intro
KEP-4330: extend version information with more detailed version fields Kubernetes-commit: 23d63770284cb30a2eb90b79ace0f1c7e32fb16f
2 parents a04ff37 + 18f4642 commit c8bf404

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

pkg/util/version/version.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type Version struct {
3333
semver bool
3434
preRelease string
3535
buildMetadata string
36-
info apimachineryversion.Info
3736
}
3837

3938
var (
@@ -456,27 +455,28 @@ func (v *Version) Compare(other string) (int, error) {
456455
return v.compareInternal(ov), nil
457456
}
458457

459-
// WithInfo returns copy of the version object with requested info
458+
// WithInfo returns copy of the version object.
459+
// Deprecated: The Info field has been removed from the Version struct. This method no longer modifies the Version object.
460460
func (v *Version) WithInfo(info apimachineryversion.Info) *Version {
461461
result := *v
462-
result.info = info
463462
return &result
464463
}
465464

465+
// Info returns the version information of a component.
466+
// Deprecated: Use Info() from effective version instead.
466467
func (v *Version) Info() *apimachineryversion.Info {
467468
if v == nil {
468469
return nil
469470
}
470471
// in case info is empty, or the major and minor in info is different from the actual major and minor
471-
v.info.Major = itoa(v.Major())
472-
v.info.Minor = itoa(v.Minor())
473-
if v.info.GitVersion == "" {
474-
v.info.GitVersion = v.String()
472+
return &apimachineryversion.Info{
473+
Major: Itoa(v.Major()),
474+
Minor: Itoa(v.Minor()),
475+
GitVersion: v.String(),
475476
}
476-
return &v.info
477477
}
478478

479-
func itoa(i uint) string {
479+
func Itoa(i uint) string {
480480
if i == 0 {
481481
return ""
482482
}

pkg/version/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ limitations under the License.
1616

1717
// +k8s:openapi-gen=true
1818

19-
// Package version supplies the type for version information collected at build time.
19+
// Package version supplies the type for version information.
2020
package version

pkg/version/types.go

+19-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@ package version
2020
// TODO: Add []string of api versions supported? It's still unclear
2121
// how we'll want to distribute that information.
2222
type Info struct {
23-
Major string `json:"major"`
24-
Minor string `json:"minor"`
25-
GitVersion string `json:"gitVersion"`
26-
GitCommit string `json:"gitCommit"`
27-
GitTreeState string `json:"gitTreeState"`
28-
BuildDate string `json:"buildDate"`
29-
GoVersion string `json:"goVersion"`
30-
Compiler string `json:"compiler"`
31-
Platform string `json:"platform"`
23+
// Major is the major version of the binary version
24+
Major string `json:"major"`
25+
// Minor is the minor version of the binary version
26+
Minor string `json:"minor"`
27+
// EmulationMajor is the major version of the emulation version
28+
EmulationMajor string `json:"emulationMajor,omitempty"`
29+
// EmulationMinor is the minor version of the emulation version
30+
EmulationMinor string `json:"emulationMinor,omitempty"`
31+
// MinCompatibilityMajor is the major version of the minimum compatibility version
32+
MinCompatibilityMajor string `json:"minCompatibilityMajor,omitempty"`
33+
// MinCompatibilityMinor is the minor version of the minimum compatibility version
34+
MinCompatibilityMinor string `json:"minCompatibilityMinor,omitempty"`
35+
GitVersion string `json:"gitVersion"`
36+
GitCommit string `json:"gitCommit"`
37+
GitTreeState string `json:"gitTreeState"`
38+
BuildDate string `json:"buildDate"`
39+
GoVersion string `json:"goVersion"`
40+
Compiler string `json:"compiler"`
41+
Platform string `json:"platform"`
3242
}
3343

3444
// String returns info as a human-friendly version string.

0 commit comments

Comments
 (0)