From 5c4c07afd728df98fc836d4cee9d6811eae7f3a4 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Wed, 13 Nov 2024 18:52:58 +0600 Subject: [PATCH 1/2] Add api for GatewayInfo Signed-off-by: Arnob kumar saha --- apis/meta/v1alpha1/gateway_info_types.go | 41 ++++++++++ apis/meta/v1alpha1/openapi_generated.go | 76 +++++++++++++++++++ apis/meta/v1alpha1/register.go | 1 + apis/meta/v1alpha1/zz_generated.deepcopy.go | 43 +++++++++++ crds/meta.k8s.appscode.com_gatewayinfoes.yaml | 48 ++++++++++++ 5 files changed, 209 insertions(+) create mode 100644 apis/meta/v1alpha1/gateway_info_types.go create mode 100644 crds/meta.k8s.appscode.com_gatewayinfoes.yaml diff --git a/apis/meta/v1alpha1/gateway_info_types.go b/apis/meta/v1alpha1/gateway_info_types.go new file mode 100644 index 000000000..1e98fb238 --- /dev/null +++ b/apis/meta/v1alpha1/gateway_info_types.go @@ -0,0 +1,41 @@ +/* +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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ResourceKindGatewayInfo = "GatewayInfo" + ResourceGatewayInfo = "gatewayinfo" + ResourceGatewayInfos = "gatewayinfos" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type GatewayInfo struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec GatewayInfoSpec `json:"spec,omitempty"` +} + +type GatewayInfoSpec struct { + GatewayClassName string `json:"gatewayClassName"` + HostName string `json:"hostName"` + IP string `json:"ip"` +} diff --git a/apis/meta/v1alpha1/openapi_generated.go b/apis/meta/v1alpha1/openapi_generated.go index 6bd70de2e..c5efa71e9 100644 --- a/apis/meta/v1alpha1/openapi_generated.go +++ b/apis/meta/v1alpha1/openapi_generated.go @@ -370,6 +370,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.DashboardResult": schema_resource_metadata_apis_meta_v1alpha1_DashboardResult(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ExecDefinition": schema_resource_metadata_apis_meta_v1alpha1_ExecDefinition(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.ExecResult": schema_resource_metadata_apis_meta_v1alpha1_ExecResult(ref), + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.GatewayInfo": schema_resource_metadata_apis_meta_v1alpha1_GatewayInfo(ref), + "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.GatewayInfoSpec": schema_resource_metadata_apis_meta_v1alpha1_GatewayInfoSpec(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.Link": schema_resource_metadata_apis_meta_v1alpha1_Link(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.Menu": schema_resource_metadata_apis_meta_v1alpha1_Menu(ref), "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.MenuEntry": schema_resource_metadata_apis_meta_v1alpha1_MenuEntry(ref), @@ -19406,6 +19408,80 @@ func schema_resource_metadata_apis_meta_v1alpha1_ExecResult(ref common.Reference } } +func schema_resource_metadata_apis_meta_v1alpha1_GatewayInfo(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: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/resource-metadata/apis/meta/v1alpha1.GatewayInfoSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "kmodules.xyz/resource-metadata/apis/meta/v1alpha1.GatewayInfoSpec"}, + } +} + +func schema_resource_metadata_apis_meta_v1alpha1_GatewayInfoSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "gatewayClassName": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "hostName": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ip": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"gatewayClassName", "hostName", "ip"}, + }, + }, + } +} + func schema_resource_metadata_apis_meta_v1alpha1_Link(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/meta/v1alpha1/register.go b/apis/meta/v1alpha1/register.go index 30a8cb7ac..cf06419e2 100644 --- a/apis/meta/v1alpha1/register.go +++ b/apis/meta/v1alpha1/register.go @@ -53,6 +53,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ClusterProfile{}, &ClusterProfileList{}, &ClusterStatus{}, + &GatewayInfo{}, &ResourceCalculator{}, &ResourceDescriptor{}, &ResourceDescriptorList{}, diff --git a/apis/meta/v1alpha1/zz_generated.deepcopy.go b/apis/meta/v1alpha1/zz_generated.deepcopy.go index b0b4686ea..2a207d862 100644 --- a/apis/meta/v1alpha1/zz_generated.deepcopy.go +++ b/apis/meta/v1alpha1/zz_generated.deepcopy.go @@ -362,6 +362,49 @@ func (in FeatureList) DeepCopy() FeatureList { return *out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GatewayInfo) DeepCopyInto(out *GatewayInfo) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewayInfo. +func (in *GatewayInfo) DeepCopy() *GatewayInfo { + if in == nil { + return nil + } + out := new(GatewayInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GatewayInfo) 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 *GatewayInfoSpec) DeepCopyInto(out *GatewayInfoSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewayInfoSpec. +func (in *GatewayInfoSpec) DeepCopy() *GatewayInfoSpec { + if in == nil { + return nil + } + out := new(GatewayInfoSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Link) DeepCopyInto(out *Link) { *out = *in diff --git a/crds/meta.k8s.appscode.com_gatewayinfoes.yaml b/crds/meta.k8s.appscode.com_gatewayinfoes.yaml new file mode 100644 index 000000000..04e908f94 --- /dev/null +++ b/crds/meta.k8s.appscode.com_gatewayinfoes.yaml @@ -0,0 +1,48 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: gatewayinfoes.meta.k8s.appscode.com +spec: + group: meta.k8s.appscode.com + names: + kind: GatewayInfo + listKind: GatewayInfoList + plural: gatewayinfoes + singular: gatewayinfo + 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: + gatewayClassName: + type: string + hostName: + type: string + ip: + type: string + required: + - gatewayClassName + - hostName + - ip + type: object + type: object + served: true + storage: true From e155689bbd75eabbd6934d345df9881e22a7fb3b Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Thu, 14 Nov 2024 02:11:51 -0700 Subject: [PATCH 2/2] Update api Signed-off-by: Tamal Saha --- apis/meta/v1alpha1/gateway_info_types.go | 5 +++-- apis/meta/v1alpha1/openapi_generated.go | 15 ++++++++++----- crds/meta.k8s.appscode.com_gatewayinfoes.yaml | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apis/meta/v1alpha1/gateway_info_types.go b/apis/meta/v1alpha1/gateway_info_types.go index 1e98fb238..69ae70197 100644 --- a/apis/meta/v1alpha1/gateway_info_types.go +++ b/apis/meta/v1alpha1/gateway_info_types.go @@ -36,6 +36,7 @@ type GatewayInfo struct { type GatewayInfoSpec struct { GatewayClassName string `json:"gatewayClassName"` - HostName string `json:"hostName"` - IP string `json:"ip"` + ServiceType string `json:"serviceType"` + HostName string `json:"hostName,omitempty"` + IP string `json:"ip,omitempty"` } diff --git a/apis/meta/v1alpha1/openapi_generated.go b/apis/meta/v1alpha1/openapi_generated.go index c5efa71e9..e46825cd7 100644 --- a/apis/meta/v1alpha1/openapi_generated.go +++ b/apis/meta/v1alpha1/openapi_generated.go @@ -19461,22 +19461,27 @@ func schema_resource_metadata_apis_meta_v1alpha1_GatewayInfoSpec(ref common.Refe Format: "", }, }, - "hostName": { + "serviceType": { SchemaProps: spec.SchemaProps{ Default: "", Type: []string{"string"}, Format: "", }, }, + "hostName": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, "ip": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, - Required: []string{"gatewayClassName", "hostName", "ip"}, + Required: []string{"gatewayClassName", "serviceType"}, }, }, } diff --git a/crds/meta.k8s.appscode.com_gatewayinfoes.yaml b/crds/meta.k8s.appscode.com_gatewayinfoes.yaml index 04e908f94..1ae64afca 100644 --- a/crds/meta.k8s.appscode.com_gatewayinfoes.yaml +++ b/crds/meta.k8s.appscode.com_gatewayinfoes.yaml @@ -38,10 +38,11 @@ spec: type: string ip: type: string + serviceType: + type: string required: - gatewayClassName - - hostName - - ip + - serviceType type: object type: object served: true