Skip to content

Commit 4906cf7

Browse files
Merge pull request #130930 from siyuanfoundation/help
chore: update emulation version help msg. Kubernetes-commit: b4c6895d0b0a913e3461bdc78358aa9514604b8f
2 parents fdef30f + 1565ae1 commit 4906cf7

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

compatibility/registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ func (r *componentGlobalsRegistry) AddFlags(fs *pflag.FlagSet) {
234234
fs.StringSliceVar(&r.emulationVersionConfig, "emulated-version", r.emulationVersionConfig, ""+
235235
"The versions different components emulate their capabilities (APIs, features, ...) of.\n"+
236236
"If set, the component will emulate the behavior of this version instead of the underlying binary version.\n"+
237-
"Version format could only be major.minor, for example: '--emulated-version=wardle=1.2,kube=1.31'. Options are:\n"+strings.Join(r.unsafeVersionFlagOptions(true), "\n")+
238-
"If the component is not specified, defaults to \"kube\"")
237+
"Version format could only be major.minor, for example: '--emulated-version=wardle=1.2,kube=1.31'.\nOptions are: "+strings.Join(r.unsafeVersionFlagOptions(true), ",")+
238+
"\nIf the component is not specified, defaults to \"kube\"")
239239

240240
if r.featureGatesConfigFlags == nil {
241241
r.featureGatesConfigFlags = cliflag.NewColonSeparatedMultimapStringStringAllowDefaultEmptyKey(&r.featureGatesConfig)

compatibility/registry_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestEffectiveVersionRegistry(t *testing.T) {
5757

5858
func testRegistry(t *testing.T) *componentGlobalsRegistry {
5959
r := NewComponentGlobalsRegistry()
60-
verKube := NewEffectiveVersionFromString("1.31", "1.31", "1.30")
60+
verKube := NewEffectiveVersionFromString("1.31.1-beta.0.353", "1.31", "1.30")
6161
fgKube := featuregate.NewVersionedFeatureGate(version.MustParse("0.0"))
6262
err := fgKube.AddVersioned(map[featuregate.Feature]featuregate.VersionedSpecs{
6363
"kubeA": {
@@ -103,13 +103,13 @@ func testRegistry(t *testing.T) *componentGlobalsRegistry {
103103

104104
func TestVersionFlagOptions(t *testing.T) {
105105
r := testRegistry(t)
106-
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), "\n")
107-
expectedEmuVers := "kube=1.31..1.31 (default=1.31)\ntest=2.8..2.8 (default=2.8)"
106+
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), ",")
107+
expectedEmuVers := "kube=1.31..1.31(default:1.31),test=2.8..2.8(default:2.8)"
108108
if emuVers != expectedEmuVers {
109109
t.Errorf("wanted emulation version flag options to be: %s, got %s", expectedEmuVers, emuVers)
110110
}
111-
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), "\n")
112-
expectedMinCompVers := "kube=1.30..1.31 (default=1.30)\ntest=2.7..2.8 (default=2.7)"
111+
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), ",")
112+
expectedMinCompVers := "kube=1.30..1.31(default:1.30),test=2.7..2.8(default:2.7)"
113113
if minCompVers != expectedMinCompVers {
114114
t.Errorf("wanted min compatibility version flag options to be: %s, got %s", expectedMinCompVers, minCompVers)
115115
}
@@ -119,13 +119,13 @@ func TestVersionFlagOptionsWithMapping(t *testing.T) {
119119
r := testRegistry(t)
120120
utilruntime.Must(r.SetEmulationVersionMapping(testComponent, DefaultKubeComponent,
121121
func(from *version.Version) *version.Version { return version.MajorMinor(1, from.Minor()+23) }))
122-
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), "\n")
123-
expectedEmuVers := "test=2.8..2.8 (default=2.8)"
122+
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), ",")
123+
expectedEmuVers := "test=2.8..2.8(default:2.8)"
124124
if emuVers != expectedEmuVers {
125125
t.Errorf("wanted emulation version flag options to be: %s, got %s", expectedEmuVers, emuVers)
126126
}
127-
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), "\n")
128-
expectedMinCompVers := "kube=1.30..1.31 (default=1.30)\ntest=2.7..2.8 (default=2.7)"
127+
minCompVers := strings.Join(r.unsafeVersionFlagOptions(false), ",")
128+
expectedMinCompVers := "kube=1.30..1.31(default:1.30),test=2.7..2.8(default:2.7)"
129129
if minCompVers != expectedMinCompVers {
130130
t.Errorf("wanted min compatibility version flag options to be: %s, got %s", expectedMinCompVers, minCompVers)
131131
}

compatibility/version.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,7 @@ func (m *effectiveVersion) BinaryVersion() *version.Version {
7979
}
8080

8181
func (m *effectiveVersion) EmulationVersion() *version.Version {
82-
ver := m.emulationVersion.Load()
83-
if ver != nil {
84-
// Emulation version can have "alpha" as pre-release to continue serving expired apis while we clean up the test.
85-
// The pre-release should not be accessible to the users.
86-
return ver.WithPreRelease(m.BinaryVersion().PreRelease())
87-
}
88-
return ver
82+
return m.emulationVersion.Load()
8983
}
9084

9185
func (m *effectiveVersion) MinCompatibilityVersion() *version.Version {
@@ -140,7 +134,7 @@ func (m *effectiveVersion) AllowedEmulationVersionRange() string {
140134
floor = version.MajorMinor(0, 0)
141135
}
142136

143-
return fmt.Sprintf("%s..%s (default=%s)", floor.String(), binaryVersion.String(), m.EmulationVersion().String())
137+
return fmt.Sprintf("%s..%s(default:%s)", floor.String(), binaryVersion.String(), m.EmulationVersion().String())
144138
}
145139

146140
func (m *effectiveVersion) AllowedMinCompatibilityVersionRange() string {
@@ -157,7 +151,7 @@ func (m *effectiveVersion) AllowedMinCompatibilityVersionRange() string {
157151
floor = version.MajorMinor(0, 0)
158152
}
159153

160-
return fmt.Sprintf("%s..%s (default=%s)", floor.String(), binaryVersion.String(), m.MinCompatibilityVersion().String())
154+
return fmt.Sprintf("%s..%s(default:%s)", floor.String(), binaryVersion.String(), m.MinCompatibilityVersion().String())
161155
}
162156

163157
func (m *effectiveVersion) Validate() []error {

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
go.uber.org/zap v1.27.0
2929
golang.org/x/sys v0.30.0
3030
k8s.io/apimachinery v0.0.0-20250319092800-e8a77bd768fd
31-
k8s.io/client-go v0.0.0-20250319213421-a9cdb028d1bd
31+
k8s.io/client-go v0.0.0-20250319213423-b0ed7301c5de
3232
k8s.io/klog/v2 v2.130.1
3333
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
3434
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3
@@ -79,7 +79,7 @@ require (
7979
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
8080
gopkg.in/inf.v0 v0.9.1 // indirect
8181
gopkg.in/yaml.v3 v3.0.1 // indirect
82-
k8s.io/api v0.0.0-20250319213038-88064fe45fc1 // indirect
82+
k8s.io/api v0.0.0-20250319213039-6b142a213afd // indirect
8383
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
8484
sigs.k8s.io/randfill v1.0.0 // indirect
8585
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
204204
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
205205
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
206206
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
207-
k8s.io/api v0.0.0-20250319213038-88064fe45fc1 h1:UxRrzYpgtXbqwLrgCZnuKutzQM+z75Ag8Xqd0en/IK8=
208-
k8s.io/api v0.0.0-20250319213038-88064fe45fc1/go.mod h1:JO0tyTI0qSXXaGVhLdqwfi3RMbS2g9hcYvzBmZP5wVk=
207+
k8s.io/api v0.0.0-20250319213039-6b142a213afd h1:8c1Va14wUYbWssIqzNjO2/Hi86kD2wOBPbotT2bXbuw=
208+
k8s.io/api v0.0.0-20250319213039-6b142a213afd/go.mod h1:JO0tyTI0qSXXaGVhLdqwfi3RMbS2g9hcYvzBmZP5wVk=
209209
k8s.io/apimachinery v0.0.0-20250319092800-e8a77bd768fd h1:KoXgjwEokLM8o95kMxowg5vp5iQ4v46Kk+zobsqeTgU=
210210
k8s.io/apimachinery v0.0.0-20250319092800-e8a77bd768fd/go.mod h1:D2UW665TVSpInyOuG6C+PMtC1MZheP0KQz65UPQEiI4=
211-
k8s.io/client-go v0.0.0-20250319213421-a9cdb028d1bd h1:BTLapLdnvFX1TwXUz0d0zoVLYgRAanc4lEL0/T7T7Qo=
212-
k8s.io/client-go v0.0.0-20250319213421-a9cdb028d1bd/go.mod h1:B0JbWCH7ziSx2Lcm10dp7pqHkuFquezdASDn6HXD2dI=
211+
k8s.io/client-go v0.0.0-20250319213423-b0ed7301c5de h1:g07flpDMKdUPeXcMejYRAXvDkM11BaEMfLJMlACJu5E=
212+
k8s.io/client-go v0.0.0-20250319213423-b0ed7301c5de/go.mod h1:mXZyivI7eM6XOlLcqYNrgTSYKl/zQI+PnQp9Jan6tNE=
213213
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
214214
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
215215
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4=

0 commit comments

Comments
 (0)