Skip to content

Commit 18f4642

Browse files
yongruilink8s-publishing-bot
authored andcommitted
refactor: detach Info from apimachinery util version
- Remove `info` field from `Version` struct - Modify `WithInfo` and `Info` methods to be deprecated - Update version information retrieval to use base version info - Simplify version information generation in compatibility tests - Remove unnecessary version info passing in build and test scenarios Kubernetes-commit: 14934b481ef6522d6c1003ded19002ea45abe5d1
1 parent a78ae8b commit 18f4642

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/util/version/version.go

+8-8
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,24 +455,25 @@ 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

479479
func Itoa(i uint) string {

0 commit comments

Comments
 (0)