Skip to content

Commit

Permalink
Remove ClusterName
Browse files Browse the repository at this point in the history
Kubernetes-commit: 331525670b772eb8956b7f5204078c51c00aaef3
  • Loading branch information
lavalamp authored and k8s-publishing-bot committed Apr 20, 2022
1 parent 5f6d692 commit 430b920
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 46 deletions.
1 change: 0 additions & 1 deletion pkg/api/meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
}
Expand Down
9 changes: 0 additions & 9 deletions pkg/api/validation/objectmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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"))...)
Expand Down Expand Up @@ -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"))...)
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/meta/v1/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/meta/v1/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions pkg/apis/meta/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions pkg/apis/meta/v1/unstructured/unstructured.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/meta/v1/unstructured/unstructured_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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())
}
7 changes: 0 additions & 7 deletions pkg/test/apis_meta_v1_unstructed_unstructure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ func TestUnstructuredGetters(t *testing.T) {
"finalizer.1",
"finalizer.2",
},
"clusterName": "cluster123",
},
},
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -302,7 +298,6 @@ func TestUnstructuredSetters(t *testing.T) {
"finalizer.1",
"finalizer.2",
},
"clusterName": "cluster123",
},
},
}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 430b920

Please sign in to comment.