From cf1bf0e6a0a2263cf016b491c7894a7819a9a983 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Wed, 22 Jan 2025 18:22:40 +0600 Subject: [PATCH] Add api for resourceManifests Signed-off-by: Arnob kumar saha --- apis/meta/v1alpha1/openapi_generated.go | 129 ++++++++++++++++++ apis/meta/v1alpha1/resourcemanifests_types.go | 57 ++++++++ apis/meta/v1alpha1/zz_generated.deepcopy.go | 78 +++++++++++ .../meta/v1alpha1/fake/fake_meta_client.go | 4 + .../v1alpha1/fake/fake_resourcemanifests.go | 46 +++++++ .../meta/v1alpha1/generated_expansion.go | 2 + .../typed/meta/v1alpha1/meta_client.go | 5 + .../typed/meta/v1alpha1/resourcemanifests.go | 64 +++++++++ ...ta.k8s.appscode.com_resourcemanifests.yaml | 45 ++++++ 9 files changed, 430 insertions(+) create mode 100644 apis/meta/v1alpha1/resourcemanifests_types.go create mode 100644 client/clientset/versioned/typed/meta/v1alpha1/fake/fake_resourcemanifests.go create mode 100644 client/clientset/versioned/typed/meta/v1alpha1/resourcemanifests.go create mode 100644 crds/meta.k8s.appscode.com_resourcemanifests.yaml diff --git a/apis/meta/v1alpha1/openapi_generated.go b/apis/meta/v1alpha1/openapi_generated.go index decd73328..d9b9f35c7 100644 --- a/apis/meta/v1alpha1/openapi_generated.go +++ b/apis/meta/v1alpha1/openapi_generated.go @@ -432,6 +432,9 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceLayout": schema_resource_metadata_apis_meta_v1alpha1_ResourceLayout(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceLayoutList": schema_resource_metadata_apis_meta_v1alpha1_ResourceLayoutList(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceLayoutSpec": schema_resource_metadata_apis_meta_v1alpha1_ResourceLayoutSpec(ref), + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifests": schema_resource_metadata_apis_meta_v1alpha1_ResourceManifests(ref), + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifestsRequest": schema_resource_metadata_apis_meta_v1alpha1_ResourceManifestsRequest(ref), + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifestsResponse": schema_resource_metadata_apis_meta_v1alpha1_ResourceManifestsResponse(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceOutline": schema_resource_metadata_apis_meta_v1alpha1_ResourceOutline(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceOutlineFilter": schema_resource_metadata_apis_meta_v1alpha1_ResourceOutlineFilter(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceOutlineFilterList": schema_resource_metadata_apis_meta_v1alpha1_ResourceOutlineFilterList(ref), @@ -22431,6 +22434,132 @@ func schema_resource_metadata_apis_meta_v1alpha1_ResourceLayoutSpec(ref common.R } } +func schema_resource_metadata_apis_meta_v1alpha1_ResourceManifests(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "request": { + SchemaProps: spec.SchemaProps{ + Description: "Request describes the attributes for the preset query.", + Ref: ref("kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifestsRequest"), + }, + }, + "response": { + SchemaProps: spec.SchemaProps{ + Description: "Response describes the attributes for the preset response.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifestsResponse"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifestsRequest", "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ResourceManifestsResponse"}, + } +} + +func schema_resource_metadata_apis_meta_v1alpha1_ResourceManifestsRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version", "kind", "name"}, + }, + }, + } +} + +func schema_resource_metadata_apis_meta_v1alpha1_ResourceManifestsResponse(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "objects": { + SchemaProps: spec.SchemaProps{ + Description: "Objects hold all the yamls related to the request. The key here is G,V,N,NS", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + }, + }, + }, + Required: []string{"objects"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + } +} + func schema_resource_metadata_apis_meta_v1alpha1_ResourceOutline(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/meta/v1alpha1/resourcemanifests_types.go b/apis/meta/v1alpha1/resourcemanifests_types.go new file mode 100644 index 000000000..652bc22bc --- /dev/null +++ b/apis/meta/v1alpha1/resourcemanifests_types.go @@ -0,0 +1,57 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + kmapi "kmodules.xyz/client-go/api/v1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +const ( + ResourceKindResourceManifests = "ResourceManifests" + ResourceResourceManifests = "resourcemanifests" +) + +// +genclient +// +genclient:nonNamespaced +// +genclient:onlyVerbs=create +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=chartpresetquery,singular=chartpresetquery,scope=Cluster +type ResourceManifests struct { + metav1.TypeMeta `json:",inline"` + // Request describes the attributes for the preset query. + // +optional + Request *ResourceManifestsRequest `json:"request,omitempty"` + // Response describes the attributes for the preset response. + // +optional + Response []ResourceManifestsResponse `json:"response,omitempty"` +} + +type ResourceManifestsRequest struct { + metav1.GroupVersionKind `json:",inline"` + kmapi.ObjectReference `json:",inline"` +} + +type ResourceManifestsResponse struct { + // Objects hold all the yamls related to the request. + // The key here is G,V,N,NS + Objects map[string]runtime.RawExtension `json:"objects"` +} diff --git a/apis/meta/v1alpha1/zz_generated.deepcopy.go b/apis/meta/v1alpha1/zz_generated.deepcopy.go index 7cbaedd8d..1c0ab5b15 100644 --- a/apis/meta/v1alpha1/zz_generated.deepcopy.go +++ b/apis/meta/v1alpha1/zz_generated.deepcopy.go @@ -2115,6 +2115,84 @@ func (in *ResourceLayoutSpec) DeepCopy() *ResourceLayoutSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceManifests) DeepCopyInto(out *ResourceManifests) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.Request != nil { + in, out := &in.Request, &out.Request + *out = new(ResourceManifestsRequest) + **out = **in + } + if in.Response != nil { + in, out := &in.Response, &out.Response + *out = make([]ResourceManifestsResponse, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceManifests. +func (in *ResourceManifests) DeepCopy() *ResourceManifests { + if in == nil { + return nil + } + out := new(ResourceManifests) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ResourceManifests) 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 *ResourceManifestsRequest) DeepCopyInto(out *ResourceManifestsRequest) { + *out = *in + out.GroupVersionKind = in.GroupVersionKind + out.ObjectReference = in.ObjectReference + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceManifestsRequest. +func (in *ResourceManifestsRequest) DeepCopy() *ResourceManifestsRequest { + if in == nil { + return nil + } + out := new(ResourceManifestsRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceManifestsResponse) DeepCopyInto(out *ResourceManifestsResponse) { + *out = *in + if in.Objects != nil { + in, out := &in.Objects, &out.Objects + *out = make(map[string]runtime.RawExtension, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceManifestsResponse. +func (in *ResourceManifestsResponse) DeepCopy() *ResourceManifestsResponse { + if in == nil { + return nil + } + out := new(ResourceManifestsResponse) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceOutline) DeepCopyInto(out *ResourceOutline) { *out = *in diff --git a/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_meta_client.go b/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_meta_client.go index 60aff1563..60b19cd1e 100644 --- a/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_meta_client.go +++ b/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_meta_client.go @@ -84,6 +84,10 @@ func (c *FakeMetaV1alpha1) ResourceLayouts() v1alpha1.ResourceLayoutInterface { return &FakeResourceLayouts{c} } +func (c *FakeMetaV1alpha1) ResourceManifestses() v1alpha1.ResourceManifestsInterface { + return &FakeResourceManifestses{c} +} + func (c *FakeMetaV1alpha1) ResourceOutlines() v1alpha1.ResourceOutlineInterface { return &FakeResourceOutlines{c} } diff --git a/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_resourcemanifests.go b/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_resourcemanifests.go new file mode 100644 index 000000000..0fd2fa90e --- /dev/null +++ b/client/clientset/versioned/typed/meta/v1alpha1/fake/fake_resourcemanifests.go @@ -0,0 +1,46 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + testing "k8s.io/client-go/testing" + v1alpha1 "kmodules.xyz/resource-metadata/apis/meta/v1alpha1" +) + +// FakeResourceManifestses implements ResourceManifestsInterface +type FakeResourceManifestses struct { + Fake *FakeMetaV1alpha1 +} + +var resourcemanifestsesResource = v1alpha1.SchemeGroupVersion.WithResource("resourcemanifestses") + +var resourcemanifestsesKind = v1alpha1.SchemeGroupVersion.WithKind("ResourceManifests") + +// Create takes the representation of a resourceManifests and creates it. Returns the server's representation of the resourceManifests, and an error, if there is any. +func (c *FakeResourceManifestses) Create(ctx context.Context, resourceManifests *v1alpha1.ResourceManifests, opts v1.CreateOptions) (result *v1alpha1.ResourceManifests, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(resourcemanifestsesResource, resourceManifests), &v1alpha1.ResourceManifests{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ResourceManifests), err +} diff --git a/client/clientset/versioned/typed/meta/v1alpha1/generated_expansion.go b/client/clientset/versioned/typed/meta/v1alpha1/generated_expansion.go index fd16251b3..898c1603d 100644 --- a/client/clientset/versioned/typed/meta/v1alpha1/generated_expansion.go +++ b/client/clientset/versioned/typed/meta/v1alpha1/generated_expansion.go @@ -46,6 +46,8 @@ type ResourceGraphExpansion interface{} type ResourceLayoutExpansion interface{} +type ResourceManifestsExpansion interface{} + type ResourceOutlineExpansion interface{} type ResourceOutlineFilterExpansion interface{} diff --git a/client/clientset/versioned/typed/meta/v1alpha1/meta_client.go b/client/clientset/versioned/typed/meta/v1alpha1/meta_client.go index ef6a39ab9..b9456240a 100644 --- a/client/clientset/versioned/typed/meta/v1alpha1/meta_client.go +++ b/client/clientset/versioned/typed/meta/v1alpha1/meta_client.go @@ -42,6 +42,7 @@ type MetaV1alpha1Interface interface { ResourceEditorsGetter ResourceGraphsGetter ResourceLayoutsGetter + ResourceManifestsesGetter ResourceOutlinesGetter ResourceOutlineFiltersGetter ResourceQueriesGetter @@ -109,6 +110,10 @@ func (c *MetaV1alpha1Client) ResourceLayouts() ResourceLayoutInterface { return newResourceLayouts(c) } +func (c *MetaV1alpha1Client) ResourceManifestses() ResourceManifestsInterface { + return newResourceManifestses(c) +} + func (c *MetaV1alpha1Client) ResourceOutlines() ResourceOutlineInterface { return newResourceOutlines(c) } diff --git a/client/clientset/versioned/typed/meta/v1alpha1/resourcemanifests.go b/client/clientset/versioned/typed/meta/v1alpha1/resourcemanifests.go new file mode 100644 index 000000000..5b4693124 --- /dev/null +++ b/client/clientset/versioned/typed/meta/v1alpha1/resourcemanifests.go @@ -0,0 +1,64 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + rest "k8s.io/client-go/rest" + v1alpha1 "kmodules.xyz/resource-metadata/apis/meta/v1alpha1" + scheme "kmodules.xyz/resource-metadata/client/clientset/versioned/scheme" +) + +// ResourceManifestsesGetter has a method to return a ResourceManifestsInterface. +// A group's client should implement this interface. +type ResourceManifestsesGetter interface { + ResourceManifestses() ResourceManifestsInterface +} + +// ResourceManifestsInterface has methods to work with ResourceManifests resources. +type ResourceManifestsInterface interface { + Create(ctx context.Context, resourceManifests *v1alpha1.ResourceManifests, opts v1.CreateOptions) (*v1alpha1.ResourceManifests, error) + ResourceManifestsExpansion +} + +// resourceManifestses implements ResourceManifestsInterface +type resourceManifestses struct { + client rest.Interface +} + +// newResourceManifestses returns a ResourceManifestses +func newResourceManifestses(c *MetaV1alpha1Client) *resourceManifestses { + return &resourceManifestses{ + client: c.RESTClient(), + } +} + +// Create takes the representation of a resourceManifests and creates it. Returns the server's representation of the resourceManifests, and an error, if there is any. +func (c *resourceManifestses) Create(ctx context.Context, resourceManifests *v1alpha1.ResourceManifests, opts v1.CreateOptions) (result *v1alpha1.ResourceManifests, err error) { + result = &v1alpha1.ResourceManifests{} + err = c.client.Post(). + Resource("resourcemanifestses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(resourceManifests). + Do(ctx). + Into(result) + return +} diff --git a/crds/meta.k8s.appscode.com_resourcemanifests.yaml b/crds/meta.k8s.appscode.com_resourcemanifests.yaml new file mode 100644 index 000000000..e2c07f279 --- /dev/null +++ b/crds/meta.k8s.appscode.com_resourcemanifests.yaml @@ -0,0 +1,45 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: resourcemanifests.meta.k8s.appscode.com +spec: + group: meta.k8s.appscode.com + names: + kind: ResourceManifests + listKind: ResourceManifestsList + plural: resourcemanifests + singular: resourcemanifests + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + properties: + objects: + additionalProperties: + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + required: + - objects + type: object + type: object + served: true + storage: true