From edb32c4b235c80270cd1fedddfe69a618467e311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Fri, 2 Aug 2024 16:34:46 +0200 Subject: [PATCH] feat(crd): add KonnectControlPlane --- api/configuration/v1/kongconsumer_types.go | 4 +- .../v1alpha1/kongpluginbinding_types.go | 6 +- api/configuration/v1alpha1/kongroute_types.go | 4 +- .../v1alpha1/kongservice_types.go | 4 +- .../v1alpha1/zz_generated.deepcopy.go | 47 ---- .../v1alpha1/konnect_controlplane_types.go | 97 +++++++ .../v1alpha1/konnect_entity_status.go | 0 api/konnect/v1alpha1/zz_generated.deepcopy.go | 146 +++++++++++ ...nnect.konghq.com_konnectcontrolplanes.yaml | 237 ++++++++++++++++++ config/crd/kustomization.yaml | 1 + config/samples/konnect_controlplane.yaml | 38 +++ docs/api-reference.md | 57 ----- docs/konnect-api-reference.md | 77 ++++++ .../v1alpha1/fake/fake_konnect_client.go | 4 + .../v1alpha1/fake/fake_konnectcontrolplane.go | 141 +++++++++++ .../konnect/v1alpha1/generated_expansion.go | 2 + .../typed/konnect/v1alpha1/konnect_client.go | 5 + .../konnect/v1alpha1/konnectcontrolplane.go | 195 ++++++++++++++ 18 files changed, 953 insertions(+), 112 deletions(-) create mode 100644 api/konnect/v1alpha1/konnect_controlplane_types.go rename api/{configuration => konnect}/v1alpha1/konnect_entity_status.go (100%) create mode 100644 config/crd/bases/konnect.konghq.com_konnectcontrolplanes.yaml create mode 100644 config/samples/konnect_controlplane.yaml create mode 100644 pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnectcontrolplane.go create mode 100644 pkg/clientset/typed/konnect/v1alpha1/konnectcontrolplane.go diff --git a/api/configuration/v1/kongconsumer_types.go b/api/configuration/v1/kongconsumer_types.go index adaa8f79..ac80b976 100644 --- a/api/configuration/v1/kongconsumer_types.go +++ b/api/configuration/v1/kongconsumer_types.go @@ -62,7 +62,7 @@ type KongConsumer struct { Status KongConsumerStatus `json:"status,omitempty"` } -func (c *KongConsumer) GetKonnectStatus() *configurationv1alpha1.KonnectEntityStatus { +func (c *KongConsumer) GetKonnectStatus() *konnectv1alpha1.KonnectEntityStatus { return &c.Status.Konnect.KonnectEntityStatus } @@ -107,7 +107,7 @@ type KongConsumerList struct { // KongConsumerStatus represents the current status of the KongConsumer resource. type KongConsumerStatus struct { // Konnect contains the Konnect entity status. - Konnect configurationv1alpha1.KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"` + Konnect konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"` // Conditions describe the current conditions of the KongConsumer. // diff --git a/api/configuration/v1alpha1/kongpluginbinding_types.go b/api/configuration/v1alpha1/kongpluginbinding_types.go index 2c9b3dd0..6eff1621 100644 --- a/api/configuration/v1alpha1/kongpluginbinding_types.go +++ b/api/configuration/v1alpha1/kongpluginbinding_types.go @@ -18,6 +18,8 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" ) // KongPluginBinding is the schema for Plugin Bindings API which defines a Kong Plugin Binding. @@ -40,7 +42,7 @@ type KongPluginBinding struct { Status KongPluginBindingStatus `json:"status,omitempty"` } -func (c *KongPluginBinding) GetKonnectStatus() *KonnectEntityStatus { +func (c *KongPluginBinding) GetKonnectStatus() *konnectv1alpha1.KonnectEntityStatus { return &c.Status.Konnect.KonnectEntityStatus } @@ -137,7 +139,7 @@ type EntityRef struct { // KongPluginBindingStatus represents the current status of the KongBinding resource. type KongPluginBindingStatus struct { // Konnect contains the Konnect entity status. - Konnect KonnectEntityStatusWithControlPlaneAndServiceRefs `json:"konnect,omitempty"` + Konnect konnectv1alpha1.KonnectEntityStatusWithControlPlaneAndServiceRefs `json:"konnect,omitempty"` // Conditions describe the status of the Konnect entity. // +listType=map diff --git a/api/configuration/v1alpha1/kongroute_types.go b/api/configuration/v1alpha1/kongroute_types.go index 3ee4c457..d2840ca8 100644 --- a/api/configuration/v1alpha1/kongroute_types.go +++ b/api/configuration/v1alpha1/kongroute_types.go @@ -45,7 +45,7 @@ type KongRoute struct { Status KongRouteStatus `json:"status,omitempty"` } -func (c *KongRoute) GetKonnectStatus() *KonnectEntityStatus { +func (c *KongRoute) GetKonnectStatus() *konnectv1alpha1.KonnectEntityStatus { return &c.Status.Konnect.KonnectEntityStatus } @@ -128,7 +128,7 @@ type KongRouteAPISpec struct { // KongRouteStatus represents the current status of the Kong Route resource. type KongRouteStatus struct { // Konnect contains the Konnect entity status. - Konnect KonnectEntityStatusWithControlPlaneAndServiceRefs `json:"konnect,omitempty"` + Konnect konnectv1alpha1.KonnectEntityStatusWithControlPlaneAndServiceRefs `json:"konnect,omitempty"` // Conditions describe the status of the Konnect entity. // +listType=map diff --git a/api/configuration/v1alpha1/kongservice_types.go b/api/configuration/v1alpha1/kongservice_types.go index 4888454a..7d3e78d7 100644 --- a/api/configuration/v1alpha1/kongservice_types.go +++ b/api/configuration/v1alpha1/kongservice_types.go @@ -43,7 +43,7 @@ type KongService struct { Status KongServiceStatus `json:"status,omitempty"` } -func (c *KongService) GetKonnectStatus() *KonnectEntityStatus { +func (c *KongService) GetKonnectStatus() *konnectv1alpha1.KonnectEntityStatus { return &c.Status.Konnect.KonnectEntityStatus } @@ -129,7 +129,7 @@ type KongServiceAPISpec struct { // KongServiceStatus represents the current status of the Kong Service resource. type KongServiceStatus struct { // Konnect contains the Konnect entity status. - Konnect KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"` + Konnect konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef `json:"konnect,omitempty"` // Conditions describe the status of the Konnect entity. // +listType=map diff --git a/api/configuration/v1alpha1/zz_generated.deepcopy.go b/api/configuration/v1alpha1/zz_generated.deepcopy.go index 5fd10f2a..80133f66 100644 --- a/api/configuration/v1alpha1/zz_generated.deepcopy.go +++ b/api/configuration/v1alpha1/zz_generated.deepcopy.go @@ -1020,53 +1020,6 @@ func (in *KongVaultStatus) DeepCopy() *KongVaultStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KonnectEntityStatus) DeepCopyInto(out *KonnectEntityStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectEntityStatus. -func (in *KonnectEntityStatus) DeepCopy() *KonnectEntityStatus { - if in == nil { - return nil - } - out := new(KonnectEntityStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KonnectEntityStatusWithControlPlaneAndServiceRefs) DeepCopyInto(out *KonnectEntityStatusWithControlPlaneAndServiceRefs) { - *out = *in - out.KonnectEntityStatus = in.KonnectEntityStatus -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectEntityStatusWithControlPlaneAndServiceRefs. -func (in *KonnectEntityStatusWithControlPlaneAndServiceRefs) DeepCopy() *KonnectEntityStatusWithControlPlaneAndServiceRefs { - if in == nil { - return nil - } - out := new(KonnectEntityStatusWithControlPlaneAndServiceRefs) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KonnectEntityStatusWithControlPlaneRef) DeepCopyInto(out *KonnectEntityStatusWithControlPlaneRef) { - *out = *in - out.KonnectEntityStatus = in.KonnectEntityStatus -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectEntityStatusWithControlPlaneRef. -func (in *KonnectEntityStatusWithControlPlaneRef) DeepCopy() *KonnectEntityStatusWithControlPlaneRef { - if in == nil { - return nil - } - out := new(KonnectEntityStatusWithControlPlaneRef) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KonnectNamespacedRef) DeepCopyInto(out *KonnectNamespacedRef) { *out = *in diff --git a/api/konnect/v1alpha1/konnect_controlplane_types.go b/api/konnect/v1alpha1/konnect_controlplane_types.go new file mode 100644 index 00000000..cf7d39d8 --- /dev/null +++ b/api/konnect/v1alpha1/konnect_controlplane_types.go @@ -0,0 +1,97 @@ +package v1alpha1 + +import ( + sdkkonnectgocomp "github.com/Kong/sdk-konnect-go/models/components" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func init() { + SchemeBuilder.Register(&KonnectControlPlane{}, &KonnectControlPlaneList{}) +} + +// KonnectControlPlane is the Schema for the KonnectControlplanes API. +// +// +genclient +// +kubebuilder:resource:scope=Namespaced +// +kubebuilder:object:root=true +// +kubebuilder:object:generate=true +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Programmed",description="The Resource is Programmed on Konnect",type=string,JSONPath=`.status.conditions[?(@.type=='Programmed')].status` +// +kubebuilder:printcolumn:name="ID",description="Konnect ID",type=string,JSONPath=`.status.id` +// +kubebuilder:printcolumn:name="OrgID",description="Konnect Organization ID this resource belongs to.",type=string,JSONPath=`.status.organizationID` +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.spec.konnect.authRef) || has(oldSelf.spec.konnect.authRef)", message="Konnect Configuration's API auth ref reference is immutable" +type KonnectControlPlane struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec KonnectControlPlaneSpec `json:"spec,omitempty"` + + Status KonnectControlPlaneStatus `json:"status,omitempty"` +} + +// KonnectControlPlaneSpec defines the desired state of KonnectControlPlane. +type KonnectControlPlaneSpec struct { + sdkkonnectgocomp.CreateControlPlaneRequest `json:",inline"` + + KonnectConfiguration KonnectConfiguration `json:"konnect,omitempty"` +} + +// KonnectControlPlaneStatus defines the observed state of KonnectControlPlane. +type KonnectControlPlaneStatus struct { + KonnectEntityStatus `json:",inline"` + + // Conditions describe the current conditions of the KonnectControlPlane. + // + // Known condition types are: + // + // * "Programmed" + // + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=8 + // +kubebuilder:default={{type: "Programmed", status: "Unknown", reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}} + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// GetKonnectStatus returns the Konnect Status of the KonnectControlPlane. +func (c *KonnectControlPlane) GetKonnectStatus() *KonnectEntityStatus { + return &c.Status.KonnectEntityStatus +} + +// GetTypeName returns the KonnectControlPlane type name. +func (c KonnectControlPlane) GetTypeName() string { + return "KonnectControlPlane" +} + +// GetKonnectLabels gets the Konnect Labels from object's spec. +func (c *KonnectControlPlane) GetKonnectLabels() map[string]string { + return c.Spec.Labels +} + +// SetKonnectLabels sets the Konnect Labels in object's spec. +func (c *KonnectControlPlane) SetKonnectLabels(labels map[string]string) { + c.Spec.Labels = labels +} + +// GetKonnectAPIAuthConfigurationRef returns the Konnect API Auth Configuration Ref. +func (c *KonnectControlPlane) GetKonnectAPIAuthConfigurationRef() KonnectAPIAuthConfigurationRef { + return c.Spec.KonnectConfiguration.APIAuthConfigurationRef +} + +// GetConditions returns the Status Conditions +func (c *KonnectControlPlane) GetConditions() []metav1.Condition { + return c.Status.Conditions +} + +// SetConditions sets the Status Conditions +func (c *KonnectControlPlane) SetConditions(conditions []metav1.Condition) { + c.Status.Conditions = conditions +} + +// +kubebuilder:object:root=true +type KonnectControlPlaneList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []KonnectControlPlane `json:"items"` +} diff --git a/api/configuration/v1alpha1/konnect_entity_status.go b/api/konnect/v1alpha1/konnect_entity_status.go similarity index 100% rename from api/configuration/v1alpha1/konnect_entity_status.go rename to api/konnect/v1alpha1/konnect_entity_status.go diff --git a/api/konnect/v1alpha1/zz_generated.deepcopy.go b/api/konnect/v1alpha1/zz_generated.deepcopy.go index 7163462f..2601b8e3 100644 --- a/api/konnect/v1alpha1/zz_generated.deepcopy.go +++ b/api/konnect/v1alpha1/zz_generated.deepcopy.go @@ -141,3 +141,149 @@ func (in *KonnectAPIAuthConfigurationStatus) DeepCopy() *KonnectAPIAuthConfigura in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KonnectControlPlane) DeepCopyInto(out *KonnectControlPlane) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectControlPlane. +func (in *KonnectControlPlane) DeepCopy() *KonnectControlPlane { + if in == nil { + return nil + } + out := new(KonnectControlPlane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KonnectControlPlane) 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 *KonnectControlPlaneList) DeepCopyInto(out *KonnectControlPlaneList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KonnectControlPlane, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectControlPlaneList. +func (in *KonnectControlPlaneList) DeepCopy() *KonnectControlPlaneList { + if in == nil { + return nil + } + out := new(KonnectControlPlaneList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KonnectControlPlaneList) 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 *KonnectControlPlaneSpec) DeepCopyInto(out *KonnectControlPlaneSpec) { + *out = *in + in.CreateControlPlaneRequest.DeepCopyInto(&out.CreateControlPlaneRequest) + out.KonnectConfiguration = in.KonnectConfiguration +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectControlPlaneSpec. +func (in *KonnectControlPlaneSpec) DeepCopy() *KonnectControlPlaneSpec { + if in == nil { + return nil + } + out := new(KonnectControlPlaneSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KonnectControlPlaneStatus) DeepCopyInto(out *KonnectControlPlaneStatus) { + *out = *in + out.KonnectEntityStatus = in.KonnectEntityStatus + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectControlPlaneStatus. +func (in *KonnectControlPlaneStatus) DeepCopy() *KonnectControlPlaneStatus { + if in == nil { + return nil + } + out := new(KonnectControlPlaneStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KonnectEntityStatus) DeepCopyInto(out *KonnectEntityStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectEntityStatus. +func (in *KonnectEntityStatus) DeepCopy() *KonnectEntityStatus { + if in == nil { + return nil + } + out := new(KonnectEntityStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KonnectEntityStatusWithControlPlaneAndServiceRefs) DeepCopyInto(out *KonnectEntityStatusWithControlPlaneAndServiceRefs) { + *out = *in + out.KonnectEntityStatus = in.KonnectEntityStatus +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectEntityStatusWithControlPlaneAndServiceRefs. +func (in *KonnectEntityStatusWithControlPlaneAndServiceRefs) DeepCopy() *KonnectEntityStatusWithControlPlaneAndServiceRefs { + if in == nil { + return nil + } + out := new(KonnectEntityStatusWithControlPlaneAndServiceRefs) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KonnectEntityStatusWithControlPlaneRef) DeepCopyInto(out *KonnectEntityStatusWithControlPlaneRef) { + *out = *in + out.KonnectEntityStatus = in.KonnectEntityStatus +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KonnectEntityStatusWithControlPlaneRef. +func (in *KonnectEntityStatusWithControlPlaneRef) DeepCopy() *KonnectEntityStatusWithControlPlaneRef { + if in == nil { + return nil + } + out := new(KonnectEntityStatusWithControlPlaneRef) + in.DeepCopyInto(out) + return out +} diff --git a/config/crd/bases/konnect.konghq.com_konnectcontrolplanes.yaml b/config/crd/bases/konnect.konghq.com_konnectcontrolplanes.yaml new file mode 100644 index 00000000..49411e65 --- /dev/null +++ b/config/crd/bases/konnect.konghq.com_konnectcontrolplanes.yaml @@ -0,0 +1,237 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.15.0 + name: konnectcontrolplanes.konnect.konghq.com +spec: + group: konnect.konghq.com + names: + kind: KonnectControlPlane + listKind: KonnectControlPlaneList + plural: konnectcontrolplanes + singular: konnectcontrolplane + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: The Resource is Programmed on Konnect + jsonPath: .status.conditions[?(@.type=='Programmed')].status + name: Programmed + type: string + - description: Konnect ID + jsonPath: .status.id + name: ID + type: string + - description: Konnect Organization ID this resource belongs to. + jsonPath: .status.organizationID + name: OrgID + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: KonnectControlPlane is the Schema for the KonnectControlplanes + API. + 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: + description: KonnectControlPlaneSpec defines the desired state of KonnectControlPlane. + properties: + auth_type: + description: The auth type value of the cluster associated with the + Runtime Group. + type: string + cloud_gateway: + description: Whether this control-plane can be used for cloud-gateways. + type: boolean + cluster_type: + description: The ClusterType value of the cluster associated with + the Control Plane. + type: string + description: + description: The description of the control plane in Konnect. + type: string + konnect: + properties: + authRef: + description: |- + APIAuthConfigurationRef is the reference to the API Auth Configuration + that should be used for this Konnect Configuration. + properties: + name: + description: Name is the name of the KonnectAPIAuthConfiguration + resource. + type: string + required: + - name + type: object + x-kubernetes-validations: + - message: authRef is immutable + rule: self == oldSelf + type: object + labels: + additionalProperties: + type: string + description: |- + Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. + + + Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_". + type: object + name: + description: The name of the control plane. + type: string + proxy_urls: + description: Array of proxy URLs associated with reaching the data-planes + connected to a control-plane. + items: + description: ProxyURL - Proxy URL associated with reaching the data-planes + connected to a control-plane. + properties: + host: + description: Hostname of the proxy URL. + type: string + port: + description: Port of the proxy URL. + format: int64 + type: integer + protocol: + description: Protocol of the proxy URL. + type: string + required: + - host + - port + - protocol + type: object + type: array + required: + - name + type: object + status: + description: KonnectControlPlaneStatus defines the observed state of KonnectControlPlane. + properties: + conditions: + default: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: Waiting for controller + reason: Pending + status: Unknown + type: Programmed + description: |- + Conditions describe the current conditions of the KonnectControlPlane. + + + Known condition types are: + + + * "Programmed" + items: + description: "Condition contains details for one aspect of the current + state of this API Resource.\n---\nThis struct is intended for + direct use as an array at the field path .status.conditions. For + example,\n\n\n\ttype FooStatus struct{\n\t // Represents the + observations of a foo's current state.\n\t // Known .status.conditions.type + are: \"Available\", \"Progressing\", and \"Degraded\"\n\t // + +patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t + \ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t + \ // other fields\n\t}" + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + --- + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be + useful (see .node.status.conditions), the ability to deconflict is important. + The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + maxItems: 8 + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + id: + description: |- + ID is the unique identifier of the Konnect entity as assigned by Konnect API. + If it's unset (empty string), it means the Konnect entity hasn't been created yet. + type: string + organizationID: + description: OrgID is ID of Konnect Org that this entity has been + created in. + type: string + serverURL: + description: ServerURL is the URL of the Konnect server in which the + entity exists. + type: string + type: object + type: object + x-kubernetes-validations: + - message: Konnect Configuration's API auth ref reference is immutable + rule: '!has(oldSelf.spec.konnect.authRef) || has(oldSelf.spec.konnect.authRef)' + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 5e306985..cdc03fc2 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -19,5 +19,6 @@ resources: - bases/configuration.konghq.com_kongroutes.yaml - bases/konnect.konghq.com_konnectapiauthconfigurations.yaml +- bases/konnect.konghq.com_konnectcontrolplanes.yaml #+kubebuilder:scaffold:crdkustomizeresource diff --git a/config/samples/konnect_controlplane.yaml b/config/samples/konnect_controlplane.yaml new file mode 100644 index 00000000..febc624a --- /dev/null +++ b/config/samples/konnect_controlplane.yaml @@ -0,0 +1,38 @@ +kind: KonnectControlPlane +apiVersion: konnect.konghq.com/v1alpha1 +metadata: + name: group1 + namespace: default +spec: + name: group1 + cluster_type: CLUSTER_TYPE_CONTROL_PLANE_GROUP + labels: + app: group1 + key1: group1 + konnect: + authRef: + name: konnect-api-auth-dev-1 +--- +kind: KonnectControlPlane +apiVersion: konnect.konghq.com/v1alpha1 +metadata: + name: test1 + namespace: default +spec: + name: test1 + labels: + app: test1 + key1: test1 + konnect: + authRef: + name: konnect-api-auth-dev-1 +--- +kind: KonnectAPIAuthConfiguration +apiVersion: konnect.konghq.com/v1alpha1 +metadata: + name: konnect-api-auth-dev-1 + namespace: default +spec: + type: token + token: kpat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + serverURL: us.api.konghq.tech diff --git a/docs/api-reference.md b/docs/api-reference.md index 3e728719..2472130b 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -789,63 +789,6 @@ _Appears in:_ -#### KonnectEntityStatus - - - - - - -| Field | Description | -| --- | --- | -| `id` _string_ | ID is the unique identifier of the Konnect entity as assigned by Konnect API. If it's unset (empty string), it means the Konnect entity hasn't been created yet. | -| `serverURL` _string_ | ServerURL is the URL of the Konnect server in which the entity exists. | -| `organizationID` _string_ | OrgID is ID of Konnect Org that this entity has been created in. | - - -_Appears in:_ -- [KonnectEntityStatusWithControlPlaneAndServiceRefs](#konnectentitystatuswithcontrolplaneandservicerefs) -- [KonnectEntityStatusWithControlPlaneRef](#konnectentitystatuswithcontrolplaneref) - -#### KonnectEntityStatusWithControlPlaneAndServiceRefs - - - - - - -| Field | Description | -| --- | --- | -| `id` _string_ | ID is the unique identifier of the Konnect entity as assigned by Konnect API. If it's unset (empty string), it means the Konnect entity hasn't been created yet. | -| `serverURL` _string_ | ServerURL is the URL of the Konnect server in which the entity exists. | -| `organizationID` _string_ | OrgID is ID of Konnect Org that this entity has been created in. | -| `controlPlaneID` _string_ | ControlPlaneID is the Konnect ID of the ControlPlane this entity is associated with. | -| `serviceID` _string_ | ServiceID is the Konnect ID of the Service this entity is associated with. | - - -_Appears in:_ -- [KongPluginBindingStatus](#kongpluginbindingstatus) -- [KongRouteStatus](#kongroutestatus) - -#### KonnectEntityStatusWithControlPlaneRef - - - - - - -| Field | Description | -| --- | --- | -| `id` _string_ | ID is the unique identifier of the Konnect entity as assigned by Konnect API. If it's unset (empty string), it means the Konnect entity hasn't been created yet. | -| `serverURL` _string_ | ServerURL is the URL of the Konnect server in which the entity exists. | -| `organizationID` _string_ | OrgID is ID of Konnect Org that this entity has been created in. | -| `controlPlaneID` _string_ | ControlPlaneID is the Konnect ID of the ControlPlane this Route is associated with. | - - -_Appears in:_ -- [KongConsumerStatus](#kongconsumerstatus) -- [KongServiceStatus](#kongservicestatus) - #### KonnectNamespacedRef diff --git a/docs/konnect-api-reference.md b/docs/konnect-api-reference.md index 21079df5..b5edb3c0 100644 --- a/docs/konnect-api-reference.md +++ b/docs/konnect-api-reference.md @@ -9,6 +9,7 @@ Package v1alpha1 contains API Schema definitions for the konnect.konghq.com v1alpha1 API group. - [KonnectAPIAuthConfiguration](#konnectapiauthconfiguration) +- [KonnectControlPlane](#konnectcontrolplane) ### KonnectAPIAuthConfiguration @@ -25,6 +26,22 @@ KonnectAPIAuthConfiguration is the Schema for the Konnect configuration type. +### KonnectControlPlane + + +KonnectControlPlane is the Schema for the KonnectControlplanes API. + + + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `konnect.konghq.com/v1alpha1` +| `kind` _string_ | `KonnectControlPlane` +| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | +| `spec` _[KonnectControlPlaneSpec](#konnectcontrolplanespec)_ | | + + + ### Types In this section you will find types that the CRDs rely on. @@ -75,5 +92,65 @@ _Underlying type:_ `string` _Appears in:_ - [KonnectAPIAuthConfigurationSpec](#konnectapiauthconfigurationspec) +#### KonnectConfiguration + + + + + + +| Field | Description | +| --- | --- | +| `authRef` _[KonnectAPIAuthConfigurationRef](#konnectapiauthconfigurationref)_ | APIAuthConfigurationRef is the reference to the API Auth Configuration that should be used for this Konnect Configuration. | + + +_Appears in:_ +- [KonnectControlPlaneSpec](#konnectcontrolplanespec) + +#### KonnectControlPlaneSpec + + +KonnectControlPlaneSpec defines the desired state of KonnectControlPlane. + + + +| Field | Description | +| --- | --- | +| `name` _string_ | The name of the control plane. | +| `description` _string_ | The description of the control plane in Konnect. | +| `cluster_type` _[ClusterType](#clustertype)_ | The ClusterType value of the cluster associated with the Control Plane. | +| `auth_type` _[AuthType](#authtype)_ | The auth type value of the cluster associated with the Runtime Group. | +| `cloud_gateway` _boolean_ | Whether this control-plane can be used for cloud-gateways. | +| `proxy_urls` _[ProxyURL](#proxyurl) array_ | Array of proxy URLs associated with reaching the data-planes connected to a control-plane. | +| `labels` _object (keys:string, values:string)_ | Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_". | +| `konnect` _[KonnectConfiguration](#konnectconfiguration)_ | | + + +_Appears in:_ +- [KonnectControlPlane](#konnectcontrolplane) + + + +#### KonnectEntityStatus + + + + + + +| Field | Description | +| --- | --- | +| `id` _string_ | ID is the unique identifier of the Konnect entity as assigned by Konnect API. If it's unset (empty string), it means the Konnect entity hasn't been created yet. | +| `serverURL` _string_ | ServerURL is the URL of the Konnect server in which the entity exists. | +| `organizationID` _string_ | OrgID is ID of Konnect Org that this entity has been created in. | + + +_Appears in:_ +- [KonnectControlPlaneStatus](#konnectcontrolplanestatus) +- [KonnectEntityStatusWithControlPlaneAndServiceRefs](#konnectentitystatuswithcontrolplaneandservicerefs) +- [KonnectEntityStatusWithControlPlaneRef](#konnectentitystatuswithcontrolplaneref) + + + diff --git a/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnect_client.go b/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnect_client.go index d5d4e063..d9bebd46 100644 --- a/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnect_client.go +++ b/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnect_client.go @@ -32,6 +32,10 @@ func (c *FakeKonnectV1alpha1) KonnectAPIAuthConfigurations(namespace string) v1a return &FakeKonnectAPIAuthConfigurations{c, namespace} } +func (c *FakeKonnectV1alpha1) KonnectControlPlanes(namespace string) v1alpha1.KonnectControlPlaneInterface { + return &FakeKonnectControlPlanes{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeKonnectV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnectcontrolplane.go b/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnectcontrolplane.go new file mode 100644 index 00000000..409e5d83 --- /dev/null +++ b/pkg/clientset/typed/konnect/v1alpha1/fake/fake_konnectcontrolplane.go @@ -0,0 +1,141 @@ +/* +Copyright 2021 Kong, Inc. + +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" + + v1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeKonnectControlPlanes implements KonnectControlPlaneInterface +type FakeKonnectControlPlanes struct { + Fake *FakeKonnectV1alpha1 + ns string +} + +var konnectcontrolplanesResource = v1alpha1.SchemeGroupVersion.WithResource("konnectcontrolplanes") + +var konnectcontrolplanesKind = v1alpha1.SchemeGroupVersion.WithKind("KonnectControlPlane") + +// Get takes name of the konnectControlPlane, and returns the corresponding konnectControlPlane object, and an error if there is any. +func (c *FakeKonnectControlPlanes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.KonnectControlPlane, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(konnectcontrolplanesResource, c.ns, name), &v1alpha1.KonnectControlPlane{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KonnectControlPlane), err +} + +// List takes label and field selectors, and returns the list of KonnectControlPlanes that match those selectors. +func (c *FakeKonnectControlPlanes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.KonnectControlPlaneList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(konnectcontrolplanesResource, konnectcontrolplanesKind, c.ns, opts), &v1alpha1.KonnectControlPlaneList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.KonnectControlPlaneList{ListMeta: obj.(*v1alpha1.KonnectControlPlaneList).ListMeta} + for _, item := range obj.(*v1alpha1.KonnectControlPlaneList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested konnectControlPlanes. +func (c *FakeKonnectControlPlanes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(konnectcontrolplanesResource, c.ns, opts)) + +} + +// Create takes the representation of a konnectControlPlane and creates it. Returns the server's representation of the konnectControlPlane, and an error, if there is any. +func (c *FakeKonnectControlPlanes) Create(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.CreateOptions) (result *v1alpha1.KonnectControlPlane, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(konnectcontrolplanesResource, c.ns, konnectControlPlane), &v1alpha1.KonnectControlPlane{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KonnectControlPlane), err +} + +// Update takes the representation of a konnectControlPlane and updates it. Returns the server's representation of the konnectControlPlane, and an error, if there is any. +func (c *FakeKonnectControlPlanes) Update(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.UpdateOptions) (result *v1alpha1.KonnectControlPlane, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(konnectcontrolplanesResource, c.ns, konnectControlPlane), &v1alpha1.KonnectControlPlane{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KonnectControlPlane), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeKonnectControlPlanes) UpdateStatus(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.UpdateOptions) (*v1alpha1.KonnectControlPlane, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(konnectcontrolplanesResource, "status", c.ns, konnectControlPlane), &v1alpha1.KonnectControlPlane{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KonnectControlPlane), err +} + +// Delete takes name of the konnectControlPlane and deletes it. Returns an error if one occurs. +func (c *FakeKonnectControlPlanes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(konnectcontrolplanesResource, c.ns, name, opts), &v1alpha1.KonnectControlPlane{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeKonnectControlPlanes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(konnectcontrolplanesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.KonnectControlPlaneList{}) + return err +} + +// Patch applies the patch and returns the patched konnectControlPlane. +func (c *FakeKonnectControlPlanes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.KonnectControlPlane, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(konnectcontrolplanesResource, c.ns, name, pt, data, subresources...), &v1alpha1.KonnectControlPlane{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KonnectControlPlane), err +} diff --git a/pkg/clientset/typed/konnect/v1alpha1/generated_expansion.go b/pkg/clientset/typed/konnect/v1alpha1/generated_expansion.go index c913ce43..555a156c 100644 --- a/pkg/clientset/typed/konnect/v1alpha1/generated_expansion.go +++ b/pkg/clientset/typed/konnect/v1alpha1/generated_expansion.go @@ -19,3 +19,5 @@ limitations under the License. package v1alpha1 type KonnectAPIAuthConfigurationExpansion interface{} + +type KonnectControlPlaneExpansion interface{} diff --git a/pkg/clientset/typed/konnect/v1alpha1/konnect_client.go b/pkg/clientset/typed/konnect/v1alpha1/konnect_client.go index d825a0f3..27553111 100644 --- a/pkg/clientset/typed/konnect/v1alpha1/konnect_client.go +++ b/pkg/clientset/typed/konnect/v1alpha1/konnect_client.go @@ -29,6 +29,7 @@ import ( type KonnectV1alpha1Interface interface { RESTClient() rest.Interface KonnectAPIAuthConfigurationsGetter + KonnectControlPlanesGetter } // KonnectV1alpha1Client is used to interact with features provided by the konnect.konghq.com group. @@ -40,6 +41,10 @@ func (c *KonnectV1alpha1Client) KonnectAPIAuthConfigurations(namespace string) K return newKonnectAPIAuthConfigurations(c, namespace) } +func (c *KonnectV1alpha1Client) KonnectControlPlanes(namespace string) KonnectControlPlaneInterface { + return newKonnectControlPlanes(c, namespace) +} + // NewForConfig creates a new KonnectV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/pkg/clientset/typed/konnect/v1alpha1/konnectcontrolplane.go b/pkg/clientset/typed/konnect/v1alpha1/konnectcontrolplane.go new file mode 100644 index 00000000..5fed0b48 --- /dev/null +++ b/pkg/clientset/typed/konnect/v1alpha1/konnectcontrolplane.go @@ -0,0 +1,195 @@ +/* +Copyright 2021 Kong, Inc. + +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" + "time" + + v1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + scheme "github.com/kong/kubernetes-configuration/pkg/clientset/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// KonnectControlPlanesGetter has a method to return a KonnectControlPlaneInterface. +// A group's client should implement this interface. +type KonnectControlPlanesGetter interface { + KonnectControlPlanes(namespace string) KonnectControlPlaneInterface +} + +// KonnectControlPlaneInterface has methods to work with KonnectControlPlane resources. +type KonnectControlPlaneInterface interface { + Create(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.CreateOptions) (*v1alpha1.KonnectControlPlane, error) + Update(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.UpdateOptions) (*v1alpha1.KonnectControlPlane, error) + UpdateStatus(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.UpdateOptions) (*v1alpha1.KonnectControlPlane, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.KonnectControlPlane, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.KonnectControlPlaneList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.KonnectControlPlane, err error) + KonnectControlPlaneExpansion +} + +// konnectControlPlanes implements KonnectControlPlaneInterface +type konnectControlPlanes struct { + client rest.Interface + ns string +} + +// newKonnectControlPlanes returns a KonnectControlPlanes +func newKonnectControlPlanes(c *KonnectV1alpha1Client, namespace string) *konnectControlPlanes { + return &konnectControlPlanes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the konnectControlPlane, and returns the corresponding konnectControlPlane object, and an error if there is any. +func (c *konnectControlPlanes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.KonnectControlPlane, err error) { + result = &v1alpha1.KonnectControlPlane{} + err = c.client.Get(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of KonnectControlPlanes that match those selectors. +func (c *konnectControlPlanes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.KonnectControlPlaneList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.KonnectControlPlaneList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested konnectControlPlanes. +func (c *konnectControlPlanes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a konnectControlPlane and creates it. Returns the server's representation of the konnectControlPlane, and an error, if there is any. +func (c *konnectControlPlanes) Create(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.CreateOptions) (result *v1alpha1.KonnectControlPlane, err error) { + result = &v1alpha1.KonnectControlPlane{} + err = c.client.Post(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(konnectControlPlane). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a konnectControlPlane and updates it. Returns the server's representation of the konnectControlPlane, and an error, if there is any. +func (c *konnectControlPlanes) Update(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.UpdateOptions) (result *v1alpha1.KonnectControlPlane, err error) { + result = &v1alpha1.KonnectControlPlane{} + err = c.client.Put(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + Name(konnectControlPlane.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(konnectControlPlane). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *konnectControlPlanes) UpdateStatus(ctx context.Context, konnectControlPlane *v1alpha1.KonnectControlPlane, opts v1.UpdateOptions) (result *v1alpha1.KonnectControlPlane, err error) { + result = &v1alpha1.KonnectControlPlane{} + err = c.client.Put(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + Name(konnectControlPlane.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(konnectControlPlane). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the konnectControlPlane and deletes it. Returns an error if one occurs. +func (c *konnectControlPlanes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *konnectControlPlanes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched konnectControlPlane. +func (c *konnectControlPlanes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.KonnectControlPlane, err error) { + result = &v1alpha1.KonnectControlPlane{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("konnectcontrolplanes"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +}