diff --git a/CHANGELOG.md b/CHANGELOG.md index 04c7a5d416..865a036a83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,10 @@ Adding a new version? You'll need three changes: - Added functionality to the `KongUpstreamPolicy` controller to properly set and enforce `KongUpstreamPolicy` status. [#5185](https://github.com/Kong/kubernetes-ingress-controller/pull/5185) +- Add CRD `KongVault` to reperesent a custom Kong vault for storing senstive + data used in plugin configurations. + [#5354](https://github.com/Kong/kubernetes-ingress-controller/pull/5354) + ### Fixed diff --git a/config/crd/bases/configuration.konghq.com_kongvaults.yaml b/config/crd/bases/configuration.konghq.com_kongvaults.yaml new file mode 100644 index 0000000000..84b5dc4d41 --- /dev/null +++ b/config/crd/bases/configuration.konghq.com_kongvaults.yaml @@ -0,0 +1,169 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.13.0 + name: kongvaults.configuration.konghq.com +spec: + group: configuration.konghq.com + names: + kind: KongVault + listKind: KongVaultList + plural: kongvaults + singular: kongvault + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Name of the backend of the vault + jsonPath: .spec.backend + name: Backend-Type + type: string + - description: Prefix of vault URI to reference the values in the vault + jsonPath: .spec.prefix + name: Prefix + type: string + - description: Age + jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: Description + jsonPath: .spec.description + name: Description + priority: 1 + type: string + - jsonPath: .status.conditions[?(@.type=="Programmed")].status + name: Programmed + type: string + 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: + backend: + description: Backend is the type of the backend storing the values + in the vault. + minLength: 1 + type: string + config: + description: Config is the configuration of the vault. Varies for + different backends. + x-kubernetes-preserve-unknown-fields: true + description: + description: Description is the description to tell the information + about the vault. + type: string + prefix: + description: Prefix is the prefix of vault URI for referencing values + in the vault. + minLength: 1 + type: string + required: + - backend + - prefix + type: object + status: + 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 KongVaultStatus. + \n Known condition types are: \n * \"Programmed\"" + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + \n type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: \"Available\", + \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge + // +listType=map // +listMapKey=type Conditions []metav1.Condition + `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" + protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + 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 + required: + - conditions + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/docs/api-reference.md b/docs/api-reference.md index e4815ded8e..2a2298869b 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -320,6 +320,7 @@ _Appears in:_ Package v1alpha1 contains API Schema definitions for the configuration.konghq.com v1alpha1 API group. - [IngressClassParameters](#ingressclassparameters) +- [KongVault](#kongvault) ### IngressClassParameters @@ -339,6 +340,24 @@ IngressClassParameters is the Schema for the IngressClassParameters API. +### KongVault + + + + + + + +| Field | Description | +| --- | --- | +| `apiVersion` _string_ | `configuration.konghq.com/v1alpha1` +| `kind` _string_ | `KongVault` +| `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` _[KongVaultSpec](#kongvaultspec)_ | | + + + + ### IngressClassParametersSpec @@ -356,6 +375,27 @@ IngressClassParameters is the Schema for the IngressClassParameters API. _Appears in:_ - [IngressClassParameters](#ingressclassparameters) +### KongVaultSpec + + + + + + + +| Field | Description | +| --- | --- | +| `backend` _string_ | Backend is the type of the backend storing the values in the vault. | +| `prefix` _string_ | Prefix is the prefix of vault URI for referencing values in the vault. | +| `description` _string_ | Description is the description to tell the information about the vault. | +| `config` _[JSON](#json)_ | Config is the configuration of the vault. Varies for different backends. | + + +_Appears in:_ +- [KongVault](#kongvault) + + + ## configuration.konghq.com/v1beta1 diff --git a/pkg/apis/configuration/v1alpha1/kong_vault_types.go b/pkg/apis/configuration/v1alpha1/kong_vault_types.go new file mode 100644 index 0000000000..fa1ddcd5f1 --- /dev/null +++ b/pkg/apis/configuration/v1alpha1/kong_vault_types.go @@ -0,0 +1,85 @@ +/* +Copyright 2023 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. +*/ + +package v1alpha1 + +import ( + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + KongValtKind = "KongVault" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,shortName=kv,categories=kong-ingress-controller +// +kubebuilder:resource:path=kongvaults +// +kubebuilder:printcolumn:name="Backend-Type",type=string,JSONPath=`.spec.backend`,description="Name of the backend of the vault" +// +kubebuilder:printcolumn:name="Prefix",type=string,JSONPath=`.spec.prefix`,description="Prefix of vault URI to reference the values in the vault" +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age" +// +kubebuilder:printcolumn:name="Description",type=string,JSONPath=`.spec.description`,description="Description",priority=1 +// +kubebuilder:printcolumn:name="Programmed",type=string,JSONPath=`.status.conditions[?(@.type=="Programmed")].status` + +type KongVault struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec KongVaultSpec `json:"spec"` + Status KongVaultStatus `json:"status,omitempty"` +} + +type KongVaultSpec struct { + // Backend is the type of the backend storing the values in the vault. + // +kubebuilder:validation:MinLength=1 + Backend string `json:"backend"` + // Prefix is the prefix of vault URI for referencing values in the vault. + // +kubebuilder:validation:MinLength=1 + Prefix string `json:"prefix"` + // Description is the description to tell the information about the vault. + Description string `json:"description,omitempty"` + // Config is the configuration of the vault. Varies for different backends. + Config apiextensionsv1.JSON `json:"config,omitempty"` +} + +type KongVaultStatus struct { + // Conditions describe the current conditions of the KongVaultStatus. + // + // 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"` +} + +// +kubebuilder:object:root=true + +type KongVaultList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KongVault `json:"items"` +} + +func init() { + SchemeBuilder.Register(&KongVault{}, &KongVaultList{}) +} diff --git a/pkg/apis/configuration/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/configuration/v1alpha1/zz_generated.deepcopy.go index 2d81955367..d8e13fefdb 100644 --- a/pkg/apis/configuration/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/configuration/v1alpha1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -96,3 +97,100 @@ func (in *IngressClassParametersSpec) DeepCopy() *IngressClassParametersSpec { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KongVault) DeepCopyInto(out *KongVault) { + *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 KongVault. +func (in *KongVault) DeepCopy() *KongVault { + if in == nil { + return nil + } + out := new(KongVault) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KongVault) 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 *KongVaultList) DeepCopyInto(out *KongVaultList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KongVault, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KongVaultList. +func (in *KongVaultList) DeepCopy() *KongVaultList { + if in == nil { + return nil + } + out := new(KongVaultList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KongVaultList) 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 *KongVaultSpec) DeepCopyInto(out *KongVaultSpec) { + *out = *in + in.Config.DeepCopyInto(&out.Config) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KongVaultSpec. +func (in *KongVaultSpec) DeepCopy() *KongVaultSpec { + if in == nil { + return nil + } + out := new(KongVaultSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KongVaultStatus) DeepCopyInto(out *KongVaultStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KongVaultStatus. +func (in *KongVaultStatus) DeepCopy() *KongVaultStatus { + if in == nil { + return nil + } + out := new(KongVaultStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/clientset/typed/configuration/v1alpha1/configuration_client.go b/pkg/clientset/typed/configuration/v1alpha1/configuration_client.go index 1d8aa0f335..a1f95b76d2 100644 --- a/pkg/clientset/typed/configuration/v1alpha1/configuration_client.go +++ b/pkg/clientset/typed/configuration/v1alpha1/configuration_client.go @@ -29,6 +29,7 @@ import ( type ConfigurationV1alpha1Interface interface { RESTClient() rest.Interface IngressClassParametersesGetter + KongVaultsGetter } // ConfigurationV1alpha1Client is used to interact with features provided by the configuration.konghq.com group. @@ -40,6 +41,10 @@ func (c *ConfigurationV1alpha1Client) IngressClassParameterses(namespace string) return newIngressClassParameterses(c, namespace) } +func (c *ConfigurationV1alpha1Client) KongVaults(namespace string) KongVaultInterface { + return newKongVaults(c, namespace) +} + // NewForConfig creates a new ConfigurationV1alpha1Client 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/configuration/v1alpha1/fake/fake_configuration_client.go b/pkg/clientset/typed/configuration/v1alpha1/fake/fake_configuration_client.go index 9d5c81a6b9..79ae0a6d7a 100644 --- a/pkg/clientset/typed/configuration/v1alpha1/fake/fake_configuration_client.go +++ b/pkg/clientset/typed/configuration/v1alpha1/fake/fake_configuration_client.go @@ -32,6 +32,10 @@ func (c *FakeConfigurationV1alpha1) IngressClassParameterses(namespace string) v return &FakeIngressClassParameterses{c, namespace} } +func (c *FakeConfigurationV1alpha1) KongVaults(namespace string) v1alpha1.KongVaultInterface { + return &FakeKongVaults{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeConfigurationV1alpha1) RESTClient() rest.Interface { diff --git a/pkg/clientset/typed/configuration/v1alpha1/fake/fake_kongvault.go b/pkg/clientset/typed/configuration/v1alpha1/fake/fake_kongvault.go new file mode 100644 index 0000000000..1aa823ef21 --- /dev/null +++ b/pkg/clientset/typed/configuration/v1alpha1/fake/fake_kongvault.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-ingress-controller/v3/pkg/apis/configuration/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" +) + +// FakeKongVaults implements KongVaultInterface +type FakeKongVaults struct { + Fake *FakeConfigurationV1alpha1 + ns string +} + +var kongvaultsResource = v1alpha1.SchemeGroupVersion.WithResource("kongvaults") + +var kongvaultsKind = v1alpha1.SchemeGroupVersion.WithKind("KongVault") + +// Get takes name of the kongVault, and returns the corresponding kongVault object, and an error if there is any. +func (c *FakeKongVaults) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.KongVault, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(kongvaultsResource, c.ns, name), &v1alpha1.KongVault{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KongVault), err +} + +// List takes label and field selectors, and returns the list of KongVaults that match those selectors. +func (c *FakeKongVaults) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.KongVaultList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(kongvaultsResource, kongvaultsKind, c.ns, opts), &v1alpha1.KongVaultList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.KongVaultList{ListMeta: obj.(*v1alpha1.KongVaultList).ListMeta} + for _, item := range obj.(*v1alpha1.KongVaultList).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 kongVaults. +func (c *FakeKongVaults) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(kongvaultsResource, c.ns, opts)) + +} + +// Create takes the representation of a kongVault and creates it. Returns the server's representation of the kongVault, and an error, if there is any. +func (c *FakeKongVaults) Create(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.CreateOptions) (result *v1alpha1.KongVault, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(kongvaultsResource, c.ns, kongVault), &v1alpha1.KongVault{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KongVault), err +} + +// Update takes the representation of a kongVault and updates it. Returns the server's representation of the kongVault, and an error, if there is any. +func (c *FakeKongVaults) Update(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.UpdateOptions) (result *v1alpha1.KongVault, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(kongvaultsResource, c.ns, kongVault), &v1alpha1.KongVault{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KongVault), 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 *FakeKongVaults) UpdateStatus(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.UpdateOptions) (*v1alpha1.KongVault, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(kongvaultsResource, "status", c.ns, kongVault), &v1alpha1.KongVault{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KongVault), err +} + +// Delete takes name of the kongVault and deletes it. Returns an error if one occurs. +func (c *FakeKongVaults) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(kongvaultsResource, c.ns, name, opts), &v1alpha1.KongVault{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeKongVaults) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(kongvaultsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.KongVaultList{}) + return err +} + +// Patch applies the patch and returns the patched kongVault. +func (c *FakeKongVaults) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.KongVault, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(kongvaultsResource, c.ns, name, pt, data, subresources...), &v1alpha1.KongVault{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.KongVault), err +} diff --git a/pkg/clientset/typed/configuration/v1alpha1/generated_expansion.go b/pkg/clientset/typed/configuration/v1alpha1/generated_expansion.go index 9e173e0e92..aff707cc29 100644 --- a/pkg/clientset/typed/configuration/v1alpha1/generated_expansion.go +++ b/pkg/clientset/typed/configuration/v1alpha1/generated_expansion.go @@ -19,3 +19,5 @@ limitations under the License. package v1alpha1 type IngressClassParametersExpansion interface{} + +type KongVaultExpansion interface{} diff --git a/pkg/clientset/typed/configuration/v1alpha1/kongvault.go b/pkg/clientset/typed/configuration/v1alpha1/kongvault.go new file mode 100644 index 0000000000..7e276eeef6 --- /dev/null +++ b/pkg/clientset/typed/configuration/v1alpha1/kongvault.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-ingress-controller/v3/pkg/apis/configuration/v1alpha1" + scheme "github.com/kong/kubernetes-ingress-controller/v3/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" +) + +// KongVaultsGetter has a method to return a KongVaultInterface. +// A group's client should implement this interface. +type KongVaultsGetter interface { + KongVaults(namespace string) KongVaultInterface +} + +// KongVaultInterface has methods to work with KongVault resources. +type KongVaultInterface interface { + Create(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.CreateOptions) (*v1alpha1.KongVault, error) + Update(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.UpdateOptions) (*v1alpha1.KongVault, error) + UpdateStatus(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.UpdateOptions) (*v1alpha1.KongVault, 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.KongVault, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.KongVaultList, 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.KongVault, err error) + KongVaultExpansion +} + +// kongVaults implements KongVaultInterface +type kongVaults struct { + client rest.Interface + ns string +} + +// newKongVaults returns a KongVaults +func newKongVaults(c *ConfigurationV1alpha1Client, namespace string) *kongVaults { + return &kongVaults{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the kongVault, and returns the corresponding kongVault object, and an error if there is any. +func (c *kongVaults) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.KongVault, err error) { + result = &v1alpha1.KongVault{} + err = c.client.Get(). + Namespace(c.ns). + Resource("kongvaults"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of KongVaults that match those selectors. +func (c *kongVaults) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.KongVaultList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.KongVaultList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("kongvaults"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested kongVaults. +func (c *kongVaults) 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("kongvaults"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a kongVault and creates it. Returns the server's representation of the kongVault, and an error, if there is any. +func (c *kongVaults) Create(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.CreateOptions) (result *v1alpha1.KongVault, err error) { + result = &v1alpha1.KongVault{} + err = c.client.Post(). + Namespace(c.ns). + Resource("kongvaults"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(kongVault). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a kongVault and updates it. Returns the server's representation of the kongVault, and an error, if there is any. +func (c *kongVaults) Update(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.UpdateOptions) (result *v1alpha1.KongVault, err error) { + result = &v1alpha1.KongVault{} + err = c.client.Put(). + Namespace(c.ns). + Resource("kongvaults"). + Name(kongVault.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(kongVault). + 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 *kongVaults) UpdateStatus(ctx context.Context, kongVault *v1alpha1.KongVault, opts v1.UpdateOptions) (result *v1alpha1.KongVault, err error) { + result = &v1alpha1.KongVault{} + err = c.client.Put(). + Namespace(c.ns). + Resource("kongvaults"). + Name(kongVault.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(kongVault). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the kongVault and deletes it. Returns an error if one occurs. +func (c *kongVaults) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("kongvaults"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *kongVaults) 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("kongvaults"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched kongVault. +func (c *kongVaults) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.KongVault, err error) { + result = &v1alpha1.KongVault{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("kongvaults"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +}