Skip to content

Commit 440a003

Browse files
committed
clusterv1.ObjectMeta should only expose labels and annotations
Signed-off-by: Vince Prignano <[email protected]>
1 parent 5cd1132 commit 440a003

File tree

10 files changed

+81
-230
lines changed

10 files changed

+81
-230
lines changed

api/v1alpha3/common_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ type ObjectMeta struct {
105105
// Cannot be updated.
106106
// More info: http://kubernetes.io/docs/user-guide/identifiers#names
107107
// +optional
108+
//
109+
// Deprecated: This field has no function and is going to be removed in a next release.
108110
Name string `json:"name,omitempty"`
109111

110112
// GenerateName is an optional prefix, used by the server, to generate a unique
@@ -123,6 +125,8 @@ type ObjectMeta struct {
123125
// Applied only if Name is not specified.
124126
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency
125127
// +optional
128+
//
129+
// Deprecated: This field has no function and is going to be removed in a next release.
126130
GenerateName string `json:"generateName,omitempty"`
127131

128132
// Namespace defines the space within each name must be unique. An empty namespace is
@@ -134,6 +138,8 @@ type ObjectMeta struct {
134138
// Cannot be updated.
135139
// More info: http://kubernetes.io/docs/user-guide/namespaces
136140
// +optional
141+
//
142+
// Deprecated: This field has no function and is going to be removed in a next release.
137143
Namespace string `json:"namespace,omitempty"`
138144

139145
// Map of string keys and values that can be used to organize and categorize
@@ -157,5 +163,7 @@ type ObjectMeta struct {
157163
// +optional
158164
// +patchMergeKey=uid
159165
// +patchStrategy=merge
166+
//
167+
// Deprecated: This field has no function and is going to be removed in a next release.
160168
OwnerReferences []metav1.OwnerReference `json:"ownerReferences,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
161169
}

api/v1alpha3/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,7 @@ func Convert_v1alpha4_MachineHealthCheckSpec_To_v1alpha3_MachineHealthCheckSpec(
233233
func Convert_v1alpha3_ClusterStatus_To_v1alpha4_ClusterStatus(in *ClusterStatus, out *v1alpha4.ClusterStatus, s apiconversion.Scope) error {
234234
return autoConvert_v1alpha3_ClusterStatus_To_v1alpha4_ClusterStatus(in, out, s)
235235
}
236+
237+
func Convert_v1alpha3_ObjectMeta_To_v1alpha4_ObjectMeta(in *ObjectMeta, out *v1alpha4.ObjectMeta, s apiconversion.Scope) error {
238+
return autoConvert_v1alpha3_ObjectMeta_To_v1alpha4_ObjectMeta(in, out, s)
239+
}

api/v1alpha3/conversion_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ func TestFuzzyConversion(t *testing.T) {
5454
Scheme: scheme,
5555
Hub: &v1alpha4.MachineSet{},
5656
Spoke: &MachineSet{},
57-
FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs},
57+
FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs, CustomObjectMetaFuzzFunc},
5858
}))
5959

6060
t.Run("for MachineDeployment", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
6161
Scheme: scheme,
6262
Hub: &v1alpha4.MachineDeployment{},
6363
Spoke: &MachineDeployment{},
64-
FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs},
64+
FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs, CustomObjectMetaFuzzFunc},
6565
}))
6666

6767
t.Run("for MachineHealthCheckSpec", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
@@ -71,6 +71,23 @@ func TestFuzzyConversion(t *testing.T) {
7171
}))
7272
}
7373

74+
func CustomObjectMetaFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} {
75+
return []interface{}{
76+
CustomObjectMetaFuzzer,
77+
}
78+
}
79+
80+
func CustomObjectMetaFuzzer(in *ObjectMeta, c fuzz.Continue) {
81+
c.FuzzNoCustom(in)
82+
83+
// These fields have been removed in v1alpha4
84+
// data is going to be lost, so we're forcing zero values here.
85+
in.Name = ""
86+
in.GenerateName = ""
87+
in.Namespace = ""
88+
in.OwnerReferences = nil
89+
}
90+
7491
func BootstrapFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
7592
return []interface{}{
7693
BootstrapFuzzer,

api/v1alpha3/zz_generated.conversion.go

Lines changed: 9 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/common_types.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package v1alpha4
1818

1919
import (
2020
corev1 "k8s.io/api/core/v1"
21-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2221
)
2322

2423
const (
@@ -129,44 +128,6 @@ type MachineAddresses []MachineAddress
129128
// In future versions, controller-tools@v2 might allow overriding the type and validation for embedded
130129
// types. When that happens, this hack should be revisited.
131130
type ObjectMeta struct {
132-
// Name must be unique within a namespace. Is required when creating resources, although
133-
// some resources may allow a client to request the generation of an appropriate name
134-
// automatically. Name is primarily intended for creation idempotence and configuration
135-
// definition.
136-
// Cannot be updated.
137-
// More info: http://kubernetes.io/docs/user-guide/identifiers#names
138-
// +optional
139-
Name string `json:"name,omitempty"`
140-
141-
// GenerateName is an optional prefix, used by the server, to generate a unique
142-
// name ONLY IF the Name field has not been provided.
143-
// If this field is used, the name returned to the client will be different
144-
// than the name passed. This value will also be combined with a unique suffix.
145-
// The provided value has the same validation rules as the Name field,
146-
// and may be truncated by the length of the suffix required to make the value
147-
// unique on the server.
148-
//
149-
// If this field is specified and the generated name exists, the server will
150-
// NOT return a 409 - instead, it will either return 201 Created or 500 with Reason
151-
// ServerTimeout indicating a unique name could not be found in the time allotted, and the client
152-
// should retry (optionally after the time indicated in the Retry-After header).
153-
//
154-
// Applied only if Name is not specified.
155-
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency
156-
// +optional
157-
GenerateName string `json:"generateName,omitempty"`
158-
159-
// Namespace defines the space within each name must be unique. An empty namespace is
160-
// equivalent to the "default" namespace, but "default" is the canonical representation.
161-
// Not all objects are required to be scoped to a namespace - the value of this field for
162-
// those objects will be empty.
163-
//
164-
// Must be a DNS_LABEL.
165-
// Cannot be updated.
166-
// More info: http://kubernetes.io/docs/user-guide/namespaces
167-
// +optional
168-
Namespace string `json:"namespace,omitempty"`
169-
170131
// Map of string keys and values that can be used to organize and categorize
171132
// (scope and select) objects. May match selectors of replication controllers
172133
// and services.
@@ -180,13 +141,4 @@ type ObjectMeta struct {
180141
// More info: http://kubernetes.io/docs/user-guide/annotations
181142
// +optional
182143
Annotations map[string]string `json:"annotations,omitempty"`
183-
184-
// List of objects depended by this object. If ALL objects in the list have
185-
// been deleted, this object will be garbage collected. If this object is managed by a controller,
186-
// then an entry in this list will point to this controller, with the controller field set to true.
187-
// There cannot be more than one managing controller.
188-
// +optional
189-
// +patchMergeKey=uid
190-
// +patchStrategy=merge
191-
OwnerReferences []metav1.OwnerReference `json:"ownerReferences,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
192144
}

api/v1alpha4/zz_generated.deepcopy.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)