Skip to content

Commit f2ba999

Browse files
committed
Update suffixes of API constants to be consistent
Signed-off-by: Chirayu Kapoor <[email protected]>
1 parent 709d848 commit f2ba999

File tree

101 files changed

+427
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+427
-427
lines changed

api/v1beta1/common_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import (
2222
)
2323

2424
const (
25-
// ClusterLabelName is the label set on machines linked to a cluster and
25+
// ClusterNameLabel is the label set on machines linked to a cluster and
2626
// external objects(bootstrap and infrastructure providers).
27-
ClusterLabelName = "cluster.x-k8s.io/cluster-name"
27+
ClusterNameLabel = "cluster.x-k8s.io/cluster-name"
2828

2929
// ClusterTopologyOwnedLabel is the label set on all the object which are managed as part of a ClusterTopology.
3030
ClusterTopologyOwnedLabel = "topology.cluster.x-k8s.io/owned"
@@ -45,18 +45,18 @@ const (
4545
// When removing also remove from staticcheck exclude-rules for SA1019 in golangci.yml.
4646
ClusterTopologyManagedFieldsAnnotation = "topology.cluster.x-k8s.io/managed-field-paths"
4747

48-
// ClusterTopologyMachineDeploymentLabelName is the label set on the generated MachineDeployment objects
48+
// ClusterTopologyMachineDeploymentNameLabel is the label set on the generated MachineDeployment objects
4949
// to track the name of the MachineDeployment topology it represents.
50-
ClusterTopologyMachineDeploymentLabelName = "topology.cluster.x-k8s.io/deployment-name"
50+
ClusterTopologyMachineDeploymentNameLabel = "topology.cluster.x-k8s.io/deployment-name"
5151

5252
// ClusterTopologyUnsafeUpdateClassNameAnnotation can be used to disable the webhook check on
5353
// update that disallows a pre-existing Cluster to be populated with Topology information and Class.
5454
ClusterTopologyUnsafeUpdateClassNameAnnotation = "unsafe.topology.cluster.x-k8s.io/disable-update-class-name-check"
5555

56-
// ProviderLabelName is the label set on components in the provider manifest.
56+
// ProviderNameLabel is the label set on components in the provider manifest.
5757
// This label allows to easily identify all the components belonging to a provider; the clusterctl
5858
// tool uses this label for implementing provider's lifecycle operations.
59-
ProviderLabelName = "cluster.x-k8s.io/provider"
59+
ProviderNameLabel = "cluster.x-k8s.io/provider"
6060

6161
// ClusterNameAnnotation is the annotation set on nodes identifying the name of the cluster the node belongs to.
6262
ClusterNameAnnotation = "cluster.x-k8s.io/cluster-name"
@@ -80,10 +80,10 @@ const (
8080
// on the reconciled object.
8181
PausedAnnotation = "cluster.x-k8s.io/paused"
8282

83-
// DisableMachineCreate is an annotation that can be used to signal a MachineSet to stop creating new machines.
83+
// DisableMachineCreateAnnotation is an annotation that can be used to signal a MachineSet to stop creating new machines.
8484
// It is utilized in the OnDelete MachineDeploymentStrategy to allow the MachineDeployment controller to scale down
8585
// older MachineSets when Machines are deleted and add the new replicas to the latest MachineSet.
86-
DisableMachineCreate = "cluster.x-k8s.io/disable-machine-create"
86+
DisableMachineCreateAnnotation = "cluster.x-k8s.io/disable-machine-create"
8787

8888
// WatchLabel is a label othat can be applied to any Cluster API object.
8989
//

api/v1beta1/condition_consts.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,19 @@ const (
166166
// RemediationInProgressReason is the reason used when an unhealthy machine is being remediated by the remediation owner.
167167
RemediationInProgressReason = "RemediationInProgress"
168168

169-
// ExternalRemediationTemplateAvailable is set on machinehealthchecks when MachineHealthCheck controller uses external remediation.
170-
// ExternalRemediationTemplateAvailable is set to false if external remediation template is not found.
171-
ExternalRemediationTemplateAvailable ConditionType = "ExternalRemediationTemplateAvailable"
169+
// ExternalRemediationTemplateAvailableCondition is set on machinehealthchecks when MachineHealthCheck controller uses external remediation.
170+
// ExternalRemediationTemplateAvailableCondition is set to false if external remediation template is not found.
171+
ExternalRemediationTemplateAvailableCondition ConditionType = "ExternalRemediationTemplateAvailable"
172172

173-
// ExternalRemediationTemplateNotFound is the reason used when a machine health check fails to find external remediation template.
174-
ExternalRemediationTemplateNotFound = "ExternalRemediationTemplateNotFound"
173+
// ExternalRemediationTemplateNotFoundReason is the reason used when a machine health check fails to find external remediation template.
174+
ExternalRemediationTemplateNotFoundReason = "ExternalRemediationTemplateNotFound"
175175

176-
// ExternalRemediationRequestAvailable is set on machinehealthchecks when MachineHealthCheck controller uses external remediation.
177-
// ExternalRemediationRequestAvailable is set to false if creating external remediation request fails.
178-
ExternalRemediationRequestAvailable ConditionType = "ExternalRemediationRequestAvailable"
176+
// ExternalRemediationRequestAvailableCondition is set on machinehealthchecks when MachineHealthCheck controller uses external remediation.
177+
// ExternalRemediationRequestAvailableCondition is set to false if creating external remediation request fails.
178+
ExternalRemediationRequestAvailableCondition ConditionType = "ExternalRemediationRequestAvailable"
179179

180-
// ExternalRemediationRequestCreationFailed is the reason used when a machine health check fails to create external remediation request.
181-
ExternalRemediationRequestCreationFailed = "ExternalRemediationRequestCreationFailed"
180+
// ExternalRemediationRequestCreationFailedReason is the reason used when a machine health check fails to create external remediation request.
181+
ExternalRemediationRequestCreationFailedReason = "ExternalRemediationRequestCreationFailed"
182182
)
183183

184184
// Conditions and condition Reasons for the Machine's Node object.

api/v1beta1/machine_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ const (
2727
// MachineFinalizer is set on PrepareForCreate callback.
2828
MachineFinalizer = "machine.cluster.x-k8s.io"
2929

30-
// MachineControlPlaneLabelName is the label set on machines or related objects that are part of a control plane.
31-
MachineControlPlaneLabelName = "cluster.x-k8s.io/control-plane"
30+
// MachineControlPlaneLabel is the label set on machines or related objects that are part of a control plane.
31+
MachineControlPlaneLabel = "cluster.x-k8s.io/control-plane"
3232

3333
// ExcludeNodeDrainingAnnotation annotation explicitly skips node draining if set.
3434
ExcludeNodeDrainingAnnotation = "machine.cluster.x-k8s.io/exclude-node-draining"
3535

3636
// ExcludeWaitForNodeVolumeDetachAnnotation annotation explicitly skips the waiting for node volume detaching if set.
3737
ExcludeWaitForNodeVolumeDetachAnnotation = "machine.cluster.x-k8s.io/exclude-wait-for-node-volume-detach"
3838

39-
// MachineSetLabelName is the label set on machines if they're controlled by MachineSet.
40-
MachineSetLabelName = "cluster.x-k8s.io/set-name"
39+
// MachineSetNameLabel is the label set on machines if they're controlled by MachineSet.
40+
MachineSetNameLabel = "cluster.x-k8s.io/set-name"
4141

42-
// MachineDeploymentLabelName is the label set on machines if they're controlled by MachineDeployment.
43-
MachineDeploymentLabelName = "cluster.x-k8s.io/deployment-name"
42+
// MachineDeploymentNameLabel is the label set on machines if they're controlled by MachineDeployment.
43+
MachineDeploymentNameLabel = "cluster.x-k8s.io/deployment-name"
4444

4545
// MachineControlPlaneNameLabel is the label set on machines if they're controlled by a ControlPlane.
4646
MachineControlPlaneNameLabel = "cluster.x-k8s.io/control-plane-name"

api/v1beta1/machine_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (m *Machine) Default() {
5050
if m.Labels == nil {
5151
m.Labels = make(map[string]string)
5252
}
53-
m.Labels[ClusterLabelName] = m.Spec.ClusterName
53+
m.Labels[ClusterNameLabel] = m.Spec.ClusterName
5454

5555
if m.Spec.Bootstrap.ConfigRef != nil && m.Spec.Bootstrap.ConfigRef.Namespace == "" {
5656
m.Spec.Bootstrap.ConfigRef.Namespace = m.Namespace

api/v1beta1/machine_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestMachineDefault(t *testing.T) {
4242
t.Run("for Machine", utildefaulting.DefaultValidateTest(m))
4343
m.Default()
4444

45-
g.Expect(m.Labels[ClusterLabelName]).To(Equal(m.Spec.ClusterName))
45+
g.Expect(m.Labels[ClusterNameLabel]).To(Equal(m.Spec.ClusterName))
4646
g.Expect(m.Spec.Bootstrap.ConfigRef.Namespace).To(Equal(m.Namespace))
4747
g.Expect(m.Spec.InfrastructureRef.Namespace).To(Equal(m.Namespace))
4848
g.Expect(*m.Spec.Version).To(Equal("v1.17.5"))

api/v1beta1/machinedeployment_webhook.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func PopulateDefaultsMachineDeployment(d *MachineDeployment) {
149149
if d.Labels == nil {
150150
d.Labels = make(map[string]string)
151151
}
152-
d.Labels[ClusterLabelName] = d.Spec.ClusterName
152+
d.Labels[ClusterNameLabel] = d.Spec.ClusterName
153153

154154
if d.Spec.MinReadySeconds == nil {
155155
d.Spec.MinReadySeconds = pointer.Int32(0)
@@ -197,10 +197,10 @@ func PopulateDefaultsMachineDeployment(d *MachineDeployment) {
197197
// If no selector has been provided, add label and selector for the
198198
// MachineDeployment's name as a default way of providing uniqueness.
199199
if len(d.Spec.Selector.MatchLabels) == 0 && len(d.Spec.Selector.MatchExpressions) == 0 {
200-
d.Spec.Selector.MatchLabels[MachineDeploymentLabelName] = d.Name
201-
d.Spec.Template.Labels[MachineDeploymentLabelName] = d.Name
200+
d.Spec.Selector.MatchLabels[MachineDeploymentNameLabel] = d.Name
201+
d.Spec.Template.Labels[MachineDeploymentNameLabel] = d.Name
202202
}
203203
// Make sure selector and template to be in the same cluster.
204-
d.Spec.Selector.MatchLabels[ClusterLabelName] = d.Spec.ClusterName
205-
d.Spec.Template.Labels[ClusterLabelName] = d.Spec.ClusterName
204+
d.Spec.Selector.MatchLabels[ClusterNameLabel] = d.Spec.ClusterName
205+
d.Spec.Template.Labels[ClusterNameLabel] = d.Spec.ClusterName
206206
}

api/v1beta1/machinedeployment_webhook_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ func TestMachineDeploymentDefault(t *testing.T) {
4444
t.Run("for MachineDeployment", utildefaulting.DefaultValidateTest(md))
4545
md.Default()
4646

47-
g.Expect(md.Labels[ClusterLabelName]).To(Equal(md.Spec.ClusterName))
47+
g.Expect(md.Labels[ClusterNameLabel]).To(Equal(md.Spec.ClusterName))
4848
g.Expect(md.Spec.MinReadySeconds).To(Equal(pointer.Int32(0)))
4949
g.Expect(md.Spec.RevisionHistoryLimit).To(Equal(pointer.Int32(1)))
5050
g.Expect(md.Spec.ProgressDeadlineSeconds).To(Equal(pointer.Int32(600)))
5151
g.Expect(md.Spec.Strategy).ToNot(BeNil())
52-
g.Expect(md.Spec.Selector.MatchLabels).To(HaveKeyWithValue(MachineDeploymentLabelName, "test-md"))
53-
g.Expect(md.Spec.Template.Labels).To(HaveKeyWithValue(MachineDeploymentLabelName, "test-md"))
52+
g.Expect(md.Spec.Selector.MatchLabels).To(HaveKeyWithValue(MachineDeploymentNameLabel, "test-md"))
53+
g.Expect(md.Spec.Template.Labels).To(HaveKeyWithValue(MachineDeploymentNameLabel, "test-md"))
5454
g.Expect(md.Spec.Strategy.Type).To(Equal(RollingUpdateMachineDeploymentStrategyType))
5555
g.Expect(md.Spec.Strategy.RollingUpdate).ToNot(BeNil())
5656
g.Expect(md.Spec.Strategy.RollingUpdate.MaxSurge.IntValue()).To(Equal(1))
@@ -259,8 +259,8 @@ func TestMachineDeploymentWithSpec(t *testing.T) {
259259
}
260260

261261
md.Default()
262-
g.Expect(md.Spec.Selector.MatchLabels).To(HaveKeyWithValue(ClusterLabelName, "test-cluster"))
263-
g.Expect(md.Spec.Template.Labels).To(HaveKeyWithValue(ClusterLabelName, "test-cluster"))
262+
g.Expect(md.Spec.Selector.MatchLabels).To(HaveKeyWithValue(ClusterNameLabel, "test-cluster"))
263+
g.Expect(md.Spec.Template.Labels).To(HaveKeyWithValue(ClusterNameLabel, "test-cluster"))
264264
}
265265

266266
func TestMachineDeploymentClusterNameImmutable(t *testing.T) {

api/v1beta1/machinehealthcheck_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (m *MachineHealthCheck) Default() {
6767
if m.Labels == nil {
6868
m.Labels = make(map[string]string)
6969
}
70-
m.Labels[ClusterLabelName] = m.Spec.ClusterName
70+
m.Labels[ClusterNameLabel] = m.Spec.ClusterName
7171

7272
if m.Spec.MaxUnhealthy == nil {
7373
defaultMaxUnhealthy := intstr.FromString("100%")
@@ -123,7 +123,7 @@ func (m *MachineHealthCheck) validate(old *MachineHealthCheck) error {
123123
)
124124
}
125125

126-
if clusterName, ok := m.Spec.Selector.MatchLabels[ClusterLabelName]; ok && clusterName != m.Spec.ClusterName {
126+
if clusterName, ok := m.Spec.Selector.MatchLabels[ClusterNameLabel]; ok && clusterName != m.Spec.ClusterName {
127127
allErrs = append(
128128
allErrs,
129129
field.Invalid(specPath.Child("selector"), m.Spec.Selector, "cannot specify a cluster selector other than the one specified by ClusterName"))

api/v1beta1/machinehealthcheck_webhook_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestMachineHealthCheckDefault(t *testing.T) {
5050
t.Run("for MachineHealthCheck", utildefaulting.DefaultValidateTest(mhc))
5151
mhc.Default()
5252

53-
g.Expect(mhc.Labels[ClusterLabelName]).To(Equal(mhc.Spec.ClusterName))
53+
g.Expect(mhc.Labels[ClusterNameLabel]).To(Equal(mhc.Spec.ClusterName))
5454
g.Expect(mhc.Spec.MaxUnhealthy.String()).To(Equal("100%"))
5555
g.Expect(mhc.Spec.NodeStartupTimeout).ToNot(BeNil())
5656
g.Expect(*mhc.Spec.NodeStartupTimeout).To(Equal(metav1.Duration{Duration: 10 * time.Minute}))
@@ -378,7 +378,7 @@ func TestMachineHealthCheckClusterNameSelectorValidation(t *testing.T) {
378378
ClusterName: "foo",
379379
Selector: metav1.LabelSelector{
380380
MatchLabels: map[string]string{
381-
ClusterLabelName: "bar",
381+
ClusterNameLabel: "bar",
382382
"baz": "qux",
383383
},
384384
},
@@ -394,9 +394,9 @@ func TestMachineHealthCheckClusterNameSelectorValidation(t *testing.T) {
394394
g.Expect(err).To(HaveOccurred())
395395
g.Expect(err.Error()).To(ContainSubstring("cannot specify a cluster selector other than the one specified by ClusterName"))
396396

397-
mhc.Spec.Selector.MatchLabels[ClusterLabelName] = "foo"
397+
mhc.Spec.Selector.MatchLabels[ClusterNameLabel] = "foo"
398398
g.Expect(mhc.validate(nil)).To(Succeed())
399-
delete(mhc.Spec.Selector.MatchLabels, ClusterLabelName)
399+
delete(mhc.Spec.Selector.MatchLabels, ClusterNameLabel)
400400
g.Expect(mhc.validate(nil)).To(Succeed())
401401
}
402402

api/v1beta1/machineset_webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (m *MachineSet) Default() {
4848
if m.Labels == nil {
4949
m.Labels = make(map[string]string)
5050
}
51-
m.Labels[ClusterLabelName] = m.Spec.ClusterName
51+
m.Labels[ClusterNameLabel] = m.Spec.ClusterName
5252

5353
if m.Spec.DeletePolicy == "" {
5454
randomPolicy := string(RandomMachineSetDeletePolicy)
@@ -64,8 +64,8 @@ func (m *MachineSet) Default() {
6464
}
6565

6666
if len(m.Spec.Selector.MatchLabels) == 0 && len(m.Spec.Selector.MatchExpressions) == 0 {
67-
m.Spec.Selector.MatchLabels[MachineSetLabelName] = m.Name
68-
m.Spec.Template.Labels[MachineSetLabelName] = m.Name
67+
m.Spec.Selector.MatchLabels[MachineSetNameLabel] = m.Name
68+
m.Spec.Template.Labels[MachineSetNameLabel] = m.Name
6969
}
7070

7171
if m.Spec.Template.Spec.Version != nil && !strings.HasPrefix(*m.Spec.Template.Spec.Version, "v") {

0 commit comments

Comments
 (0)