Skip to content

Commit

Permalink
Fix inconsistency by updating constant 'ProviderLabelName' to 'Provid…
Browse files Browse the repository at this point in the history
…erLabel'

Signed-off-by: Chirayu Kapoor <dev.csociety@gmail.com>
  • Loading branch information
chiukapoor committed Nov 25, 2022
1 parent 1f69025 commit 124f2a2
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const (
// update that disallows a pre-existing Cluster to be populated with Topology information and Class.
ClusterTopologyUnsafeUpdateClassNameAnnotation = "unsafe.topology.cluster.x-k8s.io/disable-update-class-name-check"

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

// ClusterNameAnnotation is the annotation set on nodes identifying the name of the cluster the node belongs to.
ClusterNameAnnotation = "cluster.x-k8s.io/cluster-name"
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (p *providerComponents) Delete(options DeleteOptions) error {
// We want that the delete operation is able to clean-up everything.
labels := map[string]string{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: options.Provider.ManifestLabel(),
clusterv1.ProviderLabel: options.Provider.ManifestLabel(),
}

namespaces := []string{options.Provider.Namespace}
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/cluster/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

func Test_providerComponents_Delete(t *testing.T) {
labels := map[string]string{
clusterv1.ProviderLabelName: "infrastructure-infra",
clusterv1.ProviderLabel: "infrastructure-infra",
}

crd := unstructured.Unstructured{}
Expand Down Expand Up @@ -340,7 +340,7 @@ func Test_providerComponents_DeleteCoreProviderWebhookNamespace(t *testing.T) {

func Test_providerComponents_Create(t *testing.T) {
labelsOne := map[string]string{
clusterv1.ProviderLabelName: "infrastructure-infra",
clusterv1.ProviderLabel: "infrastructure-infra",
}
commonObjects := []client.Object{
// Namespace for the provider
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (k *proxy) ListResources(labels map[string]string, namespaces ...string) ([
}
for _, crd := range crdList.Items {
component, isCoreComponent := labels[clusterctlv1.ClusterctlCoreLabelName]
_, isProviderResource := crd.Labels[clusterv1.ProviderLabelName]
_, isProviderResource := crd.Labels[clusterv1.ProviderLabel]
if (isCoreComponent && component == clusterctlv1.ClusterctlCoreLabelCertManagerValue) || isProviderResource {
for _, version := range crd.Spec.Versions {
crdsToExclude.Insert(metav1.GroupVersionKind{
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func (u *providerUpgrader) scaleDownProvider(provider clusterctlv1.Provider) err
client.InNamespace(provider.Namespace),
client.MatchingLabels{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: provider.ManifestLabel(),
clusterv1.ProviderLabel: provider.ManifestLabel(),
}); err != nil {
return errors.Wrapf(err, "failed to list Deployments for provider %s", provider.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/upgrader_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func fakeProvider(name string, providerType clusterctlv1.ProviderType, version,
Name: clusterctlv1.ManifestLabel(name, providerType),
Labels: map[string]string{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: clusterctlv1.ManifestLabel(name, providerType),
clusterv1.ProviderLabel: clusterctlv1.ManifestLabel(name, providerType),
clusterctlv1.ClusterctlCoreLabelName: clusterctlv1.ClusterctlCoreLabelInventoryValue,
},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/repository/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,6 @@ func addCommonLabels(objs []unstructured.Unstructured, provider config.Provider)
func getCommonLabels(provider config.Provider) map[string]string {
return map[string]string{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: provider.ManifestLabel(),
clusterv1.ProviderLabel: provider.ManifestLabel(),
}
}
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/repository/components_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func Test_componentsClient_Get(t *testing.T) {
}

for _, o := range got.Objs() {
for _, v := range []string{clusterctlv1.ClusterctlLabelName, clusterv1.ProviderLabelName} {
for _, v := range []string{clusterctlv1.ClusterctlLabelName, clusterv1.ProviderLabel} {
gs.Expect(o.GetLabels()).To(HaveKey(v))
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/repository/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ func Test_addCommonLabels(t *testing.T) {
"metadata": map[string]interface{}{
"labels": map[string]interface{}{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: "infrastructure-provider",
clusterv1.ProviderLabel: "infrastructure-provider",
},
},
},
Expand Down Expand Up @@ -967,7 +967,7 @@ func TestAlterComponents(t *testing.T) {
"metadata": map[string]interface{}{
"labels": map[string]interface{}{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: "infrastructure-provider",
clusterv1.ProviderLabel: "infrastructure-provider",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func fakeProvider(name string, providerType clusterctlv1.ProviderType, version,
Name: clusterctlv1.ManifestLabel(name, providerType),
Labels: map[string]string{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: clusterctlv1.ManifestLabel(name, providerType),
clusterv1.ProviderLabel: clusterctlv1.ManifestLabel(name, providerType),
clusterctlv1.ClusterctlCoreLabelName: clusterctlv1.ClusterctlCoreLabelInventoryValue,
},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/internal/test/fake_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (f *FakeProxy) WithProviderInventory(name string, providerType clusterctlv1
Name: clusterctlv1.ManifestLabel(name, providerType),
Labels: map[string]string{
clusterctlv1.ClusterctlLabelName: "",
clusterv1.ProviderLabelName: clusterctlv1.ManifestLabel(name, providerType),
clusterv1.ProviderLabel: clusterctlv1.ManifestLabel(name, providerType),
clusterctlv1.ClusterctlCoreLabelName: clusterctlv1.ClusterctlCoreLabelInventoryValue,
},
},
Expand Down
6 changes: 3 additions & 3 deletions hack/tools/tilt-prepare/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,14 +870,14 @@ func getProviderObj(prefix string, objs []unstructured.Unstructured) (*unstructu
}

namespace = objs[i].GetName()
manifestLabel = objs[i].GetLabels()[clusterv1.ProviderLabelName]
manifestLabel = objs[i].GetLabels()[clusterv1.ProviderLabel]
break
}

if manifestLabel == "" {
return nil, errors.Errorf(
"Could not find any Namespace object with label %s and therefore failed to deduce provider name and type",
clusterv1.ProviderLabelName)
clusterv1.ProviderLabel)
}

providerType := string(clusterctlv1.CoreProviderType)
Expand Down Expand Up @@ -912,7 +912,7 @@ func getProviderObj(prefix string, objs []unstructured.Unstructured) (*unstructu
Name: manifestLabel,
Namespace: namespace,
Labels: map[string]string{
clusterv1.ProviderLabelName: manifestLabel,
clusterv1.ProviderLabel: manifestLabel,
clusterctlv1.ClusterctlLabelName: "",
clusterctlv1.ClusterctlCoreLabelName: clusterctlv1.ClusterctlCoreLabelInventoryValue,
},
Expand Down
2 changes: 1 addition & 1 deletion test/framework/alltypes_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func dumpObject(resource runtime.Object, logPath string) {
// capiProviderOptions returns a set of ListOptions that allows to identify all the objects belonging to Cluster API providers.
func capiProviderOptions() []client.ListOption {
return []client.ListOption{
client.HasLabels{clusterv1.ProviderLabelName},
client.HasLabels{clusterv1.ProviderLabel},
}
}

Expand Down

0 comments on commit 124f2a2

Please sign in to comment.