diff --git a/pkg/apis/policy/v1alpha1/well_known_labels.go b/pkg/apis/policy/v1alpha1/well_known_constants.go similarity index 100% rename from pkg/apis/policy/v1alpha1/well_known_labels.go rename to pkg/apis/policy/v1alpha1/well_known_constants.go diff --git a/pkg/apis/work/v1alpha1/well_known_labels.go b/pkg/apis/work/v1alpha1/well_known_constants.go similarity index 100% rename from pkg/apis/work/v1alpha1/well_known_labels.go rename to pkg/apis/work/v1alpha1/well_known_constants.go diff --git a/pkg/apis/work/v1alpha2/well_known_labels.go b/pkg/apis/work/v1alpha2/well_known_constants.go similarity index 66% rename from pkg/apis/work/v1alpha2/well_known_labels.go rename to pkg/apis/work/v1alpha2/well_known_constants.go index 44b1df42f..902856fe3 100644 --- a/pkg/apis/work/v1alpha2/well_known_labels.go +++ b/pkg/apis/work/v1alpha2/well_known_constants.go @@ -11,14 +11,23 @@ const ( // It will be used to retrieve all Works objects that derived by a specific ClusterResourceBinding object. ClusterResourceBindingReferenceKey = "clusterresourcebinding.karmada.io/key" - // ResourceBindingNamespaceLabel is added to objects to specify associated ResourceBinding's namespace. - ResourceBindingNamespaceLabel = "resourcebinding.karmada.io/namespace" + // ResourceBindingNamespaceAnnotationKey is added to object to describe the associated ResourceBinding's namespace. + // It is added to: + // - Work object: describes the namespace of ResourceBinding which the Work derived from. + // - Manifest in Work object: describes the namespace of ResourceBinding which the manifest derived from. + ResourceBindingNamespaceAnnotationKey = "resourcebinding.karmada.io/namespace" - // ResourceBindingNameLabel is added to objects to specify associated ResourceBinding's name. - ResourceBindingNameLabel = "resourcebinding.karmada.io/name" + // ResourceBindingNameAnnotationKey is added to object to describe the associated ResourceBinding's name. + // It is added to: + // - Work object: describes the name of ResourceBinding which the Work derived from. + // - Manifest in Work object: describes the name of ResourceBinding which the manifest derived from. + ResourceBindingNameAnnotationKey = "resourcebinding.karmada.io/name" - // ClusterResourceBindingLabel is added to objects to specify associated ClusterResourceBinding. - ClusterResourceBindingLabel = "clusterresourcebinding.karmada.io/name" + // ClusterResourceBindingAnnotationKey is added to object to describe associated ClusterResourceBinding's name. + // It is added to: + // - Work object: describes the name of ClusterResourceBinding which the Work derived from. + // - Manifest in Work object: describes the name of ClusterResourceBinding which the manifest derived from. + ClusterResourceBindingAnnotationKey = "clusterresourcebinding.karmada.io/name" // WorkNamespaceLabel is added to objects to specify associated Work's namespace. WorkNamespaceLabel = "work.karmada.io/namespace" diff --git a/pkg/controllers/binding/binding_controller.go b/pkg/controllers/binding/binding_controller.go index 7741c5c1c..e3c904674 100644 --- a/pkg/controllers/binding/binding_controller.go +++ b/pkg/controllers/binding/binding_controller.go @@ -208,8 +208,8 @@ func (c *ResourceBindingController) SetupWithManager(mgr controllerruntime.Manag func(a client.Object) []reconcile.Request { var requests []reconcile.Request annotations := a.GetAnnotations() - crNamespace, namespaceExist := annotations[workv1alpha2.ResourceBindingNamespaceLabel] - crName, nameExist := annotations[workv1alpha2.ResourceBindingNameLabel] + crNamespace, namespaceExist := annotations[workv1alpha2.ResourceBindingNamespaceAnnotationKey] + crName, nameExist := annotations[workv1alpha2.ResourceBindingNameAnnotationKey] if namespaceExist && nameExist { requests = append(requests, reconcile.Request{ NamespacedName: types.NamespacedName{ diff --git a/pkg/controllers/binding/cluster_resource_binding_controller.go b/pkg/controllers/binding/cluster_resource_binding_controller.go index 14c34e259..93716502d 100644 --- a/pkg/controllers/binding/cluster_resource_binding_controller.go +++ b/pkg/controllers/binding/cluster_resource_binding_controller.go @@ -151,7 +151,7 @@ func (c *ClusterResourceBindingController) SetupWithManager(mgr controllerruntim func(a client.Object) []reconcile.Request { var requests []reconcile.Request annotations := a.GetAnnotations() - crbName, nameExist := annotations[workv1alpha2.ClusterResourceBindingLabel] + crbName, nameExist := annotations[workv1alpha2.ClusterResourceBindingAnnotationKey] if nameExist { requests = append(requests, reconcile.Request{ NamespacedName: types.NamespacedName{ diff --git a/pkg/controllers/binding/common.go b/pkg/controllers/binding/common.go index 470a15899..aefcce21b 100644 --- a/pkg/controllers/binding/common.go +++ b/pkg/controllers/binding/common.go @@ -198,13 +198,13 @@ func mergeLabel(workload *unstructured.Unstructured, workNamespace string, bindi func mergeAnnotations(workload *unstructured.Unstructured, binding metav1.Object, scope apiextensionsv1.ResourceScope) map[string]string { annotations := make(map[string]string) if scope == apiextensionsv1.NamespaceScoped { - util.MergeAnnotation(workload, workv1alpha2.ResourceBindingNamespaceLabel, binding.GetNamespace()) - util.MergeAnnotation(workload, workv1alpha2.ResourceBindingNameLabel, binding.GetName()) - annotations[workv1alpha2.ResourceBindingNamespaceLabel] = binding.GetNamespace() - annotations[workv1alpha2.ResourceBindingNameLabel] = binding.GetName() + util.MergeAnnotation(workload, workv1alpha2.ResourceBindingNamespaceAnnotationKey, binding.GetNamespace()) + util.MergeAnnotation(workload, workv1alpha2.ResourceBindingNameAnnotationKey, binding.GetName()) + annotations[workv1alpha2.ResourceBindingNamespaceAnnotationKey] = binding.GetNamespace() + annotations[workv1alpha2.ResourceBindingNameAnnotationKey] = binding.GetName() } else { - util.MergeAnnotation(workload, workv1alpha2.ClusterResourceBindingLabel, binding.GetName()) - annotations[workv1alpha2.ClusterResourceBindingLabel] = binding.GetName() + util.MergeAnnotation(workload, workv1alpha2.ClusterResourceBindingAnnotationKey, binding.GetName()) + annotations[workv1alpha2.ClusterResourceBindingAnnotationKey] = binding.GetName() } return annotations