diff --git a/apis/placement/v1alpha1/zz_generated.deepcopy.go b/apis/placement/v1alpha1/zz_generated.deepcopy.go index bdc1ec2a8..8d79518d2 100644 --- a/apis/placement/v1alpha1/zz_generated.deepcopy.go +++ b/apis/placement/v1alpha1/zz_generated.deepcopy.go @@ -23,7 +23,7 @@ package v1alpha1 import ( "github.com/kubefleet-dev/kubefleet/apis/placement/v1beta1" "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" + runtime "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" ) @@ -161,32 +161,6 @@ func (in *ClusterApprovalRequestList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterResourceEnvelope) DeepCopyInto(out *ClusterResourceEnvelope) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceEnvelope. -func (in *ClusterResourceEnvelope) DeepCopy() *ClusterResourceEnvelope { - if in == nil { - return nil - } - out := new(ClusterResourceEnvelope) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterResourceEnvelope) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResourceOverride) DeepCopyInto(out *ClusterResourceOverride) { *out = *in @@ -622,28 +596,6 @@ func (in *ClusterUpdatingStatus) DeepCopy() *ClusterUpdatingStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EnvelopeSpec) DeepCopyInto(out *EnvelopeSpec) { - *out = *in - if in.Manifests != nil { - in, out := &in.Manifests, &out.Manifests - *out = make(map[string]Manifest, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvelopeSpec. -func (in *EnvelopeSpec) DeepCopy() *EnvelopeSpec { - if in == nil { - return nil - } - out := new(EnvelopeSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JSONPatchOverride) DeepCopyInto(out *JSONPatchOverride) { *out = *in @@ -660,22 +612,6 @@ func (in *JSONPatchOverride) DeepCopy() *JSONPatchOverride { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Manifest) DeepCopyInto(out *Manifest) { - *out = *in - in.Data.DeepCopyInto(&out.Data) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Manifest. -func (in *Manifest) DeepCopy() *Manifest { - if in == nil { - return nil - } - out := new(Manifest) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OverridePolicy) DeepCopyInto(out *OverridePolicy) { *out = *in @@ -802,32 +738,6 @@ func (in *PlacementRef) DeepCopy() *PlacementRef { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceEnvelope) DeepCopyInto(out *ResourceEnvelope) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceEnvelope. -func (in *ResourceEnvelope) DeepCopy() *ResourceEnvelope { - if in == nil { - return nil - } - out := new(ResourceEnvelope) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ResourceEnvelope) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceOverride) DeepCopyInto(out *ResourceOverride) { *out = *in diff --git a/apis/placement/v1alpha1/envelope_types.go b/apis/placement/v1beta1/envelope_types.go similarity index 72% rename from apis/placement/v1alpha1/envelope_types.go rename to apis/placement/v1beta1/envelope_types.go index a8a29fc40..eebe296c6 100644 --- a/apis/placement/v1alpha1/envelope_types.go +++ b/apis/placement/v1beta1/envelope_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,36 +26,21 @@ import ( // +kubebuilder:object:root=true // +kubebuilder:resource:scope="Cluster",categories={fleet,fleet-placement} // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:storageversion // ClusterResourceEnvelope wraps cluster-scoped resources for placement. type ClusterResourceEnvelope struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // The desired state of ClusterResourceEnvelope. - // +kubebuilder:validation:Required - Spec EnvelopeSpec `json:"spec"` -} - -// EnvelopeSpec helps wrap resources for placement. -type EnvelopeSpec struct { - // A map of wrapped manifests. + // The manifests wrapped in this envelope. // // Each manifest is uniquely identified by a string key, typically a filename that represents - // the manifest. + // the manifest. The value is the manifest object itself. // +kubebuilder:validation:Required // +kubebuilder:validation:MinProperties=1 // +kubebuilder:validation:MaxProperties=50 - Manifests map[string]Manifest `json:"manifests"` -} - -// Manifest is a wrapped resource. -type Manifest struct { - // The resource data. - // +kubebuilder:validation:Required - // +kubebuilder:validation:EmbeddedResource - // +kubebuilder:pruning:PreserveUnknownFields - Data runtime.RawExtension `json:"data"` + Data map[string]runtime.RawExtension `json:"data"` } // +genclient @@ -63,11 +48,19 @@ type Manifest struct { // +kubebuilder:object:root=true // +kubebuilder:resource:scope="Namespaced",categories={fleet,fleet-placement} // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:storageversion + +// ResourceEnvelope wraps namespaced resources for placement. type ResourceEnvelope struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // The desired state of ResourceEnvelope. + // The manifests wrapped in this envelope. + // + // Each manifest is uniquely identified by a string key, typically a filename that represents + // the manifest. The value is the manifest object itself. // +kubebuilder:validation:Required - Spec EnvelopeSpec `json:"spec"` + // +kubebuilder:validation:MinProperties=1 + // +kubebuilder:validation:MaxProperties=50 + Data map[string]runtime.RawExtension `json:"data"` } diff --git a/apis/placement/v1beta1/zz_generated.deepcopy.go b/apis/placement/v1beta1/zz_generated.deepcopy.go index dec32e99d..8e692e177 100644 --- a/apis/placement/v1beta1/zz_generated.deepcopy.go +++ b/apis/placement/v1beta1/zz_generated.deepcopy.go @@ -416,6 +416,38 @@ func (in *ClusterResourceBindingList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterResourceEnvelope) DeepCopyInto(out *ClusterResourceEnvelope) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Data != nil { + in, out := &in.Data, &out.Data + *out = make(map[string]runtime.RawExtension, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceEnvelope. +func (in *ClusterResourceEnvelope) DeepCopy() *ClusterResourceEnvelope { + if in == nil { + return nil + } + out := new(ClusterResourceEnvelope) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterResourceEnvelope) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResourcePlacement) DeepCopyInto(out *ClusterResourcePlacement) { *out = *in @@ -1503,6 +1535,38 @@ func (in *ResourceContent) DeepCopy() *ResourceContent { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceEnvelope) DeepCopyInto(out *ResourceEnvelope) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Data != nil { + in, out := &in.Data, &out.Data + *out = make(map[string]runtime.RawExtension, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceEnvelope. +func (in *ResourceEnvelope) DeepCopy() *ResourceEnvelope { + if in == nil { + return nil + } + out := new(ResourceEnvelope) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ResourceEnvelope) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceIdentifier) DeepCopyInto(out *ResourceIdentifier) { *out = *in diff --git a/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceenvelopes.yaml b/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceenvelopes.yaml index 0c53b05a3..9b00cfba7 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceenvelopes.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceenvelopes.yaml @@ -17,7 +17,7 @@ spec: singular: clusterresourceenvelope scope: Cluster versions: - - name: v1alpha1 + - name: v1beta1 schema: openAPIV3Schema: description: ClusterResourceEnvelope wraps cluster-scoped resources for placement. @@ -29,6 +29,18 @@ spec: may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string + data: + additionalProperties: + type: object + x-kubernetes-preserve-unknown-fields: true + description: |- + The manifests wrapped in this envelope. + + Each manifest is uniquely identified by a string key, typically a filename that represents + the manifest. The value is the manifest object itself. + maxProperties: 50 + minProperties: 1 + type: object kind: description: |- Kind is a string value representing the REST resource this object represents. @@ -39,34 +51,8 @@ spec: type: string metadata: type: object - spec: - description: The desired state of ClusterResourceEnvelope. - properties: - manifests: - additionalProperties: - description: Manifest is a wrapped resource. - properties: - data: - description: The resource data. - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - required: - - data - type: object - description: |- - A map of wrapped manifests. - - Each manifest is uniquely identified by a string key, typically a filename that represents - the manifest. - maxProperties: 50 - minProperties: 1 - type: object - required: - - manifests - type: object required: - - spec + - data type: object served: true storage: true diff --git a/config/crd/bases/placement.kubernetes-fleet.io_resourceenvelopes.yaml b/config/crd/bases/placement.kubernetes-fleet.io_resourceenvelopes.yaml index b15627041..963e66c40 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_resourceenvelopes.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_resourceenvelopes.yaml @@ -17,9 +17,10 @@ spec: singular: resourceenvelope scope: Namespaced versions: - - name: v1alpha1 + - name: v1beta1 schema: openAPIV3Schema: + description: ResourceEnvelope wraps namespaced resources for placement. properties: apiVersion: description: |- @@ -28,6 +29,18 @@ spec: may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources type: string + data: + additionalProperties: + type: object + x-kubernetes-preserve-unknown-fields: true + description: |- + The manifests wrapped in this envelope. + + Each manifest is uniquely identified by a string key, typically a filename that represents + the manifest. The value is the manifest object itself. + maxProperties: 50 + minProperties: 1 + type: object kind: description: |- Kind is a string value representing the REST resource this object represents. @@ -38,34 +51,8 @@ spec: type: string metadata: type: object - spec: - description: The desired state of ResourceEnvelope. - properties: - manifests: - additionalProperties: - description: Manifest is a wrapped resource. - properties: - data: - description: The resource data. - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - required: - - data - type: object - description: |- - A map of wrapped manifests. - - Each manifest is uniquely identified by a string key, typically a filename that represents - the manifest. - maxProperties: 50 - minProperties: 1 - type: object - required: - - manifests - type: object required: - - spec + - data type: object served: true storage: true diff --git a/examples/envelopes/clusterscoped.yaml b/examples/envelopes/clusterscoped.yaml index 558b86fc5..de7e74ef1 100644 --- a/examples/envelopes/clusterscoped.yaml +++ b/examples/envelopes/clusterscoped.yaml @@ -1,36 +1,33 @@ -apiVersion: placement.kubernetes-fleet.io/v1alpha1 +apiVersion: placement.kubernetes-fleet.io/v1beta1 kind: ClusterResourceEnvelope metadata: name: example -spec: - manifests: - "webhook.yaml": - data: - apiVersion: admissionregistration.k8s.io/v1 - kind: ValidatingWebhookConfiguration - metadata: +data: + "webhook.yaml": + apiVersion: admissionregistration.k8s.io/v1 + kind: ValidatingWebhookConfiguration + metadata: + name: guard + webhooks: + - name: guard.example.com + rules: + - operations: ["CREATE"] + apiGroups: ["*"] + apiVersions: ["*"] + resources: ["*"] + clientConfig: + service: name: guard - webhooks: - - name: guard.example.com - rules: - - operations: ["CREATE"] - apiGroups: ["*"] - apiVersions: ["*"] - resources: ["*"] - clientConfig: - service: - name: guard - namespace: ops - admissionReviewVersions: ["v1"] - sideEffects: None - timeoutSeconds: 10 - "clusterrole.yaml": - data: - apiVersion: rbac.authorization.k8s.io/v1 - kind: ClusterRole - metadata: - name: pod-reader - rules: - - apiGroups: [""] - resources: ["pods"] - verbs: ["get", "list", "watch"] + namespace: ops + admissionReviewVersions: ["v1"] + sideEffects: None + timeoutSeconds: 10 + "clusterrole.yaml": + apiVersion: rbac.authorization.k8s.io/v1 + kind: ClusterRole + metadata: + name: pod-reader + rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list", "watch"] diff --git a/examples/envelopes/namespacescoped.yaml b/examples/envelopes/namespacescoped.yaml index 4642b8139..b261e0e99 100644 --- a/examples/envelopes/namespacescoped.yaml +++ b/examples/envelopes/namespacescoped.yaml @@ -1,33 +1,30 @@ -apiVersion: placement.kubernetes-fleet.io/v1alpha1 +apiVersion: placement.kubernetes-fleet.io/v1beta1 kind: ResourceEnvelope metadata: name: example -spec: - manifests: - "cm.yaml": - data: - apiVersion: v1 - kind: ConfigMap +data: + "cm.yaml": + apiVersion: v1 + kind: ConfigMap + metadata: + name: app + data: + foo: bar + "deploy.yaml": + apiVersion: apps/v1 + kind: Deployment + metadata: + name: app + spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: metadata: - name: app - data: - foo: bar - "deploy.yaml": - data: - apiVersion: apps/v1 - kind: Deployment - metadata: - name: app + labels: + app: nginx spec: - replicas: 1 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - name: web - image: nginx + containers: + - name: web + image: nginx