Skip to content

Commit 15d095a

Browse files
more comments
1 parent 1d9c337 commit 15d095a

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

api/v1alpha4/cluster_webhook.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (c *Cluster) validateTopology(old *Cluster) field.ErrorList {
122122
var allErrs field.ErrorList
123123

124124
// NOTE: ClusterClass and managed topologies are behind ClusterManagedTopologies feature gate flag; the web hook
125-
// must to prevent usage of Cluster.Topology in case the feature flag is disabled.
125+
// must prevent the usage of Cluster.Topology in case the feature flag is disabled.
126126
if !feature.Gates.Enabled(feature.ClusterManagedTopologies) {
127127
allErrs = append(
128128
allErrs,

api/v1alpha4/cluster_webhook_test.go

+44-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func TestClusterTopologyValidation(t *testing.T) {
270270
},
271271
},
272272
{
273-
name: "should return error on upgrade when Topology class is changed",
273+
name: "should return error on update when Topology class is changed",
274274
expectErr: true,
275275
old: &Cluster{
276276
Spec: ClusterSpec{
@@ -292,7 +292,7 @@ func TestClusterTopologyValidation(t *testing.T) {
292292
},
293293
},
294294
{
295-
name: "should return error on upgrade when Topology version is downgraded",
295+
name: "should return error on update when Topology version is downgraded",
296296
expectErr: true,
297297
old: &Cluster{
298298
Spec: ClusterSpec{
@@ -313,6 +313,48 @@ func TestClusterTopologyValidation(t *testing.T) {
313313
},
314314
},
315315
},
316+
{
317+
name: "should update",
318+
expectErr: false,
319+
old: &Cluster{
320+
Spec: ClusterSpec{
321+
InfrastructureRef: &corev1.ObjectReference{},
322+
Topology: &Topology{
323+
Class: "foo",
324+
Version: "v1.19.1",
325+
Workers: &WorkersTopology{
326+
MachineDeployments: []MachineDeploymentTopology{
327+
{
328+
Name: "aa",
329+
},
330+
{
331+
Name: "bb",
332+
},
333+
},
334+
},
335+
},
336+
},
337+
},
338+
in: &Cluster{
339+
Spec: ClusterSpec{
340+
InfrastructureRef: &corev1.ObjectReference{},
341+
Topology: &Topology{
342+
Class: "foo",
343+
Version: "v1.19.2",
344+
Workers: &WorkersTopology{
345+
MachineDeployments: []MachineDeploymentTopology{
346+
{
347+
Name: "aa",
348+
},
349+
{
350+
Name: "bb",
351+
},
352+
},
353+
},
354+
},
355+
},
356+
},
357+
},
316358
}
317359

318360
for _, tt := range tests {

api/v1alpha4/clusterclass_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type MachineDeploymentClass struct {
7373
Template MachineDeploymentClassTemplate `json:"template"`
7474
}
7575

76-
// MachineDeploymentClassTemplate defines how a Deployment generated from a MachineDeploymentClass
76+
// MachineDeploymentClassTemplate defines how a MachineDeployment generated from a MachineDeploymentClass
7777
// should look like.
7878
type MachineDeploymentClassTemplate struct {
7979
Metadata ObjectMeta `json:"metadata,omitempty"`
@@ -90,7 +90,7 @@ type MachineDeploymentClassTemplate struct {
9090
// LocalObjectTemplate defines a template for a topology Class.
9191
type LocalObjectTemplate struct {
9292
// Ref is a required reference to a custom resource
93-
// offered by a bootstrap provider.
93+
// offered by a provider.
9494
Ref corev1.ObjectReference `json:"ref"`
9595
}
9696

api/v1alpha4/clusterclass_webhook.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (in *ClusterClass) validate(old *ClusterClass) error {
119119
if class.Template.Bootstrap.Ref.Namespace != in.Namespace {
120120
allErrs = append(allErrs,
121121
field.Invalid(
122-
field.NewPath("spec", "worker", "deployments", "template", "bootstrap", "ref", "namespace"),
122+
field.NewPath("spec", "worker", "machineDeployments", "template", "bootstrap", "ref", "namespace"),
123123
class.Template.Bootstrap.Ref.Namespace,
124124
"must match metadata.namespace",
125125
),
@@ -128,7 +128,7 @@ func (in *ClusterClass) validate(old *ClusterClass) error {
128128
if class.Template.Infrastructure.Ref.Namespace != in.Namespace {
129129
allErrs = append(allErrs,
130130
field.Invalid(
131-
field.NewPath("spec", "worker", "deployments", "infrastructure", "bootstrap", "ref", "namespace"),
131+
field.NewPath("spec", "worker", "machineDeployments", "infrastructure", "bootstrap", "ref", "namespace"),
132132
class.Template.Infrastructure.Ref.Namespace,
133133
"must match metadata.namespace",
134134
),
@@ -142,7 +142,7 @@ func (in *ClusterClass) validate(old *ClusterClass) error {
142142
if classNames.Has(class.Class) {
143143
allErrs = append(allErrs,
144144
field.Invalid(
145-
field.NewPath("spec", "worker", "deployments"),
145+
field.NewPath("spec", "worker", "machineDeployments"),
146146
class,
147147
fmt.Sprintf("MachineDeployment class should be unique. MachineDeployment with class %q is defined more than once.", class.Class),
148148
),
@@ -159,7 +159,7 @@ func (in *ClusterClass) validate(old *ClusterClass) error {
159159
if !classNames.Has(oldClass.Class) {
160160
allErrs = append(allErrs,
161161
field.Invalid(
162-
field.NewPath("spec", "worker", "deployments"),
162+
field.NewPath("spec", "worker", "machineDeployments"),
163163
in.Spec.Workers.MachineDeployments,
164164
fmt.Sprintf("The %q MachineDeployment class can't be removed.", oldClass.Class),
165165
),

config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
properties:
4848
ref:
4949
description: Ref is a required reference to a custom resource
50-
offered by a bootstrap provider.
50+
offered by a provider.
5151
properties:
5252
apiVersion:
5353
description: API version of the referent.
@@ -94,7 +94,7 @@ spec:
9494
properties:
9595
ref:
9696
description: Ref is a required reference to a custom resource
97-
offered by a bootstrap provider.
97+
offered by a provider.
9898
properties:
9999
apiVersion:
100100
description: API version of the referent.
@@ -162,7 +162,7 @@ spec:
162162
properties:
163163
ref:
164164
description: Ref is a required reference to a custom
165-
resource offered by a bootstrap provider.
165+
resource offered by a provider.
166166
properties:
167167
apiVersion:
168168
description: API version of the referent.
@@ -216,7 +216,7 @@ spec:
216216
properties:
217217
ref:
218218
description: Ref is a required reference to a custom
219-
resource offered by a bootstrap provider.
219+
resource offered by a provider.
220220
properties:
221221
apiVersion:
222222
description: API version of the referent.

feature/feature.go

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const (
3737
// ClusterResourceSet is a feature gate for the ClusterResourceSet functionality.
3838
//
3939
// alpha: v0.3
40+
// beta: v0.4
4041
ClusterResourceSet featuregate.Feature = "ClusterResourceSet"
4142

4243
// ClusterManagedTopologies is a feature gate for the ClusterClass and managed topologies functionality.

0 commit comments

Comments
 (0)