diff --git a/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml b/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml new file mode 100644 index 000000000..31cb1015a --- /dev/null +++ b/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml @@ -0,0 +1,420 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.5 + name: boundapiresourceschemas.kube-bind.io +spec: + group: kube-bind.io + names: + categories: + - kube-bindings + kind: BoundAPIResourceSchema + listKind: BoundAPIResourceSchemaList + plural: boundapiresourceschemas + singular: boundapiresourceschema + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: BoundAPIResourceSchema + 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: BoundAPIResourceSchemaSpec defines the desired state of the + BoundAPIResourceSchema. + properties: + conversion: + description: conversion defines conversion settings for the defined + custom resource. + properties: + strategy: + description: |- + strategy specifies how custom resources are converted between versions. Allowed values are: + - `"None"`: The converter only change the apiVersion and would not touch any other field in the custom resource. + - `"Webhook"`: API Server will call to an external webhook to do the conversion. Additional information + is needed for this option. This requires spec.preserveUnknownFields to be false, and spec.conversion.webhook to be set. + enum: + - None + - Webhook + type: string + webhook: + description: webhook describes how to call the conversion webhook. + Required when `strategy` is set to `"Webhook"`. + properties: + clientConfig: + description: clientConfig is the instructions for how to call + the webhook if strategy is `Webhook`. + properties: + caBundle: + description: |- + caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. + If unspecified, system trust roots on the apiserver are used. + format: byte + type: string + url: + description: |- + url gives the location of the webhook, in standard URL form + (`scheme://host:port/path`). + + Please note that using `localhost` or `127.0.0.1` as a `host` is + risky unless you take great care to run this webhook on all hosts + which run an apiserver which might need to make calls to this + webhook. Such installs are likely to be non-portable, i.e., not easy + to turn up in a new cluster. + + The scheme must be "https"; the URL must begin with "https://". + + A path is optional, and if present may be any string permissible in + a URL. You may use the path to pass an arbitrary string to the + webhook, for example, a cluster identifier. + + Attempting to use a user or basic auth e.g. "user:password@" is not + allowed. Fragments ("#...") and query parameters ("?...") are not + allowed, either. + format: uri + type: string + type: object + conversionReviewVersions: + description: |- + conversionReviewVersions is an ordered list of preferred `ConversionReview` + versions the Webhook expects. The API server will use the first version in + the list which it supports. If none of the versions specified in this list + are supported by API server, conversion will fail for the custom resource. + If a persisted Webhook configuration specifies allowed versions and does not + include any versions known to the API Server, calls to the webhook will fail. + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + type: object + x-kubernetes-validations: + - message: Webhook must be specified if strategy=Webhook + rule: (self.strategy == 'None' && !has(self.webhook)) || (self.strategy + == 'Webhook' && has(self.webhook)) + group: + description: "group is the API group of the defined custom resource. + Empty string means the\ncore API group. \tThe resources are served + under `/apis//...` or `/api` for the core group." + type: string + informerScope: + allOf: + - enum: + - Cluster + - Namespaced + - enum: + - Cluster + - Namespaced + description: |- + InformerScope indicates whether the informer for defined custom resource is cluster- or namespace-scoped. + Allowed values are `Cluster` and `Namespaced`. + type: string + names: + description: names specify the resource and kind names for the custom + resource. + properties: + categories: + description: |- + categories is a list of grouped resources this custom resource belongs to (e.g. 'all'). + This is published in API discovery documents, and used by clients to support invocations like + `kubectl get all`. + items: + type: string + type: array + x-kubernetes-list-type: atomic + kind: + description: |- + kind is the serialized kind of the resource. It is normally CamelCase and singular. + Custom resource instances will use this value as the `kind` attribute in API calls. + type: string + listKind: + description: listKind is the serialized kind of the list for this + resource. Defaults to "`kind`List". + type: string + plural: + description: |- + plural is the plural name of the resource to serve. + The custom resources are served under `/apis///.../`. + Must match the name of the CustomResourceDefinition (in the form `.`). + Must be all lowercase. + type: string + shortNames: + description: |- + shortNames are short names for the resource, exposed in API discovery documents, + and used by clients to support invocations like `kubectl get `. + It must be all lowercase. + items: + type: string + type: array + x-kubernetes-list-type: atomic + singular: + description: singular is the singular name of the resource. It + must be all lowercase. Defaults to lowercased `kind`. + type: string + required: + - kind + - plural + type: object + scope: + description: |- + scope indicates whether the defined custom resource is cluster- or namespace-scoped. + Allowed values are `Cluster` and `Namespaced`. + enum: + - Cluster + - Namespaced + type: string + versions: + description: |- + versions is the API version of the defined custom resource. + + Note: the OpenAPI v3 schemas must be equal for all versions until CEL + version migration is supported. + items: + description: APIResourceVersion describes one API version of a resource. + properties: + additionalPrinterColumns: + description: |- + additionalPrinterColumns specifies additional columns returned in Table output. + See https://kubernetes.io/docs/reference/using-api/api-concepts/#receiving-resources-as-tables for details. + If no columns are specified, a single column displaying the age of the custom resource is used. + items: + description: CustomResourceColumnDefinition specifies a column + for server side printing. + properties: + description: + description: description is a human readable description + of this column. + type: string + format: + description: |- + format is an optional OpenAPI type definition for this column. The 'name' format is applied + to the primary identifier column to assist in clients identifying column is the resource name. + See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details. + type: string + jsonPath: + description: |- + jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against + each custom resource to produce the value for this column. + type: string + name: + description: name is a human readable name for the column. + type: string + priority: + description: |- + priority is an integer defining the relative importance of this column compared to others. Lower + numbers are considered higher priority. Columns that may be omitted in limited space scenarios + should be given a priority greater than 0. + format: int32 + type: integer + type: + description: |- + type is an OpenAPI type definition for this column. + See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details. + type: string + required: + - jsonPath + - name + - type + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + deprecated: + description: |- + deprecated indicates this version of the custom resource API is deprecated. + When set to true, API requests to this version receive a warning header in the server response. + Defaults to false. + type: boolean + deprecationWarning: + description: |- + deprecationWarning overrides the default warning returned to API clients. + May only be set when `deprecated` is true. + The default warning indicates this version is deprecated and recommends use + of the newest served version of equal or greater stability, if one exists. + type: string + name: + description: |- + name is the version name, e.g. “v1”, “v2beta1”, etc. + The custom resources are served under this version at `/apis///...` if `served` is true. + minLength: 1 + pattern: ^v[1-9][0-9]*([a-z]+[1-9][0-9]*)?$ + type: string + schema: + description: |- + schema describes the structural schema used for validation, pruning, and defaulting + of this version of the custom resource. + type: object + x-kubernetes-map-type: atomic + x-kubernetes-preserve-unknown-fields: true + served: + default: true + description: served is a flag enabling/disabling this version + from being served via REST APIs + type: boolean + storage: + description: |- + storage indicates this version should be used when persisting custom resources to storage. + There must be exactly one version with storage=true. + type: boolean + subresources: + description: subresources specify what subresources this version + of the defined custom resource have. + properties: + scale: + description: scale indicates the custom resource should + serve a `/scale` subresource that returns an `autoscaling/v1` + Scale object. + properties: + labelSelectorPath: + description: |- + labelSelectorPath defines the JSON path inside of a custom resource that corresponds to Scale `status.selector`. + Only JSON paths without the array notation are allowed. + Must be a JSON Path under `.status` or `.spec`. + Must be set to work with HorizontalPodAutoscaler. + The field pointed by this JSON path must be a string field (not a complex selector struct) + which contains a serialized label selector in string form. + More info: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions#scale-subresource + If there is no value under the given path in the custom resource, the `status.selector` value in the `/scale` + subresource will default to the empty string. + type: string + specReplicasPath: + description: |- + specReplicasPath defines the JSON path inside of a custom resource that corresponds to Scale `spec.replicas`. + Only JSON paths without the array notation are allowed. + Must be a JSON Path under `.spec`. + If there is no value under the given path in the custom resource, the `/scale` subresource will return an error on GET. + type: string + statusReplicasPath: + description: |- + statusReplicasPath defines the JSON path inside of a custom resource that corresponds to Scale `status.replicas`. + Only JSON paths without the array notation are allowed. + Must be a JSON Path under `.status`. + If there is no value under the given path in the custom resource, the `status.replicas` value in the `/scale` subresource + will default to 0. + type: string + required: + - specReplicasPath + - statusReplicasPath + type: object + status: + description: |- + status indicates the custom resource should serve a `/status` subresource. + When enabled: + 1. requests to the custom resource primary endpoint ignore changes to the `status` stanza of the object. + 2. requests to the custom resource `/status` subresource ignore changes to anything other than the `status` stanza of the object. + type: object + type: object + required: + - name + - schema + - served + - storage + type: object + minItems: 1 + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + required: + - group + - informerScope + - names + - scope + - versions + type: object + status: + description: BoundAPIResourceSchemaStatus defines the observed state of + the BoundAPIResourceSchema. + properties: + conditions: + description: Conditions represent the latest available observations + of the object's state. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + 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. + 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 + type: array + instantiations: + description: Instantiations tracks the number of instances of the + resource on the consumer side. + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go b/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go new file mode 100644 index 000000000..e15e9c970 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go @@ -0,0 +1,96 @@ +/* +Copyright 2025 The Kube Bind Authors. + +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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// BoundAPIResourceSchema +// +crd +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +type BoundAPIResourceSchema struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BoundAPIResourceSchemaSpec `json:"spec"` + Status BoundAPIResourceSchemaStatus `json:"status,omitempty"` +} + +// BoundAPIResourceSchemaSpec defines the desired state of the BoundAPIResourceSchema. +type BoundAPIResourceSchemaSpec struct { + // InformerScope indicates whether the informer for defined custom resource is cluster- or namespace-scoped. + // Allowed values are `Cluster` and `Namespaced`. + // + // +required + // +kubebuilder:validation:Enum=Cluster;Namespaced + InformerScope InformerScope `json:"informerScope"` + + APIResourceSchemaCRDSpec `json:",inline"` +} + +// BoundAPIResourceSchemaConditionType is type of BoundAPIResourceSchemaCondition +// +kubebuilder:validation:Enum=Valid;Invalid +type BoundAPIResourceSchemaConditionType string + +const ( + // BoundAPIResourceSchemaReady indicates that the API resource schema is ready. + // It is set to true when the API resource schema is accepted and there are no drifts detected. + BoundAPIResourceSchemaValid BoundAPIResourceSchemaConditionType = "Valid" + // BoundAPIResourceSchemaDriftDetected indicates that there is a drift between the consumer's API and the expected API. + // It is set to true when the API resource schema is not accepted or there are drifts detected. + BoundAPIResourceSchemaInvalid BoundAPIResourceSchemaConditionType = "Invalid" +) + +// BoundAPIResourceSchemaConditionReason is the set of reasons for specific condition type. +// +kubebuilder:validation:Enum=Accepted;Rejected;Pending;DriftDetected +type BoundAPIResourceSchemaConditionReason string + +const ( + // BoundAPIResourceSchemaAccepted indicates that the API resource schema is accepted. + BoundAPIResourceSchemaAccepted BoundAPIResourceSchemaConditionReason = "Accepted" + // BoundAPIResourceSchemaRejected indicates that the API resource schema is rejected. + BoundAPIResourceSchemaRejected BoundAPIResourceSchemaConditionReason = "Rejected" + // BoundAPIResourceSchemaPending indicates that the API resource schema is pending. + BoundAPIResourceSchemaPending BoundAPIResourceSchemaConditionReason = "Pending" + // BoundAPIResourceSchemaDriftDetected indicates that there is a drift between the consumer's API and the expected API. + BoundAPIResourceSchemaDriftDetected BoundAPIResourceSchemaConditionReason = "DriftDetected" +) + +// BoundAPIResourceSchemaStatus defines the observed state of the BoundAPIResourceSchema. +type BoundAPIResourceSchemaStatus struct { + // Conditions represent the latest available observations of the object's state. + // +optional + Conditions []metav1.Condition `json:"conditions,omitempty"` + + // Instantiations tracks the number of instances of the resource on the consumer side. + // +optional + Instantiations int `json:"instantiations,omitempty"` +} + +// BoundAPIResourceSchemaList is a list of BoundAPIResourceSchemas. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type BoundAPIResourceSchemaList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []BoundAPIResourceSchema `json:"items"` +} diff --git a/sdk/apis/kubebind/v1alpha2/register.go b/sdk/apis/kubebind/v1alpha2/register.go index 72700a89e..0225cb21b 100644 --- a/sdk/apis/kubebind/v1alpha2/register.go +++ b/sdk/apis/kubebind/v1alpha2/register.go @@ -47,6 +47,9 @@ func Resource(resource string) schema.GroupResource { func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &APIResourceSchema{}, + &APIResourceSchemaList{}, + &BoundAPIResourceSchema{}, + &BoundAPIResourceSchemaList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go b/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go index 0fa206039..411fe5052 100644 --- a/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go +++ b/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go @@ -23,6 +23,7 @@ package v1alpha2 import ( v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -160,6 +161,107 @@ func (in *APIResourceVersion) DeepCopy() *APIResourceVersion { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BoundAPIResourceSchema) DeepCopyInto(out *BoundAPIResourceSchema) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchema. +func (in *BoundAPIResourceSchema) DeepCopy() *BoundAPIResourceSchema { + if in == nil { + return nil + } + out := new(BoundAPIResourceSchema) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BoundAPIResourceSchema) 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 *BoundAPIResourceSchemaList) DeepCopyInto(out *BoundAPIResourceSchemaList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]BoundAPIResourceSchema, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchemaList. +func (in *BoundAPIResourceSchemaList) DeepCopy() *BoundAPIResourceSchemaList { + if in == nil { + return nil + } + out := new(BoundAPIResourceSchemaList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BoundAPIResourceSchemaList) 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 *BoundAPIResourceSchemaSpec) DeepCopyInto(out *BoundAPIResourceSchemaSpec) { + *out = *in + in.APIResourceSchemaCRDSpec.DeepCopyInto(&out.APIResourceSchemaCRDSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchemaSpec. +func (in *BoundAPIResourceSchemaSpec) DeepCopy() *BoundAPIResourceSchemaSpec { + if in == nil { + return nil + } + out := new(BoundAPIResourceSchemaSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BoundAPIResourceSchemaStatus) DeepCopyInto(out *BoundAPIResourceSchemaStatus) { + *out = *in + 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]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchemaStatus. +func (in *BoundAPIResourceSchemaStatus) DeepCopy() *BoundAPIResourceSchemaStatus { + if in == nil { + return nil + } + out := new(BoundAPIResourceSchemaStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CustomResourceConversion) DeepCopyInto(out *CustomResourceConversion) { *out = *in diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..cc1b3f870 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,70 @@ +/* +Copyright The Kube Bind Authors. + +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 v1alpha2 + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned/scheme" +) + +// BoundAPIResourceSchemasGetter has a method to return a BoundAPIResourceSchemaInterface. +// A group's client should implement this interface. +type BoundAPIResourceSchemasGetter interface { + BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaInterface +} + +// BoundAPIResourceSchemaInterface has methods to work with BoundAPIResourceSchema resources. +type BoundAPIResourceSchemaInterface interface { + Create(ctx context.Context, boundAPIResourceSchema *v1alpha2.BoundAPIResourceSchema, opts v1.CreateOptions) (*v1alpha2.BoundAPIResourceSchema, error) + Update(ctx context.Context, boundAPIResourceSchema *v1alpha2.BoundAPIResourceSchema, opts v1.UpdateOptions) (*v1alpha2.BoundAPIResourceSchema, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, boundAPIResourceSchema *v1alpha2.BoundAPIResourceSchema, opts v1.UpdateOptions) (*v1alpha2.BoundAPIResourceSchema, 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) (*v1alpha2.BoundAPIResourceSchema, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.BoundAPIResourceSchemaList, 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 *v1alpha2.BoundAPIResourceSchema, err error) + BoundAPIResourceSchemaExpansion +} + +// boundAPIResourceSchemas implements BoundAPIResourceSchemaInterface +type boundAPIResourceSchemas struct { + *gentype.ClientWithList[*v1alpha2.BoundAPIResourceSchema, *v1alpha2.BoundAPIResourceSchemaList] +} + +// newBoundAPIResourceSchemas returns a BoundAPIResourceSchemas +func newBoundAPIResourceSchemas(c *KubeBindV1alpha2Client, namespace string) *boundAPIResourceSchemas { + return &boundAPIResourceSchemas{ + gentype.NewClientWithList[*v1alpha2.BoundAPIResourceSchema, *v1alpha2.BoundAPIResourceSchemaList]( + "boundapiresourceschemas", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.BoundAPIResourceSchema { return &v1alpha2.BoundAPIResourceSchema{} }, + func() *v1alpha2.BoundAPIResourceSchemaList { return &v1alpha2.BoundAPIResourceSchemaList{} }), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_boundapiresourceschema.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_boundapiresourceschema.go new file mode 100644 index 000000000..597797297 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_boundapiresourceschema.go @@ -0,0 +1,148 @@ +/* +Copyright The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// FakeBoundAPIResourceSchemas implements BoundAPIResourceSchemaInterface +type FakeBoundAPIResourceSchemas struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var boundapiresourceschemasResource = v1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas") + +var boundapiresourceschemasKind = v1alpha2.SchemeGroupVersion.WithKind("BoundAPIResourceSchema") + +// Get takes name of the boundAPIResourceSchema, and returns the corresponding boundAPIResourceSchema object, and an error if there is any. +func (c *FakeBoundAPIResourceSchemas) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) { + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(boundapiresourceschemasResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), err +} + +// List takes label and field selectors, and returns the list of BoundAPIResourceSchemas that match those selectors. +func (c *FakeBoundAPIResourceSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.BoundAPIResourceSchemaList, err error) { + emptyResult := &v1alpha2.BoundAPIResourceSchemaList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(boundapiresourceschemasResource, boundapiresourceschemasKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.BoundAPIResourceSchemaList{ListMeta: obj.(*v1alpha2.BoundAPIResourceSchemaList).ListMeta} + for _, item := range obj.(*v1alpha2.BoundAPIResourceSchemaList).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 boundAPIResourceSchemas. +func (c *FakeBoundAPIResourceSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(boundapiresourceschemasResource, c.ns, opts)) + +} + +// Create takes the representation of a boundAPIResourceSchema and creates it. Returns the server's representation of the boundAPIResourceSchema, and an error, if there is any. +func (c *FakeBoundAPIResourceSchemas) Create(ctx context.Context, boundAPIResourceSchema *v1alpha2.BoundAPIResourceSchema, opts v1.CreateOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) { + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(boundapiresourceschemasResource, c.ns, boundAPIResourceSchema, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), err +} + +// Update takes the representation of a boundAPIResourceSchema and updates it. Returns the server's representation of the boundAPIResourceSchema, and an error, if there is any. +func (c *FakeBoundAPIResourceSchemas) Update(ctx context.Context, boundAPIResourceSchema *v1alpha2.BoundAPIResourceSchema, opts v1.UpdateOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) { + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(boundapiresourceschemasResource, c.ns, boundAPIResourceSchema, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), 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 *FakeBoundAPIResourceSchemas) UpdateStatus(ctx context.Context, boundAPIResourceSchema *v1alpha2.BoundAPIResourceSchema, opts v1.UpdateOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) { + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(boundapiresourceschemasResource, "status", c.ns, boundAPIResourceSchema, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), err +} + +// Delete takes name of the boundAPIResourceSchema and deletes it. Returns an error if one occurs. +func (c *FakeBoundAPIResourceSchemas) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(boundapiresourceschemasResource, c.ns, name, opts), &v1alpha2.BoundAPIResourceSchema{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeBoundAPIResourceSchemas) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(boundapiresourceschemasResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.BoundAPIResourceSchemaList{}) + return err +} + +// Patch applies the patch and returns the patched boundAPIResourceSchema. +func (c *FakeBoundAPIResourceSchemas) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.BoundAPIResourceSchema, err error) { + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(boundapiresourceschemasResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), err +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go index 429226072..3ca3482d0 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go @@ -33,6 +33,10 @@ func (c *FakeKubeBindV1alpha2) APIResourceSchemas(namespace string) v1alpha2.API return &FakeAPIResourceSchemas{c, namespace} } +func (c *FakeKubeBindV1alpha2) BoundAPIResourceSchemas(namespace string) v1alpha2.BoundAPIResourceSchemaInterface { + return &FakeBoundAPIResourceSchemas{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeKubeBindV1alpha2) RESTClient() rest.Interface { diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go index 4e3067937..12bb2639e 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go @@ -19,3 +19,5 @@ limitations under the License. package v1alpha2 type APIResourceSchemaExpansion interface{} + +type BoundAPIResourceSchemaExpansion interface{} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go index 1f77db9cc..22b850465 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go @@ -30,6 +30,7 @@ import ( type KubeBindV1alpha2Interface interface { RESTClient() rest.Interface APIResourceSchemasGetter + BoundAPIResourceSchemasGetter } // KubeBindV1alpha2Client is used to interact with features provided by the kube-bind.io group. @@ -41,6 +42,10 @@ func (c *KubeBindV1alpha2Client) APIResourceSchemas(namespace string) APIResourc return newAPIResourceSchemas(c, namespace) } +func (c *KubeBindV1alpha2Client) BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaInterface { + return newBoundAPIResourceSchemas(c, namespace) +} + // NewForConfig creates a new KubeBindV1alpha2Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/sdk/client/informers/externalversions/generic.go b/sdk/client/informers/externalversions/generic.go index f61e26520..c1257c790 100644 --- a/sdk/client/informers/externalversions/generic.go +++ b/sdk/client/informers/externalversions/generic.go @@ -69,6 +69,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=kube-bind.io, Version=v1alpha2 case v1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas"): return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIResourceSchemas().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().BoundAPIResourceSchemas().Informer()}, nil } diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..939fb9519 --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,91 @@ +/* +Copyright The Kube Bind Authors. + +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 informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + versioned "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" + internalinterfaces "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/internalinterfaces" + v1alpha2 "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" +) + +// BoundAPIResourceSchemaInformer provides access to a shared informer and lister for +// BoundAPIResourceSchemas. +type BoundAPIResourceSchemaInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.BoundAPIResourceSchemaLister +} + +type boundAPIResourceSchemaInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewBoundAPIResourceSchemaInformer constructs a new informer for BoundAPIResourceSchema type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBoundAPIResourceSchemaInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBoundAPIResourceSchemaInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredBoundAPIResourceSchemaInformer constructs a new informer for BoundAPIResourceSchema type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBoundAPIResourceSchemaInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().BoundAPIResourceSchemas(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().BoundAPIResourceSchemas(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.BoundAPIResourceSchema{}, + resyncPeriod, + indexers, + ) +} + +func (f *boundAPIResourceSchemaInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBoundAPIResourceSchemaInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *boundAPIResourceSchemaInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.BoundAPIResourceSchema{}, f.defaultInformer) +} + +func (f *boundAPIResourceSchemaInformer) Lister() v1alpha2.BoundAPIResourceSchemaLister { + return v1alpha2.NewBoundAPIResourceSchemaLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go index caee10c7f..1ee726c9e 100644 --- a/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go @@ -26,6 +26,8 @@ import ( type Interface interface { // APIResourceSchemas returns a APIResourceSchemaInformer. APIResourceSchemas() APIResourceSchemaInformer + // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaInformer. + BoundAPIResourceSchemas() BoundAPIResourceSchemaInformer } type version struct { @@ -43,3 +45,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (v *version) APIResourceSchemas() APIResourceSchemaInformer { return &aPIResourceSchemaInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// BoundAPIResourceSchemas returns a BoundAPIResourceSchemaInformer. +func (v *version) BoundAPIResourceSchemas() BoundAPIResourceSchemaInformer { + return &boundAPIResourceSchemaInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/sdk/client/listers/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/client/listers/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..b0d3a919a --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,71 @@ +/* +Copyright The Kube Bind Authors. + +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 lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// BoundAPIResourceSchemaLister helps list BoundAPIResourceSchemas. +// All objects returned here must be treated as read-only. +type BoundAPIResourceSchemaLister interface { + // List lists all BoundAPIResourceSchemas in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.BoundAPIResourceSchema, err error) + // BoundAPIResourceSchemas returns an object that can list and get BoundAPIResourceSchemas. + BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaNamespaceLister + BoundAPIResourceSchemaListerExpansion +} + +// boundAPIResourceSchemaLister implements the BoundAPIResourceSchemaLister interface. +type boundAPIResourceSchemaLister struct { + listers.ResourceIndexer[*v1alpha2.BoundAPIResourceSchema] +} + +// NewBoundAPIResourceSchemaLister returns a new BoundAPIResourceSchemaLister. +func NewBoundAPIResourceSchemaLister(indexer cache.Indexer) BoundAPIResourceSchemaLister { + return &boundAPIResourceSchemaLister{listers.New[*v1alpha2.BoundAPIResourceSchema](indexer, v1alpha2.Resource("boundapiresourceschema"))} +} + +// BoundAPIResourceSchemas returns an object that can list and get BoundAPIResourceSchemas. +func (s *boundAPIResourceSchemaLister) BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaNamespaceLister { + return boundAPIResourceSchemaNamespaceLister{listers.NewNamespaced[*v1alpha2.BoundAPIResourceSchema](s.ResourceIndexer, namespace)} +} + +// BoundAPIResourceSchemaNamespaceLister helps list and get BoundAPIResourceSchemas. +// All objects returned here must be treated as read-only. +type BoundAPIResourceSchemaNamespaceLister interface { + // List lists all BoundAPIResourceSchemas in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.BoundAPIResourceSchema, err error) + // Get retrieves the BoundAPIResourceSchema from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.BoundAPIResourceSchema, error) + BoundAPIResourceSchemaNamespaceListerExpansion +} + +// boundAPIResourceSchemaNamespaceLister implements the BoundAPIResourceSchemaNamespaceLister +// interface. +type boundAPIResourceSchemaNamespaceLister struct { + listers.ResourceIndexer[*v1alpha2.BoundAPIResourceSchema] +} diff --git a/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go b/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go index f2287acf0..96d5c4aca 100644 --- a/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go +++ b/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go @@ -25,3 +25,11 @@ type APIResourceSchemaListerExpansion interface{} // APIResourceSchemaNamespaceListerExpansion allows custom methods to be added to // APIResourceSchemaNamespaceLister. type APIResourceSchemaNamespaceListerExpansion interface{} + +// BoundAPIResourceSchemaListerExpansion allows custom methods to be added to +// BoundAPIResourceSchemaLister. +type BoundAPIResourceSchemaListerExpansion interface{} + +// BoundAPIResourceSchemaNamespaceListerExpansion allows custom methods to be added to +// BoundAPIResourceSchemaNamespaceLister. +type BoundAPIResourceSchemaNamespaceListerExpansion interface{} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..1656ac73f --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,86 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kube Bind Authors. + +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 kcp code-generator. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + + kcpclient "github.com/kcp-dev/apimachinery/v2/pkg/client" + "github.com/kcp-dev/logicalcluster/v3" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + kubebindv1alpha2client "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2" +) + +// BoundAPIResourceSchemasClusterGetter has a method to return a BoundAPIResourceSchemaClusterInterface. +// A group's cluster client should implement this interface. +type BoundAPIResourceSchemasClusterGetter interface { + BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInterface +} + +// BoundAPIResourceSchemaClusterInterface can operate on BoundAPIResourceSchemas across all clusters, +// or scope down to one cluster and return a BoundAPIResourceSchemasNamespacer. +type BoundAPIResourceSchemaClusterInterface interface { + Cluster(logicalcluster.Path) BoundAPIResourceSchemasNamespacer + List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.BoundAPIResourceSchemaList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) +} + +type boundAPIResourceSchemasClusterInterface struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] +} + +// Cluster scopes the client down to a particular cluster. +func (c *boundAPIResourceSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) BoundAPIResourceSchemasNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &boundAPIResourceSchemasNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} +} + +// List returns the entire collection of all BoundAPIResourceSchemas across all clusters. +func (c *boundAPIResourceSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.BoundAPIResourceSchemaList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).BoundAPIResourceSchemas(metav1.NamespaceAll).List(ctx, opts) +} + +// Watch begins to watch all BoundAPIResourceSchemas across all clusters. +func (c *boundAPIResourceSchemasClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).BoundAPIResourceSchemas(metav1.NamespaceAll).Watch(ctx, opts) +} + +// BoundAPIResourceSchemasNamespacer can scope to objects within a namespace, returning a kubebindv1alpha2client.BoundAPIResourceSchemaInterface. +type BoundAPIResourceSchemasNamespacer interface { + Namespace(string) kubebindv1alpha2client.BoundAPIResourceSchemaInterface +} + +type boundAPIResourceSchemasNamespacer struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] + clusterPath logicalcluster.Path +} + +func (n *boundAPIResourceSchemasNamespacer) Namespace(namespace string) kubebindv1alpha2client.BoundAPIResourceSchemaInterface { + return n.clientCache.ClusterOrDie(n.clusterPath).BoundAPIResourceSchemas(namespace) +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/boundapiresourceschema.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/boundapiresourceschema.go new file mode 100644 index 000000000..8fff69c69 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/boundapiresourceschema.go @@ -0,0 +1,213 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kube Bind Authors. + +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 kcp code-generator. DO NOT EDIT. + +package fake + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/kcp-dev/logicalcluster/v3" + + kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/testing" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + applyconfigurationskubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + kcpkubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2" + kubebindv1alpha2client "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2" +) + +var boundAPIResourceSchemasResource = schema.GroupVersionResource{Group: "kube-bind.io", Version: "v1alpha2", Resource: "boundapiresourceschemas"} +var boundAPIResourceSchemasKind = schema.GroupVersionKind{Group: "kube-bind.io", Version: "v1alpha2", Kind: "BoundAPIResourceSchema"} + +type boundAPIResourceSchemasClusterClient struct { + *kcptesting.Fake +} + +// Cluster scopes the client down to a particular cluster. +func (c *boundAPIResourceSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) kcpkubebindv1alpha2.BoundAPIResourceSchemasNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &boundAPIResourceSchemasNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +} + +// List takes label and field selectors, and returns the list of BoundAPIResourceSchemas that match those selectors across all clusters. +func (c *boundAPIResourceSchemasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.BoundAPIResourceSchemaList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(boundAPIResourceSchemasResource, boundAPIResourceSchemasKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &kubebindv1alpha2.BoundAPIResourceSchemaList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.BoundAPIResourceSchemaList{ListMeta: obj.(*kubebindv1alpha2.BoundAPIResourceSchemaList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.BoundAPIResourceSchemaList).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 BoundAPIResourceSchemas across all clusters. +func (c *boundAPIResourceSchemasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(boundAPIResourceSchemasResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +} + +type boundAPIResourceSchemasNamespacer struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path +} + +func (n *boundAPIResourceSchemasNamespacer) Namespace(namespace string) kubebindv1alpha2client.BoundAPIResourceSchemaInterface { + return &boundAPIResourceSchemasClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +} + +type boundAPIResourceSchemasClient struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path + Namespace string +} + +func (c *boundAPIResourceSchemasClient) Create(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchema, opts metav1.CreateOptions) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, boundAPIResourceSchema), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} + +func (c *boundAPIResourceSchemasClient) Update(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchema, opts metav1.UpdateOptions) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, boundAPIResourceSchema), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} + +func (c *boundAPIResourceSchemasClient) UpdateStatus(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchema, opts metav1.UpdateOptions) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(boundAPIResourceSchemasResource, c.ClusterPath, "status", c.Namespace, boundAPIResourceSchema), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} + +func (c *boundAPIResourceSchemasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, name, opts), &kubebindv1alpha2.BoundAPIResourceSchema{}) + return err +} + +func (c *boundAPIResourceSchemasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := kcptesting.NewDeleteCollectionAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, listOpts) + + _, err := c.Fake.Invokes(action, &kubebindv1alpha2.BoundAPIResourceSchemaList{}) + return err +} + +func (c *boundAPIResourceSchemasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + obj, err := c.Fake.Invokes(kcptesting.NewGetAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, name), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} + +// List takes label and field selectors, and returns the list of BoundAPIResourceSchemas that match those selectors. +func (c *boundAPIResourceSchemasClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.BoundAPIResourceSchemaList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(boundAPIResourceSchemasResource, boundAPIResourceSchemasKind, c.ClusterPath, c.Namespace, opts), &kubebindv1alpha2.BoundAPIResourceSchemaList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.BoundAPIResourceSchemaList{ListMeta: obj.(*kubebindv1alpha2.BoundAPIResourceSchemaList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.BoundAPIResourceSchemaList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +func (c *boundAPIResourceSchemasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, opts)) +} + +func (c *boundAPIResourceSchemasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} + +func (c *boundAPIResourceSchemasClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + if applyConfiguration == nil { + return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") + } + data, err := json.Marshal(applyConfiguration) + if err != nil { + return nil, err + } + name := applyConfiguration.Name + if name == nil { + return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") + } + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} + +func (c *boundAPIResourceSchemasClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + if applyConfiguration == nil { + return nil, fmt.Errorf("applyConfiguration provided to Apply must not be nil") + } + data, err := json.Marshal(applyConfiguration) + if err != nil { + return nil, err + } + name := applyConfiguration.Name + if name == nil { + return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") + } + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(boundAPIResourceSchemasResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.BoundAPIResourceSchema{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), err +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/kubebind_client.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/kubebind_client.go index 3131126b7..c65e1fbda 100644 --- a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/kubebind_client.go +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/kubebind_client.go @@ -48,6 +48,10 @@ func (c *KubeBindV1alpha2ClusterClient) APIResourceSchemas() kcpkubebindv1alpha2 return &aPIResourceSchemasClusterClient{Fake: c.Fake} } +func (c *KubeBindV1alpha2ClusterClient) BoundAPIResourceSchemas() kcpkubebindv1alpha2.BoundAPIResourceSchemaClusterInterface { + return &boundAPIResourceSchemasClusterClient{Fake: c.Fake} +} + var _ kubebindv1alpha2.KubeBindV1alpha2Interface = (*KubeBindV1alpha2Client)(nil) type KubeBindV1alpha2Client struct { @@ -63,3 +67,7 @@ func (c *KubeBindV1alpha2Client) RESTClient() rest.Interface { func (c *KubeBindV1alpha2Client) APIResourceSchemas(namespace string) kubebindv1alpha2.APIResourceSchemaInterface { return &aPIResourceSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} } + +func (c *KubeBindV1alpha2Client) BoundAPIResourceSchemas(namespace string) kubebindv1alpha2.BoundAPIResourceSchemaInterface { + return &boundAPIResourceSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/kubebind_client.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/kubebind_client.go index 82300fa55..916341162 100644 --- a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/kubebind_client.go +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/kubebind_client.go @@ -35,6 +35,7 @@ import ( type KubeBindV1alpha2ClusterInterface interface { KubeBindV1alpha2ClusterScoper APIResourceSchemasClusterGetter + BoundAPIResourceSchemasClusterGetter } type KubeBindV1alpha2ClusterScoper interface { @@ -56,6 +57,10 @@ func (c *KubeBindV1alpha2ClusterClient) APIResourceSchemas() APIResourceSchemaCl return &aPIResourceSchemasClusterInterface{clientCache: c.clientCache} } +func (c *KubeBindV1alpha2ClusterClient) BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInterface { + return &boundAPIResourceSchemasClusterInterface{clientCache: c.clientCache} +} + // NewForConfig creates a new KubeBindV1alpha2ClusterClient for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/sdk/kcp/informers/externalversions/generic.go b/sdk/kcp/informers/externalversions/generic.go index 2c960fdce..7f9f966e7 100644 --- a/sdk/kcp/informers/externalversions/generic.go +++ b/sdk/kcp/informers/externalversions/generic.go @@ -101,6 +101,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=kube-bind.io, Version=V1alpha2 case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIResourceSchemas().Informer()}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().BoundAPIResourceSchemas().Informer()}, nil } return nil, fmt.Errorf("no informer found for %v", resource) @@ -130,6 +132,9 @@ func (f *sharedScopedInformerFactory) ForResource(resource schema.GroupVersionRe case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas"): informer := f.KubeBind().V1alpha2().APIResourceSchemas().Informer() return &genericInformer{lister: cache.NewGenericLister(informer.GetIndexer(), resource.GroupResource()), informer: informer}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas"): + informer := f.KubeBind().V1alpha2().BoundAPIResourceSchemas().Informer() + return &genericInformer{lister: cache.NewGenericLister(informer.GetIndexer(), resource.GroupResource()), informer: informer}, nil } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..772cda048 --- /dev/null +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,182 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kube Bind Authors. + +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 kcp code-generator. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + "time" + + kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" + kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers" + "github.com/kcp-dev/logicalcluster/v3" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/tools/cache" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + scopedclientset "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned" + clientset "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/cluster" + "github.com/kube-bind/kube-bind/sdk/kcp/informers/externalversions/internalinterfaces" + kubebindv1alpha2listers "github.com/kube-bind/kube-bind/sdk/kcp/listers/kubebind/v1alpha2" +) + +// BoundAPIResourceSchemaClusterInformer provides access to a shared informer and lister for +// BoundAPIResourceSchemas. +type BoundAPIResourceSchemaClusterInformer interface { + Cluster(logicalcluster.Name) BoundAPIResourceSchemaInformer + Informer() kcpcache.ScopeableSharedIndexInformer + Lister() kubebindv1alpha2listers.BoundAPIResourceSchemaClusterLister +} + +type boundAPIResourceSchemaClusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewBoundAPIResourceSchemaClusterInformer constructs a new informer for BoundAPIResourceSchema type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBoundAPIResourceSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredBoundAPIResourceSchemaClusterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredBoundAPIResourceSchemaClusterInformer constructs a new informer for BoundAPIResourceSchema type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBoundAPIResourceSchemaClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) kcpcache.ScopeableSharedIndexInformer { + return kcpinformers.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().BoundAPIResourceSchemas().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().BoundAPIResourceSchemas().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.BoundAPIResourceSchema{}, + resyncPeriod, + indexers, + ) +} + +func (f *boundAPIResourceSchemaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredBoundAPIResourceSchemaClusterInformer(client, resyncPeriod, cache.Indexers{ + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, + f.tweakListOptions, + ) +} + +func (f *boundAPIResourceSchemaClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.BoundAPIResourceSchema{}, f.defaultInformer) +} + +func (f *boundAPIResourceSchemaClusterInformer) Lister() kubebindv1alpha2listers.BoundAPIResourceSchemaClusterLister { + return kubebindv1alpha2listers.NewBoundAPIResourceSchemaClusterLister(f.Informer().GetIndexer()) +} + +// BoundAPIResourceSchemaInformer provides access to a shared informer and lister for +// BoundAPIResourceSchemas. +type BoundAPIResourceSchemaInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2listers.BoundAPIResourceSchemaLister +} + +func (f *boundAPIResourceSchemaClusterInformer) Cluster(clusterName logicalcluster.Name) BoundAPIResourceSchemaInformer { + return &boundAPIResourceSchemaInformer{ + informer: f.Informer().Cluster(clusterName), + lister: f.Lister().Cluster(clusterName), + } +} + +type boundAPIResourceSchemaInformer struct { + informer cache.SharedIndexInformer + lister kubebindv1alpha2listers.BoundAPIResourceSchemaLister +} + +func (f *boundAPIResourceSchemaInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +func (f *boundAPIResourceSchemaInformer) Lister() kubebindv1alpha2listers.BoundAPIResourceSchemaLister { + return f.lister +} + +type boundAPIResourceSchemaScopedInformer struct { + factory internalinterfaces.SharedScopedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +func (f *boundAPIResourceSchemaScopedInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.BoundAPIResourceSchema{}, f.defaultInformer) +} + +func (f *boundAPIResourceSchemaScopedInformer) Lister() kubebindv1alpha2listers.BoundAPIResourceSchemaLister { + return kubebindv1alpha2listers.NewBoundAPIResourceSchemaLister(f.Informer().GetIndexer()) +} + +// NewBoundAPIResourceSchemaInformer constructs a new informer for BoundAPIResourceSchema type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBoundAPIResourceSchemaInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBoundAPIResourceSchemaInformer(client, resyncPeriod, namespace, indexers, nil) +} + +// NewFilteredBoundAPIResourceSchemaInformer constructs a new informer for BoundAPIResourceSchema type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBoundAPIResourceSchemaInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().BoundAPIResourceSchemas(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().BoundAPIResourceSchemas(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.BoundAPIResourceSchema{}, + resyncPeriod, + indexers, + ) +} + +func (f *boundAPIResourceSchemaScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBoundAPIResourceSchemaInformer(client, resyncPeriod, f.namespace, cache.Indexers{ + cache.NamespaceIndex: cache.MetaNamespaceIndexFunc, + }, f.tweakListOptions) +} diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/interface.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/interface.go index b48ba3bb2..c0f96a907 100644 --- a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/interface.go +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/interface.go @@ -28,6 +28,8 @@ import ( type ClusterInterface interface { // APIResourceSchemas returns a APIResourceSchemaClusterInformer APIResourceSchemas() APIResourceSchemaClusterInformer + // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaClusterInformer + BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInformer } type version struct { @@ -45,9 +47,16 @@ func (v *version) APIResourceSchemas() APIResourceSchemaClusterInformer { return &aPIResourceSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// BoundAPIResourceSchemas returns a BoundAPIResourceSchemaClusterInformer +func (v *version) BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInformer { + return &boundAPIResourceSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + type Interface interface { // APIResourceSchemas returns a APIResourceSchemaInformer APIResourceSchemas() APIResourceSchemaInformer + // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaInformer + BoundAPIResourceSchemas() BoundAPIResourceSchemaInformer } type scopedVersion struct { @@ -65,3 +74,8 @@ func NewScoped(f internalinterfaces.SharedScopedInformerFactory, namespace strin func (v *scopedVersion) APIResourceSchemas() APIResourceSchemaInformer { return &aPIResourceSchemaScopedInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// BoundAPIResourceSchemas returns a BoundAPIResourceSchemaInformer +func (v *scopedVersion) BoundAPIResourceSchemas() BoundAPIResourceSchemaInformer { + return &boundAPIResourceSchemaScopedInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..a534da14b --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,196 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kube Bind Authors. + +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 kcp code-generator. DO NOT EDIT. + +package v1alpha2 + +import ( + kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" + "github.com/kcp-dev/logicalcluster/v3" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// BoundAPIResourceSchemaClusterLister can list BoundAPIResourceSchemas across all workspaces, or scope down to a BoundAPIResourceSchemaLister for one workspace. +// All objects returned here must be treated as read-only. +type BoundAPIResourceSchemaClusterLister interface { + // List lists all BoundAPIResourceSchemas in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) + // Cluster returns a lister that can list and get BoundAPIResourceSchemas in one workspace. + Cluster(clusterName logicalcluster.Name) BoundAPIResourceSchemaLister + BoundAPIResourceSchemaClusterListerExpansion +} + +type boundAPIResourceSchemaClusterLister struct { + indexer cache.Indexer +} + +// NewBoundAPIResourceSchemaClusterLister returns a new BoundAPIResourceSchemaClusterLister. +// We assume that the indexer: +// - is fed by a cross-workspace LIST+WATCH +// - uses kcpcache.MetaClusterNamespaceKeyFunc as the key function +// - has the kcpcache.ClusterIndex as an index +// - has the kcpcache.ClusterAndNamespaceIndex as an index +func NewBoundAPIResourceSchemaClusterLister(indexer cache.Indexer) *boundAPIResourceSchemaClusterLister { + return &boundAPIResourceSchemaClusterLister{indexer: indexer} +} + +// List lists all BoundAPIResourceSchemas in the indexer across all workspaces. +func (s *boundAPIResourceSchemaClusterLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*kubebindv1alpha2.BoundAPIResourceSchema)) + }) + return ret, err +} + +// Cluster scopes the lister to one workspace, allowing users to list and get BoundAPIResourceSchemas. +func (s *boundAPIResourceSchemaClusterLister) Cluster(clusterName logicalcluster.Name) BoundAPIResourceSchemaLister { + return &boundAPIResourceSchemaLister{indexer: s.indexer, clusterName: clusterName} +} + +// BoundAPIResourceSchemaLister can list BoundAPIResourceSchemas across all namespaces, or scope down to a BoundAPIResourceSchemaNamespaceLister for one namespace. +// All objects returned here must be treated as read-only. +type BoundAPIResourceSchemaLister interface { + // List lists all BoundAPIResourceSchemas in the workspace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) + // BoundAPIResourceSchemas returns a lister that can list and get BoundAPIResourceSchemas in one workspace and namespace. + BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaNamespaceLister + BoundAPIResourceSchemaListerExpansion +} + +// boundAPIResourceSchemaLister can list all BoundAPIResourceSchemas inside a workspace or scope down to a BoundAPIResourceSchemaLister for one namespace. +type boundAPIResourceSchemaLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name +} + +// List lists all BoundAPIResourceSchemas in the indexer for a workspace. +func (s *boundAPIResourceSchemaLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) { + err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.BoundAPIResourceSchema)) + }) + return ret, err +} + +// BoundAPIResourceSchemas returns an object that can list and get BoundAPIResourceSchemas in one namespace. +func (s *boundAPIResourceSchemaLister) BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaNamespaceLister { + return &boundAPIResourceSchemaNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +} + +// boundAPIResourceSchemaNamespaceLister helps list and get BoundAPIResourceSchemas. +// All objects returned here must be treated as read-only. +type BoundAPIResourceSchemaNamespaceLister interface { + // List lists all BoundAPIResourceSchemas in the workspace and namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) + // Get retrieves the BoundAPIResourceSchema from the indexer for a given workspace, namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) + BoundAPIResourceSchemaNamespaceListerExpansion +} + +// boundAPIResourceSchemaNamespaceLister helps list and get BoundAPIResourceSchemas. +// All objects returned here must be treated as read-only. +type boundAPIResourceSchemaNamespaceLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name + namespace string +} + +// List lists all BoundAPIResourceSchemas in the indexer for a given workspace and namespace. +func (s *boundAPIResourceSchemaNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) { + err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.BoundAPIResourceSchema)) + }) + return ret, err +} + +// Get retrieves the BoundAPIResourceSchema from the indexer for a given workspace, namespace and name. +func (s *boundAPIResourceSchemaNamespaceLister) Get(name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) + obj, exists, err := s.indexer.GetByKey(key) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(kubebindv1alpha2.Resource("boundapiresourceschemas"), name) + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), nil +} + +// NewBoundAPIResourceSchemaLister returns a new BoundAPIResourceSchemaLister. +// We assume that the indexer: +// - is fed by a workspace-scoped LIST+WATCH +// - uses cache.MetaNamespaceKeyFunc as the key function +// - has the cache.NamespaceIndex as an index +func NewBoundAPIResourceSchemaLister(indexer cache.Indexer) *boundAPIResourceSchemaScopedLister { + return &boundAPIResourceSchemaScopedLister{indexer: indexer} +} + +// boundAPIResourceSchemaScopedLister can list all BoundAPIResourceSchemas inside a workspace or scope down to a BoundAPIResourceSchemaLister for one namespace. +type boundAPIResourceSchemaScopedLister struct { + indexer cache.Indexer +} + +// List lists all BoundAPIResourceSchemas in the indexer for a workspace. +func (s *boundAPIResourceSchemaScopedLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) { + err = cache.ListAll(s.indexer, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.BoundAPIResourceSchema)) + }) + return ret, err +} + +// BoundAPIResourceSchemas returns an object that can list and get BoundAPIResourceSchemas in one namespace. +func (s *boundAPIResourceSchemaScopedLister) BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaNamespaceLister { + return &boundAPIResourceSchemaScopedNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// boundAPIResourceSchemaScopedNamespaceLister helps list and get BoundAPIResourceSchemas. +type boundAPIResourceSchemaScopedNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all BoundAPIResourceSchemas in the indexer for a given workspace and namespace. +func (s *boundAPIResourceSchemaScopedNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.BoundAPIResourceSchema, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.BoundAPIResourceSchema)) + }) + return ret, err +} + +// Get retrieves the BoundAPIResourceSchema from the indexer for a given workspace, namespace and name. +func (s *boundAPIResourceSchemaScopedNamespaceLister) Get(name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + key := s.namespace + "/" + name + obj, exists, err := s.indexer.GetByKey(key) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(kubebindv1alpha2.Resource("boundapiresourceschemas"), name) + } + return obj.(*kubebindv1alpha2.BoundAPIResourceSchema), nil +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go new file mode 100644 index 000000000..38db5beeb --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go @@ -0,0 +1,31 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kube Bind Authors. + +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 kcp code-generator. DO NOT EDIT. + +package v1alpha2 + +// BoundAPIResourceSchemaClusterListerExpansion allows custom methods to be added to BoundAPIResourceSchemaClusterLister. +type BoundAPIResourceSchemaClusterListerExpansion interface{} + +// BoundAPIResourceSchemaListerExpansion allows custom methods to be added to BoundAPIResourceSchemaLister. +type BoundAPIResourceSchemaListerExpansion interface{} + +// BoundAPIResourceSchemaNamespaceListerExpansion allows custom methods to be added to BoundAPIResourceSchemaNamespaceLister. +type BoundAPIResourceSchemaNamespaceListerExpansion interface{}