Skip to content

Commit 1f4a6b0

Browse files
committed
chore: better naming of vars (from code review)
Signed-off-by: Tarun Gupta Akirala <[email protected]>
1 parent 55fd1f3 commit 1f4a6b0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

api/v1beta1/cluster_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
// cleanup the cluster resources when a Cluster is being deleted.
3636
ClusterFinalizer = "cluster.cluster.x-k8s.io"
3737

38-
// KindCluster represents the Kind of Cluster.
39-
KindCluster = "Cluster"
38+
// ClusterKind represents the Kind of Cluster.
39+
ClusterKind = "Cluster"
4040
)
4141

4242
// ANCHOR: ClusterSpec

api/v1beta1/clusterclass_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"k8s.io/apimachinery/pkg/util/intstr"
2626
)
2727

28-
// KindClusterClass represents the Kind of ClusterClass.
29-
const KindClusterClass = "ClusterClass"
28+
// ClusterClassKind represents the Kind of ClusterClass.
29+
const ClusterClassKind = "ClusterClass"
3030

3131
// +kubebuilder:object:root=true
3232
// +kubebuilder:resource:path=clusterclasses,shortName=cc,scope=Namespaced,categories=cluster-api

cmd/clusterctl/client/cluster/mover.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ func patchCluster(proxy Proxy, n *node, patch client.Patch, mutators []ResourceM
602602
// Get the ClusterClass from the server
603603
clusterObj := &unstructured.Unstructured{}
604604
clusterObj.SetAPIVersion(clusterv1.GroupVersion.String())
605-
clusterObj.SetKind(clusterv1.KindCluster)
605+
clusterObj.SetKind(clusterv1.ClusterKind)
606606
clusterObj.SetName(n.identity.Name)
607607
clusterObj.SetNamespace(n.identity.Namespace)
608608
for _, mutator := range mutators {
@@ -631,7 +631,7 @@ func pauseClusterClass(proxy Proxy, n *node, pause bool, mutators []ResourceMuta
631631
// Get the ClusterClass from the server
632632
clusterClass := &unstructured.Unstructured{}
633633
clusterClass.SetAPIVersion(clusterv1.GroupVersion.String())
634-
clusterClass.SetKind(clusterv1.KindClusterClass)
634+
clusterClass.SetKind(clusterv1.ClusterClassKind)
635635
clusterClass.SetName(n.identity.Name)
636636
clusterClass.SetNamespace(n.identity.Namespace)
637637
for _, mutator := range mutators {
@@ -774,12 +774,12 @@ func (o *objectMover) createGroup(group moveGroup, toProxy Proxy, mutators []Res
774774

775775
// Maintain a cache of namespaces that have been verified to already exist.
776776
// Nb. This prevents us from making repetitive (and expensive) calls in listing all namespaces to ensure a namespace exists before creating a resource.
777-
ensuredNamespaces := sets.New[string]()
777+
existingNamespaces := sets.New[string]()
778778
for _, nodeToCreate := range group {
779779
// Creates the Kubernetes object corresponding to the nodeToCreate.
780780
// Nb. The operation is wrapped in a retry loop to make move more resilient to unexpected conditions.
781781
err := retryWithExponentialBackoff(createTargetObjectBackoff, func() error {
782-
return o.createTargetObject(nodeToCreate, toProxy, mutators, ensuredNamespaces)
782+
return o.createTargetObject(nodeToCreate, toProxy, mutators, existingNamespaces)
783783
})
784784
if err != nil {
785785
errList = append(errList, err)
@@ -838,7 +838,7 @@ func (o *objectMover) restoreGroup(group moveGroup, toProxy Proxy) error {
838838
}
839839

840840
// createTargetObject creates the Kubernetes object in the target Management cluster corresponding to the object graph node, taking care of restoring the OwnerReference with the owner nodes, if any.
841-
func (o *objectMover) createTargetObject(nodeToCreate *node, toProxy Proxy, mutators []ResourceMutatorFunc, ensuredNamespaces sets.Set[string]) error {
841+
func (o *objectMover) createTargetObject(nodeToCreate *node, toProxy Proxy, mutators []ResourceMutatorFunc, existingNamespaces sets.Set[string]) error {
842842
log := logf.Log
843843
log.V(1).Info("Creating", nodeToCreate.identity.Kind, nodeToCreate.identity.Name, "Namespace", nodeToCreate.identity.Namespace)
844844

@@ -890,7 +890,7 @@ func (o *objectMover) createTargetObject(nodeToCreate *node, toProxy Proxy, muta
890890
mutator(obj)
891891
}
892892
// Applying mutators MAY change the namespace, so ensure the namespace exists before creating the resource.
893-
if !nodeToCreate.isGlobal && !ensuredNamespaces.Has(obj.GetNamespace()) {
893+
if !nodeToCreate.isGlobal && !existingNamespaces.Has(obj.GetNamespace()) {
894894
if err = o.ensureNamespace(toProxy, obj.GetNamespace()); err != nil {
895895
return err
896896
}

0 commit comments

Comments
 (0)