diff --git a/pkg/api/meta/meta.go b/pkg/api/meta/meta.go index 81403393f..42e21c1df 100644 --- a/pkg/api/meta/meta.go +++ b/pkg/api/meta/meta.go @@ -130,7 +130,6 @@ func AsPartialObjectMetadata(m metav1.Object) *metav1.PartialObjectMetadata { Annotations: m.GetAnnotations(), OwnerReferences: m.GetOwnerReferences(), Finalizers: m.GetFinalizers(), - ZZZ_DeprecatedClusterName: m.GetZZZ_DeprecatedClusterName(), ManagedFields: m.GetManagedFields(), }, } diff --git a/pkg/api/validation/objectmeta.go b/pkg/api/validation/objectmeta.go index 9a1fe0731..8b77c641c 100644 --- a/pkg/api/validation/objectmeta.go +++ b/pkg/api/validation/objectmeta.go @@ -40,9 +40,6 @@ var BannedOwners = map[schema.GroupVersionKind]struct{}{ {Group: "", Version: "v1", Kind: "Event"}: {}, } -// ValidateZZZ_DeprecatedClusterName can be used to check whether the given cluster name is valid. -var ValidateZZZ_DeprecatedClusterName = NameIsDNS1035Label - // ValidateAnnotations validates that a set of annotations are correctly defined. func ValidateAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} @@ -184,11 +181,6 @@ func ValidateObjectMetaAccessor(meta metav1.Object, requiresNamespace bool, name allErrs = append(allErrs, field.Forbidden(fldPath.Child("namespace"), "not allowed on this type")) } } - if len(meta.GetZZZ_DeprecatedClusterName()) != 0 { - for _, msg := range ValidateZZZ_DeprecatedClusterName(meta.GetZZZ_DeprecatedClusterName(), false) { - allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterName"), meta.GetZZZ_DeprecatedClusterName(), msg)) - } - } allErrs = append(allErrs, ValidateNonnegativeField(meta.GetGeneration(), fldPath.Child("generation"))...) allErrs = append(allErrs, v1validation.ValidateLabels(meta.GetLabels(), fldPath.Child("labels"))...) @@ -261,7 +253,6 @@ func ValidateObjectMetaAccessorUpdate(newMeta, oldMeta metav1.Object, fldPath *f allErrs = append(allErrs, ValidateImmutableField(newMeta.GetCreationTimestamp(), oldMeta.GetCreationTimestamp(), fldPath.Child("creationTimestamp"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionTimestamp(), oldMeta.GetDeletionTimestamp(), fldPath.Child("deletionTimestamp"))...) allErrs = append(allErrs, ValidateImmutableField(newMeta.GetDeletionGracePeriodSeconds(), oldMeta.GetDeletionGracePeriodSeconds(), fldPath.Child("deletionGracePeriodSeconds"))...) - allErrs = append(allErrs, ValidateImmutableField(newMeta.GetZZZ_DeprecatedClusterName(), oldMeta.GetZZZ_DeprecatedClusterName(), fldPath.Child("clusterName"))...) allErrs = append(allErrs, v1validation.ValidateLabels(newMeta.GetLabels(), fldPath.Child("labels"))...) allErrs = append(allErrs, ValidateAnnotations(newMeta.GetAnnotations(), fldPath.Child("annotations"))...) diff --git a/pkg/apis/meta/v1/helpers_test.go b/pkg/apis/meta/v1/helpers_test.go index b12cc8a30..af6d9cf7d 100644 --- a/pkg/apis/meta/v1/helpers_test.go +++ b/pkg/apis/meta/v1/helpers_test.go @@ -205,7 +205,6 @@ func TestResetObjectMetaForStatus(t *testing.T) { existingMeta.SetUID(types.UID("")) existingMeta.SetName("") existingMeta.SetNamespace("") - existingMeta.SetZZZ_DeprecatedClusterName("") existingMeta.SetCreationTimestamp(Time{}) existingMeta.SetDeletionTimestamp(nil) existingMeta.SetDeletionGracePeriodSeconds(nil) diff --git a/pkg/apis/meta/v1/meta.go b/pkg/apis/meta/v1/meta.go index 1ea90de1e..92d3ed5e0 100644 --- a/pkg/apis/meta/v1/meta.go +++ b/pkg/apis/meta/v1/meta.go @@ -59,8 +59,6 @@ type Object interface { SetFinalizers(finalizers []string) GetOwnerReferences() []OwnerReference SetOwnerReferences([]OwnerReference) - GetZZZ_DeprecatedClusterName() string - SetZZZ_DeprecatedClusterName(clusterName string) GetManagedFields() []ManagedFieldsEntry SetManagedFields(managedFields []ManagedFieldsEntry) } @@ -172,10 +170,6 @@ func (meta *ObjectMeta) GetOwnerReferences() []OwnerReference { return m func (meta *ObjectMeta) SetOwnerReferences(references []OwnerReference) { meta.OwnerReferences = references } -func (meta *ObjectMeta) GetZZZ_DeprecatedClusterName() string { return meta.ZZZ_DeprecatedClusterName } -func (meta *ObjectMeta) SetZZZ_DeprecatedClusterName(clusterName string) { - meta.ZZZ_DeprecatedClusterName = clusterName -} func (meta *ObjectMeta) GetManagedFields() []ManagedFieldsEntry { return meta.ManagedFields } func (meta *ObjectMeta) SetManagedFields(managedFields []ManagedFieldsEntry) { meta.ManagedFields = managedFields diff --git a/pkg/apis/meta/v1/types.go b/pkg/apis/meta/v1/types.go index eb071d410..5b1ba1a88 100644 --- a/pkg/apis/meta/v1/types.go +++ b/pkg/apis/meta/v1/types.go @@ -254,14 +254,9 @@ type ObjectMeta struct { // +patchStrategy=merge Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"` - // Deprecated: ClusterName is a legacy field that was always cleared by - // the system and never used; it will be removed completely in 1.25. - // - // The name in the go struct is changed to help clients detect - // accidental use. - // - // +optional - ZZZ_DeprecatedClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"` + // Tombstone: ClusterName was a legacy field that was always cleared by + // the system and never used. + // ClusterName string `json:"clusterName,omitempty" protobuf:"bytes,15,opt,name=clusterName"` // ManagedFields maps workflow-id and version to the set of fields // that are managed by that workflow. This is mostly for internal diff --git a/pkg/apis/meta/v1/unstructured/unstructured.go b/pkg/apis/meta/v1/unstructured/unstructured.go index f0fad90fd..a499eee8e 100644 --- a/pkg/apis/meta/v1/unstructured/unstructured.go +++ b/pkg/apis/meta/v1/unstructured/unstructured.go @@ -444,18 +444,6 @@ func (u *Unstructured) SetFinalizers(finalizers []string) { u.setNestedStringSlice(finalizers, "metadata", "finalizers") } -func (u *Unstructured) GetZZZ_DeprecatedClusterName() string { - return getNestedString(u.Object, "metadata", "clusterName") -} - -func (u *Unstructured) SetZZZ_DeprecatedClusterName(clusterName string) { - if len(clusterName) == 0 { - RemoveNestedField(u.Object, "metadata", "clusterName") - return - } - u.setNestedField(clusterName, "metadata", "clusterName") -} - func (u *Unstructured) GetManagedFields() []metav1.ManagedFieldsEntry { items, found, err := NestedSlice(u.Object, "metadata", "managedFields") if !found || err != nil { diff --git a/pkg/apis/meta/v1/unstructured/unstructured_test.go b/pkg/apis/meta/v1/unstructured/unstructured_test.go index 81372162a..be9a48f71 100644 --- a/pkg/apis/meta/v1/unstructured/unstructured_test.go +++ b/pkg/apis/meta/v1/unstructured/unstructured_test.go @@ -105,7 +105,6 @@ func TestUnstructuredMetadataOmitempty(t *testing.T) { u.SetAnnotations(nil) u.SetOwnerReferences(nil) u.SetFinalizers(nil) - u.SetZZZ_DeprecatedClusterName("") u.SetManagedFields(nil) gotMetadata, _, err := unstructured.NestedFieldNoCopy(u.UnstructuredContent(), "metadata") @@ -147,6 +146,5 @@ func setObjectMetaUsingAccessors(u, uCopy *unstructured.Unstructured) { uCopy.SetAnnotations(u.GetAnnotations()) uCopy.SetOwnerReferences(u.GetOwnerReferences()) uCopy.SetFinalizers(u.GetFinalizers()) - uCopy.SetZZZ_DeprecatedClusterName(u.GetZZZ_DeprecatedClusterName()) uCopy.SetManagedFields(u.GetManagedFields()) } diff --git a/pkg/test/apis_meta_v1_unstructed_unstructure_test.go b/pkg/test/apis_meta_v1_unstructed_unstructure_test.go index 0ef51a035..b1a50a41a 100644 --- a/pkg/test/apis_meta_v1_unstructed_unstructure_test.go +++ b/pkg/test/apis_meta_v1_unstructed_unstructure_test.go @@ -170,7 +170,6 @@ func TestUnstructuredGetters(t *testing.T) { "finalizer.1", "finalizer.2", }, - "clusterName": "cluster123", }, }, } @@ -245,9 +244,6 @@ func TestUnstructuredGetters(t *testing.T) { if got, want := unstruct.GetFinalizers(), []string{"finalizer.1", "finalizer.2"}; !reflect.DeepEqual(got, want) { t.Errorf("GetFinalizers()=%v, want %v", got, want) } - if got, want := unstruct.GetZZZ_DeprecatedClusterName(), "cluster123"; got != want { - t.Errorf("GetZZZ_DeprecatedClusterName()=%v, want %v", got, want) - } if got, want := unstruct.GetDeletionGracePeriodSeconds(), &ten; !reflect.DeepEqual(got, want) { t.Errorf("GetDeletionGracePeriodSeconds()=%v, want %v", got, want) } @@ -302,7 +298,6 @@ func TestUnstructuredSetters(t *testing.T) { "finalizer.1", "finalizer.2", }, - "clusterName": "cluster123", }, }, } @@ -338,7 +333,6 @@ func TestUnstructuredSetters(t *testing.T) { } unstruct.SetOwnerReferences(newOwnerReferences) unstruct.SetFinalizers([]string{"finalizer.1", "finalizer.2"}) - unstruct.SetZZZ_DeprecatedClusterName("cluster123") unstruct.SetDeletionGracePeriodSeconds(&ten) unstruct.SetGeneration(ten) @@ -534,7 +528,6 @@ func TestAccessorMethods(t *testing.T) { {accessor: "Annotations", val: map[string]string{"foo": "bar"}}, {accessor: "Finalizers", val: []string{"foo"}}, {accessor: "OwnerReferences", val: []metav1.OwnerReference{{Name: "foo"}}}, - {accessor: "ZZZ_DeprecatedClusterName", val: "foo"}, } for i, test := range tests { t.Logf("evaluating test %d (%s)", i, test.accessor)