diff --git a/.golangci.yaml b/.golangci.yaml index aa8296c75..d9f2cf39d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -68,6 +68,9 @@ linters: - linters: - goconst path: (.+)_test\.go + - linters: + - staticcheck + text: QF1008 paths: - pkg/client - third_party$ diff --git a/Makefile b/Makefile index 051005e64..bf97a9ea5 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ SHELL := /usr/bin/env bash -e GO_INSTALL = ./hack/go-install.sh +ROOT_DIR=$(abspath .) TOOLS_DIR=hack/tools TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR)) GOBIN_DIR=$(abspath ./bin ) @@ -151,9 +152,13 @@ $(CODE_GENERATOR): GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/code-generator/v2 $(CODE_GENERATOR_BIN) $(CODE_GENERATOR_VER) lint: $(GOLANGCI_LINT) $(LOGCHECK) ## Run linters - $(GOLANGCI_LINT) run ./... + $(GOLANGCI_LINT) run $(GOLANGCI_LINT_FLAGS) -c $(ROOT_DIR)/.golangci.yaml --timeout 20m .PHONY: lint +fix-lint: $(GOLANGCI_LINT) + GOLANGCI_LINT_FLAGS="--fix" $(MAKE) lint +.PHONY: fix-lint + vendor: ## Vendor the dependencies go mod tidy go mod vendor @@ -250,6 +255,9 @@ $(KCP): tar xz -C "$(TOOLS_DIR)" --strip-components="1" bin/kcp mv $(TOOLS_DIR)/kcp $(KCP) +run-kcp: $(KCP) + $(KCP) start + .PHONY: test-e2e ifdef USE_GOTESTSUM test-e2e: $(GOTESTSUM) @@ -354,7 +362,7 @@ image-local: @echo "Successfully built local images with tag $(REV)" .PHONY: kind-load -kind-load: image-local ## Load locally built images into kind cluster +kind-load: @echo "Loading images into kind cluster '$(KIND_CLUSTER)'" kind load docker-image $(KO_DOCKER_REPO)/konnector:$(REV) --name $(KIND_CLUSTER) kind load docker-image $(KO_DOCKER_REPO)/example-backend:$(REV) --name $(KIND_CLUSTER) diff --git a/README.md b/README.md index a714a2be0..0f1af7403 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # kube-bind -### Disclaimer: work in progress and not ready for production use. +### Disclaimer: work in progress and not ready for production use. You are invited to [contribute](#contributing)! @@ -26,9 +26,9 @@ $ kubectl krew index add bind https://github.com/kube-bind/krew-index.git $ kubectl krew install bind/bind $ kubectl bind https://mangodb/exports Redirect to the brower to authenticate via OIDC. -BOOM – the MangoDB API is available in the local cluster, +BOOM – the MangoDB API is available in the local cluster, without anything MangoDB-specific running. -$ kubectl get mangodbs +$ kubectl get mangodbs ``` ## For more information @@ -42,7 +42,7 @@ The kube-bind prototype is following this manifesto from the linked talk: ## Contributing -We ❤️ our contributors! If you're interested in helping us out, please check out +We ❤️ our contributors! If you're interested in helping us out, please check out [Contributing to kube-bind](./CONTRIBUTING.md) and [kube-bind Project Governance](./GOVERNANCE.md). ## Getting in touch @@ -60,54 +60,25 @@ All the actions shown between the clusters are done by the konnector, except: th ## Usage -To run the current backend, there must be an OIDC issuer installed in place to do the -the oauth2 workflow. - -We use dex to manage OIDC, following the steps below you can run a local OIDC issuer using dex: -* First, clone the dex repo: `git clone https://github.com/dexidp/dex.git` -* `cd dex` and then build the dex binary `make build` -* The binary will be created in `bin/dex` -* Adjust the config file(`examples/config-dev.yaml`) for dex by specifying the server callback method: -```yaml -staticClients: -- id: kube-bind - redirectURIs: - - 'http://127.0.0.1:8080/callback' - name: 'Kube Bind' -``` -* Run dex: `./bin/dex serve examples/config-dev.yaml` +To get familiar with setting up the environment, please check out docs at [kube-bind.io](https://docs.kube-bind.io/main/setup). -Next you should be able to run the backend. For it you need a kubernetes cluster (e.g. kind) -accessible. +## API Changes in coming v0.5.0 release -***Note: make sure before running the backend that you have the dex server up and running as mentioned above -and that you have at least one k8s cluster. Take a look at the backend option in the cmd/main.go file*** +Version v0.5.0 includes significant architectural improvements to the API structure: -* apply the CRDs: `kubectl apply -f deploy/crd` -* In order to populate binding list on website, we need a CRD with label `kube-bind.io/exported: true`. Apply example CRD: `kubectl apply -f deploy/examples/crd-mangodb.yaml` -* start the backend binary with the right flags: -```shell -$ make build -$ bin/example-backend \ - --oidc-issuer-client-secret=ZXhhbXBsZS1hcHAtc2VjcmV0 \ - --oidc-issuer-client-id=kube-bind \ - --oidc-issuer-url=http://127.0.0.1:5556/dex \ - --oidc-callback-url=http://127.0.0.1:8080/callback \ - --pretty-name="BigCorp.com" \ - --namespace-prefix="kube-bind-" \ - --cookie-signing-key=bGMHz7SR9XcI9JdDB68VmjQErrjbrAR9JdVqjAOKHzE= \ - --cookie-encryption-key=wadqi4u+w0bqnSrVFtM38Pz2ykYVIeeadhzT34XlC1Y= -``` +### Major Changes -where `ZXhhbXBsZS1hcHAtc2VjcmV0` matches the value of the dex config file. +- **API Version Upgrade**: Introduced `v1alpha2` API version with improved stability and features +- **Service Exposure Refactoring**: Completely refactored the service exposure mechanism to use: + - `APIResourceSchema`: Define the schema of exported CRDs, allowing one APIServiceExport to reference multiple CRDs. + - `BoundAPIResourceSchema`: Represent bound schemas in consumer clusters and underlying status of synced resources. -The `--cookie-signing-key` and `--cookie-encryption-key` settings can be generated using: -```shell -$ openssl rand -base64 32 -WQh88mNOY0Z3tLy1/WOud7qIEEBxz+POc4j8BsYenYo= -``` +### Limitations -The `--cookie-signing-key` option is required and supports 32 and 64 byte lengths. -The `--cookie-encryption-key` option is optional and supports byte lengths of 16, 24, 32 for AES-128, AES-192, or AES-256. +These limitations are part of the roadmap and will be addressed in the future. -* with a KUBECONFIG against another cluster (a consumer cluster) bind a service: `kubectl bind http://127.0.0.1:8080/export`. +* Currently we don't support related resources, like ConfigMaps, Secrets +* Currently CRD resources MUST be installed in the provider cluster, even when APIResourceSchema is used. + This is to allow the konnector to sync instances of the CRD to the consumer cluster. + This should be removed once we introduce sync policies and object wrappers. +* Currently we dont support granular permissions, like only allow to read/write certain named resources. diff --git a/cli/go.mod b/cli/go.mod index 2ddc71fcb..19bdf0f39 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -2,15 +2,19 @@ module github.com/kube-bind/kube-bind/cli go 1.23.4 -replace github.com/kube-bind/kube-bind/sdk/apis => ../sdk/apis +replace ( + github.com/kube-bind/kube-bind => ../ + github.com/kube-bind/kube-bind/sdk/apis => ../sdk/apis + github.com/kube-bind/kube-bind/sdk/client => ../sdk/client +) require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/blang/semver/v4 v4.0.0 github.com/fatih/color v1.18.0 - github.com/kube-bind/kube-bind v0.4.6 - github.com/kube-bind/kube-bind/sdk/apis v0.4.6 - github.com/kube-bind/kube-bind/sdk/client v0.4.6 + github.com/kube-bind/kube-bind v0.0.0-00010101000000-000000000000 + github.com/kube-bind/kube-bind/sdk/apis v0.4.8 + github.com/kube-bind/kube-bind/sdk/client v0.0.0-20250515145715-d9f20e7c840d github.com/mdp/qrterminal/v3 v3.2.0 github.com/muesli/reflow v0.3.0 github.com/spf13/cobra v1.8.1 diff --git a/cli/go.sum b/cli/go.sum index 2dffcd62f..2124d54eb 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -115,10 +115,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kube-bind/kube-bind v0.4.6 h1:XOa1Ac3tn5aJARni/f9+rNcvr4XEzRGXlzWhn0kkbVo= -github.com/kube-bind/kube-bind v0.4.6/go.mod h1:+xqzeod5hyVPEe0GaZXAnhaipmH5pusNfPmyVALkvcA= -github.com/kube-bind/kube-bind/sdk/client v0.4.6 h1:zcBA3qWAnRmbRaZZX62JPdLUA30n0CrE+fxzEowH0Ok= -github.com/kube-bind/kube-bind/sdk/client v0.4.6/go.mod h1:BaLx9LytSHd6s+VRNiNdleqnNzHoV1A5AoUvskyJ9tc= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= diff --git a/cli/pkg/crd2apiresourceschema/plugin/crd2apiresourceschema.go b/cli/pkg/crd2apiresourceschema/plugin/crd2apiresourceschema.go index 16252af56..f8c4b7489 100644 --- a/cli/pkg/crd2apiresourceschema/plugin/crd2apiresourceschema.go +++ b/cli/pkg/crd2apiresourceschema/plugin/crd2apiresourceschema.go @@ -18,7 +18,6 @@ package plugin import ( "context" - "encoding/json" "errors" "fmt" "io" @@ -41,6 +40,7 @@ import ( "github.com/kube-bind/kube-bind/cli/pkg/kubectl/base" kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers" ) type CRD2APIResourceSchemaOptions struct { @@ -116,7 +116,7 @@ func (b *CRD2APIResourceSchemaOptions) Run(ctx context.Context) error { } prefix := fmt.Sprintf("v%s-%s", time.Now().Format("060102"), string(version.Get().GitCommit)) - apiResourceSchema, err := convertCRDToAPIResourceSchema(crdObj, prefix) + apiResourceSchema, err := helpers.CRDToAPIResourceSchema(crdObj, prefix) if err != nil { fmt.Fprintf(b.Options.ErrOut, "Failed to convert CRD %s to APIResourceSchema: %v\n", crdObj.Name, err) continue @@ -158,82 +158,6 @@ func generateAPIResourceSchemaInCluster(ctx context.Context, client dynamic.Inte return nil } -func convertCRDToAPIResourceSchema(crd *apiextensionsv1.CustomResourceDefinition, prefix string) (*kubebindv1alpha2.APIResourceSchema, error) { - name := prefix + "." + crd.Name - informerScope := kubebindv1alpha2.NamespacedScope - apiResourceSchema := &kubebindv1alpha2.APIResourceSchema{ - TypeMeta: metav1.TypeMeta{ - APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), - Kind: "APIResourceSchema", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - }, - Spec: kubebindv1alpha2.APIResourceSchemaSpec{ - InformerScope: informerScope, - APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{ - Group: crd.Spec.Group, - Names: crd.Spec.Names, - Scope: crd.Spec.Scope, - }, - }, - } - - if len(crd.Spec.Versions) > 1 && crd.Spec.Conversion == nil { - return nil, fmt.Errorf("multiple versions specified for CRD %q but no conversion strategy", crd.Name) - } - - if crd.Spec.Conversion != nil { - crConversion := &kubebindv1alpha2.CustomResourceConversion{ - Strategy: kubebindv1alpha2.ConversionStrategyType(crd.Spec.Conversion.Strategy), - } - - if crd.Spec.Conversion.Strategy == "Webhook" { - crConversion.Webhook = &kubebindv1alpha2.WebhookConversion{ - ConversionReviewVersions: crd.Spec.Conversion.Webhook.ConversionReviewVersions, - } - - if crd.Spec.Conversion.Webhook.ClientConfig != nil { - crConversion.Webhook.ClientConfig = &kubebindv1alpha2.WebhookClientConfig{ - URL: crd.Spec.Conversion.Webhook.ClientConfig.URL, - CABundle: crd.Spec.Conversion.Webhook.ClientConfig.CABundle, - } - } - } - - apiResourceSchema.Spec.Conversion = crConversion - } - - for i := range crd.Spec.Versions { - crdVersion := crd.Spec.Versions[i] - - apiResourceVersion := kubebindv1alpha2.APIResourceVersion{ - Name: crdVersion.Name, - Served: crdVersion.Served, - Storage: crdVersion.Storage, - Deprecated: crdVersion.Deprecated, - DeprecationWarning: crdVersion.DeprecationWarning, - AdditionalPrinterColumns: crdVersion.AdditionalPrinterColumns, - } - - if crdVersion.Schema != nil && crdVersion.Schema.OpenAPIV3Schema != nil { - rawSchema, err := json.Marshal(crdVersion.Schema.OpenAPIV3Schema) - if err != nil { - return nil, fmt.Errorf("error converting schema for version %q: %w", crdVersion.Name, err) - } - apiResourceVersion.Schema = runtime.RawExtension{Raw: rawSchema} - } - - if crdVersion.Subresources != nil { - apiResourceVersion.Subresources = *crdVersion.Subresources - } - - apiResourceSchema.Spec.Versions = append(apiResourceSchema.Spec.Versions, apiResourceVersion) - } - - return apiResourceSchema, nil -} - func writeObjectToYAML(outputDir string, apiResourceSchema *kubebindv1alpha2.APIResourceSchema, logger io.Writer) error { if err := os.MkdirAll(outputDir, 0755); err != nil { return fmt.Errorf("failed to create output directory %s: %w", outputDir, err) diff --git a/cli/pkg/kubectl/bind-apiservice/plugin/bind.go b/cli/pkg/kubectl/bind-apiservice/plugin/bind.go index 17d865372..9ca25a2dd 100644 --- a/cli/pkg/kubectl/bind-apiservice/plugin/bind.go +++ b/cli/pkg/kubectl/bind-apiservice/plugin/bind.go @@ -40,7 +40,7 @@ import ( "sigs.k8s.io/yaml" "github.com/kube-bind/kube-bind/cli/pkg/kubectl/base" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) // BindAPIServiceOptions are the options for the kubectl-bind-apiservice command. @@ -257,12 +257,12 @@ func (b *BindAPIServiceOptions) getRequestManifest() ([]byte, error) { return body, nil } -func (b *BindAPIServiceOptions) unmarshalManifest(bs []byte) (*kubebindv1alpha1.APIServiceExportRequest, error) { - var request kubebindv1alpha1.APIServiceExportRequest +func (b *BindAPIServiceOptions) unmarshalManifest(bs []byte) (*kubebindv1alpha2.APIServiceExportRequest, error) { + var request kubebindv1alpha2.APIServiceExportRequest if err := yaml.Unmarshal(bs, &request); err != nil { return nil, fmt.Errorf("failed to unmarshal manifest: %w", err) } - if request.APIVersion != kubebindv1alpha1.SchemeGroupVersion.String() { + if request.APIVersion != kubebindv1alpha2.SchemeGroupVersion.String() { return nil, fmt.Errorf("invalid apiVersion %q", request.APIVersion) } if request.Kind != "APIServiceExportRequest" { diff --git a/cli/pkg/kubectl/bind-apiservice/plugin/konnector.go b/cli/pkg/kubectl/bind-apiservice/plugin/konnector.go index 3d8753eac..fcbcf35f0 100644 --- a/cli/pkg/kubectl/bind-apiservice/plugin/konnector.go +++ b/cli/pkg/kubectl/bind-apiservice/plugin/konnector.go @@ -111,7 +111,7 @@ func (b *BindAPIServiceOptions) deployKonnector(ctx context.Context, config *res } first := true return wait.PollUntilContextCancel(ctx, 1*time.Second, true, func(ctx context.Context) (bool, error) { - _, err := bindClient.KubeBindV1alpha1().APIServiceBindings().List(ctx, metav1.ListOptions{}) + _, err := bindClient.KubeBindV1alpha2().APIServiceBindings().List(ctx, metav1.ListOptions{}) if err == nil { if !first { fmt.Fprintln(b.Options.IOStreams.ErrOut) //nolint:errcheck diff --git a/cli/pkg/kubectl/bind-apiservice/plugin/servicebindings.go b/cli/pkg/kubectl/bind-apiservice/plugin/servicebindings.go index 167f1f53a..47ef89fd7 100644 --- a/cli/pkg/kubectl/bind-apiservice/plugin/servicebindings.go +++ b/cli/pkg/kubectl/bind-apiservice/plugin/servicebindings.go @@ -27,14 +27,14 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/rest" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" - "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1/helpers" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" ) -func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, config *rest.Config, request *kubebindv1alpha1.APIServiceExportRequest, secretName string) ([]*kubebindv1alpha1.APIServiceBinding, error) { +func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, config *rest.Config, request *kubebindv1alpha2.APIServiceExportRequest, secretName string) ([]*kubebindv1alpha2.APIServiceBinding, error) { bindClient, err := bindclient.NewForConfig(config) if err != nil { return nil, err @@ -44,10 +44,10 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co return nil, err } - var bindings []*kubebindv1alpha1.APIServiceBinding + var bindings []*kubebindv1alpha2.APIServiceBinding for _, resource := range request.Spec.Resources { name := resource.Resource + "." + resource.Group - existing, err := bindClient.KubeBindV1alpha1().APIServiceBindings().Get(ctx, name, metav1.GetOptions{}) + existing, err := bindClient.KubeBindV1alpha2().APIServiceBindings().Get(ctx, name, metav1.GetOptions{}) if err != nil && !apierrors.IsNotFound(err) { return nil, err } else if err == nil { @@ -76,14 +76,14 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co first = false fmt.Fprint(b.Options.IOStreams.ErrOut, ".") //nolint:errcheck } - created, err := bindClient.KubeBindV1alpha1().APIServiceBindings().Create(ctx, &kubebindv1alpha1.APIServiceBinding{ + created, err := bindClient.KubeBindV1alpha2().APIServiceBindings().Create(ctx, &kubebindv1alpha2.APIServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Name: resource.Resource + "." + resource.Group, Namespace: "kube-bind", }, - Spec: kubebindv1alpha1.APIServiceBindingSpec{ - KubeconfigSecretRef: kubebindv1alpha1.ClusterSecretKeyRef{ - LocalSecretKeyRef: kubebindv1alpha1.LocalSecretKeyRef{ + Spec: kubebindv1alpha2.APIServiceBindingSpec{ + KubeconfigSecretRef: kubebindv1alpha2.ClusterSecretKeyRef{ + LocalSecretKeyRef: kubebindv1alpha2.LocalSecretKeyRef{ Name: secretName, Key: "kubeconfig", }, @@ -102,7 +102,7 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co conditionsapi.ConditionSeverityInfo, "Pending", ) - _, _ = bindClient.KubeBindV1alpha1().APIServiceBindings().UpdateStatus(ctx, created, metav1.UpdateOptions{}) //nolint:errcheck + _, _ = bindClient.KubeBindV1alpha2().APIServiceBindings().UpdateStatus(ctx, created, metav1.UpdateOptions{}) //nolint:errcheck fmt.Fprintf(b.Options.IOStreams.ErrOut, "✅ Created APIServiceBinding %s.%s\n", resource.Resource, resource.Group) //nolint:errcheck bindings = append(bindings, created) diff --git a/cli/pkg/kubectl/bind-apiservice/plugin/serviceexportrequest.go b/cli/pkg/kubectl/bind-apiservice/plugin/serviceexportrequest.go index f80a689ba..ec4bd173c 100644 --- a/cli/pkg/kubectl/bind-apiservice/plugin/serviceexportrequest.go +++ b/cli/pkg/kubectl/bind-apiservice/plugin/serviceexportrequest.go @@ -29,7 +29,7 @@ import ( "k8s.io/cli-runtime/pkg/printers" "k8s.io/client-go/rest" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" ) @@ -37,8 +37,8 @@ func (b *BindAPIServiceOptions) createServiceExportRequest( ctx context.Context, remoteConfig *rest.Config, ns string, - request *kubebindv1alpha1.APIServiceExportRequest, -) (*kubebindv1alpha1.APIServiceExportRequest, error) { + request *kubebindv1alpha2.APIServiceExportRequest, +) (*kubebindv1alpha2.APIServiceExportRequest, error) { bindRemoteClient, err := bindclient.NewForConfig(remoteConfig) if err != nil { return nil, err @@ -48,7 +48,7 @@ func (b *BindAPIServiceOptions) createServiceExportRequest( if request.Name == "" { request.GenerateName = "export-" } - created, err := bindRemoteClient.KubeBindV1alpha1().APIServiceExportRequests(ns).Create(ctx, request, metav1.CreateOptions{}) + created, err := bindRemoteClient.KubeBindV1alpha2().APIServiceExportRequests(ns).Create(ctx, request, metav1.CreateOptions{}) if err != nil && !apierrors.IsAlreadyExists(err) { return nil, err } else if err != nil && request.Name == "" { @@ -56,26 +56,26 @@ func (b *BindAPIServiceOptions) createServiceExportRequest( } else if err != nil { request.GenerateName = request.Name + "-" request.Name = "" - created, err = bindRemoteClient.KubeBindV1alpha1().APIServiceExportRequests(ns).Create(ctx, request, metav1.CreateOptions{}) + created, err = bindRemoteClient.KubeBindV1alpha2().APIServiceExportRequests(ns).Create(ctx, request, metav1.CreateOptions{}) if err != nil { return nil, err } } // wait for the request to be Successful, Failed or deleted - var result *kubebindv1alpha1.APIServiceExportRequest + var result *kubebindv1alpha2.APIServiceExportRequest if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 10*time.Minute, true, func(ctx context.Context) (bool, error) { - request, err := bindRemoteClient.KubeBindV1alpha1().APIServiceExportRequests(ns).Get(ctx, created.Name, metav1.GetOptions{}) + request, err := bindRemoteClient.KubeBindV1alpha2().APIServiceExportRequests(ns).Get(ctx, created.Name, metav1.GetOptions{}) if err != nil && !apierrors.IsNotFound(err) { return false, err } else if apierrors.IsNotFound(err) { return false, fmt.Errorf("APIServiceExportRequest %s was deleted by the service provider", created.Name) } - if request.Status.Phase == kubebindv1alpha1.APIServiceExportRequestPhaseSucceeded { + if request.Status.Phase == kubebindv1alpha2.APIServiceExportRequestPhaseSucceeded { result = request return true, nil } - if request.Status.Phase == kubebindv1alpha1.APIServiceExportRequestPhaseFailed { + if request.Status.Phase == kubebindv1alpha2.APIServiceExportRequestPhaseFailed { return false, fmt.Errorf("binding request failed: %s", request.Status.TerminalMessage) } return false, nil @@ -86,16 +86,16 @@ func (b *BindAPIServiceOptions) createServiceExportRequest( return result, nil } -func (b *BindAPIServiceOptions) printTable(ctx context.Context, config *rest.Config, bindings []*kubebindv1alpha1.APIServiceBinding) error { +func (b *BindAPIServiceOptions) printTable(ctx context.Context, config *rest.Config, bindings []*kubebindv1alpha2.APIServiceBinding) error { printer := printers.NewTablePrinter(printers.PrintOptions{ WithKind: true, - Kind: kubebindv1alpha1.SchemeGroupVersion.WithKind("APIServiceBinding").GroupKind(), + Kind: kubebindv1alpha2.SchemeGroupVersion.WithKind("APIServiceBinding").GroupKind(), }) tableConfig := rest.CopyConfig(config) tableConfig.APIPath = "/apis" tableConfig.ContentConfig.AcceptContentTypes = fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1.SchemeGroupVersion.Version, metav1.GroupName) - tableConfig.GroupVersion = &kubebindv1alpha1.SchemeGroupVersion + tableConfig.GroupVersion = &kubebindv1alpha2.SchemeGroupVersion scheme := runtime.NewScheme() if err := metav1.AddMetaToScheme(scheme); err != nil { return err diff --git a/cli/pkg/kubectl/bind/authenticator/authenticator.go b/cli/pkg/kubectl/bind/authenticator/authenticator.go index f411658e0..69a38d419 100644 --- a/cli/pkg/kubectl/bind/authenticator/authenticator.go +++ b/cli/pkg/kubectl/bind/authenticator/authenticator.go @@ -33,7 +33,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) var ( @@ -42,7 +42,7 @@ var ( ) func init() { - utilruntime.Must(kubebindv1alpha1.AddToScheme(kubebindSchema)) + utilruntime.Must(kubebindv1alpha2.AddToScheme(kubebindSchema)) } type LocalhostCallbackAuthenticator struct { diff --git a/cli/pkg/kubectl/bind/plugin/authenticate.go b/cli/pkg/kubectl/bind/plugin/authenticate.go index a92e05bdb..b9ec4996c 100644 --- a/cli/pkg/kubectl/bind/plugin/authenticate.go +++ b/cli/pkg/kubectl/bind/plugin/authenticate.go @@ -33,10 +33,10 @@ import ( clientgoversion "k8s.io/client-go/pkg/version" "github.com/kube-bind/kube-bind/pkg/version" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) -func getProvider(url string, insecure bool) (*kubebindv1alpha1.BindingProvider, error) { +func getProvider(url string, insecure bool) (*kubebindv1alpha2.BindingProvider, error) { client := &http.Client{} if insecure { client.Transport = &http.Transport{ @@ -60,7 +60,7 @@ func getProvider(url string, insecure bool) (*kubebindv1alpha1.BindingProvider, return nil, err } - provider := &kubebindv1alpha1.BindingProvider{} + provider := &kubebindv1alpha2.BindingProvider{} if err := json.Unmarshal(blob, provider); err != nil { return nil, err } @@ -72,8 +72,9 @@ func getProvider(url string, insecure bool) (*kubebindv1alpha1.BindingProvider, } if bindSemVer, err := semver.Parse(strings.TrimLeft(bindVersion, "v")); err != nil { return nil, fmt.Errorf("failed to parse bind version %q: %v", bindVersion, err) - } else if min := semver.MustParse("0.3.0"); bindSemVer.GE(min) { - // we added this in v0.3.0. Don't test before. + } else if min := semver.MustParse("0.5.0"); bindSemVer.GE(min) { + // At v0.5.0 we made breaking change for how APIExports looks like. + // So we need to test for v0.5.0+. If if err := validateProviderVersion(provider.Version); err != nil { return nil, err } @@ -84,7 +85,7 @@ func getProvider(url string, insecure bool) (*kubebindv1alpha1.BindingProvider, func validateProviderVersion(providerVersion string) error { if providerVersion == "" { - return fmt.Errorf("provider version %q is empty, please update the backend to v0.3.0+", providerVersion) + return fmt.Errorf("provider version %q is empty, please update the backend to v0.5.0+", providerVersion) } else if providerVersion == "v0.0.0" || providerVersion == "v0.0.0-master+$Format:%H$" { // unversioned, development version return nil @@ -94,15 +95,16 @@ func validateProviderVersion(providerVersion string) error { if err != nil { return fmt.Errorf("provider version %q cannot be parsed", providerVersion) } - if min := semver.MustParse("0.3.0"); providerSemVer.LT(min) { + // Check if provider is higher than 0.4.8, we need to have same version of kube-bind to use this provider. + if min := semver.MustParse("0.5.0"); providerSemVer.LT(min) { return fmt.Errorf("provider version %s is not supported, must be at least v%s", providerVersion, min) } return nil } -func (b *BindOptions) authenticate(provider *kubebindv1alpha1.BindingProvider, callback, sessionID, clusterID string, urlCh chan<- string) error { - var oauth2Method *kubebindv1alpha1.OAuth2CodeGrant +func (b *BindOptions) authenticate(provider *kubebindv1alpha2.BindingProvider, callback, sessionID, clusterID string, urlCh chan<- string) error { + var oauth2Method *kubebindv1alpha2.OAuth2CodeGrant for _, m := range provider.AuthenticationMethods { if m.Method == "OAuth2CodeGrant" { oauth2Method = m.OAuth2CodeGrant diff --git a/cli/pkg/kubectl/bind/plugin/bind.go b/cli/pkg/kubectl/bind/plugin/bind.go index c0e6b94ed..41a8a8104 100644 --- a/cli/pkg/kubectl/bind/plugin/bind.go +++ b/cli/pkg/kubectl/bind/plugin/bind.go @@ -45,7 +45,7 @@ import ( "github.com/kube-bind/kube-bind/cli/pkg/kubectl/base" "github.com/kube-bind/kube-bind/cli/pkg/kubectl/bind/authenticator" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) // BindOptions contains the options for creating an APIBinding. @@ -159,7 +159,7 @@ func (b *BindOptions) Run(ctx context.Context, urlCh chan<- string) error { return fmt.Errorf("failed to fetch authentication url %q: %v", exportURL, err) } - if provider.APIVersion != kubebindv1alpha1.GroupVersion { + if provider.APIVersion != kubebindv1alpha2.GroupVersion { return fmt.Errorf("unsupported binding provider version: %q", provider.APIVersion) } @@ -201,10 +201,10 @@ func (b *BindOptions) Run(ctx context.Context, urlCh chan<- string) error { fmt.Fprintf(b.IOStreams.ErrOut, "🔑 Successfully authenticated to %s\n", exportURL.String()) //nolint:errcheck // verify the response - if gvk.GroupVersion() != kubebindv1alpha1.SchemeGroupVersion || gvk.Kind != "BindingResponse" { - return fmt.Errorf("unexpected response type %s, only supporting %s", gvk, kubebindv1alpha1.SchemeGroupVersion.WithKind("BindingResponse")) + if gvk.GroupVersion() != kubebindv1alpha2.SchemeGroupVersion || gvk.Kind != "BindingResponse" { + return fmt.Errorf("unexpected response type %s, only supporting %s", gvk, kubebindv1alpha2.SchemeGroupVersion.WithKind("BindingResponse")) } - bindingResponse, ok := response.(*kubebindv1alpha1.BindingResponse) + bindingResponse, ok := response.(*kubebindv1alpha2.BindingResponse) if !ok { return fmt.Errorf("unexpected response type %T", response) } @@ -216,16 +216,16 @@ func (b *BindOptions) Run(ctx context.Context, urlCh chan<- string) error { } // extract the requests - var apiRequests []*kubebindv1alpha1.APIServiceExportRequestResponse + var apiRequests []*kubebindv1alpha2.APIServiceExportRequestResponse for i, request := range bindingResponse.Requests { var meta metav1.TypeMeta if err := json.Unmarshal(request.Raw, &meta); err != nil { return fmt.Errorf("unexpected response: failed to unmarshal request #%d: %v", i, err) } - if got, expected := meta.APIVersion, kubebindv1alpha1.SchemeGroupVersion.String(); got != expected { + if got, expected := meta.APIVersion, kubebindv1alpha2.SchemeGroupVersion.String(); got != expected { return fmt.Errorf("unexpected response: request #%d is not %s, got %s", i, expected, got) } - var apiRequest kubebindv1alpha1.APIServiceExportRequestResponse + var apiRequest kubebindv1alpha2.APIServiceExportRequestResponse if err := json.Unmarshal(request.Raw, &apiRequest); err != nil { return fmt.Errorf("failed to unmarshal api request #%d: %v", i+1, err) } diff --git a/contrib/example-backend/controllers/clusterbinding/clusterbinding_controller.go b/contrib/example-backend/controllers/clusterbinding/clusterbinding_controller.go index 4fecd62fb..34ae634a5 100644 --- a/contrib/example-backend/controllers/clusterbinding/clusterbinding_controller.go +++ b/contrib/example-backend/controllers/clusterbinding/clusterbinding_controller.go @@ -40,10 +40,10 @@ import ( "k8s.io/klog/v2" "github.com/kube-bind/kube-bind/pkg/committer" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -53,7 +53,7 @@ const ( // NewController returns a new controller to reconcile ClusterBindings. func NewController( config *rest.Config, - scope kubebindv1alpha1.Scope, + scope kubebindv1alpha2.InformerScope, clusterBindingInformer bindinformers.ClusterBindingInformer, serviceExportInformer bindinformers.APIServiceExportInformer, clusterRoleInformer rbacinformers.ClusterRoleInformer, @@ -97,9 +97,12 @@ func NewController( reconciler: reconciler{ scope: scope, - listServiceExports: func(ns string) ([]*kubebindv1alpha1.APIServiceExport, error) { + listServiceExports: func(ns string) ([]*kubebindv1alpha2.APIServiceExport, error) { return serviceExportInformer.Lister().APIServiceExports(ns).List(labels.Everything()) }, + getAPIResourceSchema: func(ctx context.Context, namespace, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + return bindClient.KubeBindV1alpha2().APIResourceSchemas().Get(ctx, name, metav1.GetOptions{}) + }, getClusterRole: func(name string) (*rbacv1.ClusterRole, error) { return clusterRoleInformer.Lister().Get(name) }, @@ -135,21 +138,21 @@ func NewController( }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.ClusterBinding, *kubebindv1alpha1.ClusterBindingSpec, *kubebindv1alpha1.ClusterBindingStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.ClusterBinding] { - return bindClient.KubeBindV1alpha1().ClusterBindings(ns) + commit: committer.NewCommitter[*kubebindv1alpha2.ClusterBinding, *kubebindv1alpha2.ClusterBindingSpec, *kubebindv1alpha2.ClusterBindingStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.ClusterBinding] { + return bindClient.KubeBindV1alpha2().ClusterBindings(ns) }, ), } if _, err := clusterBindingInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueClusterBinding(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueClusterBinding(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueClusterBinding(logger, obj) }, }); err != nil { @@ -157,13 +160,13 @@ func NewController( } if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -173,7 +176,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.ClusterBindingSpec, *kubebindv1alpha1.ClusterBindingStatus] +type Resource = committer.Resource[*kubebindv1alpha2.ClusterBindingSpec, *kubebindv1alpha2.ClusterBindingStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // Controller reconciles ClusterBinding conditions. @@ -200,7 +203,7 @@ type Controller struct { commit CommitFunc } -func (c *Controller) enqueueClusterBinding(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueClusterBinding(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -211,7 +214,7 @@ func (c *Controller) enqueueClusterBinding(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceExport(logger klog.Logger, obj any) { seKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) diff --git a/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go b/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go index 0a64db21e..2c94b8e45 100644 --- a/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go +++ b/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go @@ -30,19 +30,19 @@ import ( "k8s.io/utils/ptr" kuberesources "github.com/kube-bind/kube-bind/contrib/example-backend/kubernetes/resources" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" ) type reconciler struct { - scope kubebindv1alpha1.Scope + scope kubebindv1alpha2.InformerScope - listServiceExports func(ns string) ([]*kubebindv1alpha1.APIServiceExport, error) - - getClusterRole func(name string) (*rbacv1.ClusterRole, error) - createClusterRole func(ctx context.Context, binding *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error) - updateClusterRole func(ctx context.Context, binding *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error) + listServiceExports func(ns string) ([]*kubebindv1alpha2.APIServiceExport, error) + getAPIResourceSchema func(ctx context.Context, namespace, name string) (*kubebindv1alpha2.APIResourceSchema, error) + getClusterRole func(name string) (*rbacv1.ClusterRole, error) + createClusterRole func(ctx context.Context, binding *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error) + updateClusterRole func(ctx context.Context, binding *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error) getClusterRoleBinding func(name string) (*rbacv1.ClusterRoleBinding, error) createClusterRoleBinding func(ctx context.Context, binding *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error) @@ -56,7 +56,7 @@ type reconciler struct { getNamespace func(name string) (*corev1.Namespace, error) } -func (r *reconciler) reconcile(ctx context.Context, clusterBinding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) reconcile(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding) error { var errs []error if err := r.ensureClusterBindingConditions(ctx, clusterBinding); err != nil { @@ -77,24 +77,24 @@ func (r *reconciler) reconcile(ctx context.Context, clusterBinding *kubebindv1al return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureClusterBindingConditions(_ context.Context, clusterBinding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureClusterBindingConditions(_ context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding) error { if clusterBinding.Status.LastHeartbeatTime.IsZero() { conditions.MarkFalse(clusterBinding, - kubebindv1alpha1.ClusterBindingConditionHealthy, + kubebindv1alpha2.ClusterBindingConditionHealthy, "FirstHeartbeatPending", conditionsapi.ConditionSeverityInfo, "Waiting for first heartbeat", ) } else if clusterBinding.Status.HeartbeatInterval.Duration == 0 { conditions.MarkFalse(clusterBinding, - kubebindv1alpha1.ClusterBindingConditionHealthy, + kubebindv1alpha2.ClusterBindingConditionHealthy, "HeartbeatIntervalMissing", conditionsapi.ConditionSeverityInfo, "Waiting for consumer cluster reporting its heartbeat interval", ) } else if ago := time.Since(clusterBinding.Status.LastHeartbeatTime.Time); ago > clusterBinding.Status.HeartbeatInterval.Duration*2 { conditions.MarkFalse(clusterBinding, - kubebindv1alpha1.ClusterBindingConditionHealthy, + kubebindv1alpha2.ClusterBindingConditionHealthy, "HeartbeatTimeout", conditionsapi.ConditionSeverityError, "Heartbeat timeout: expected heartbeat within %s, but last one has been at %s", @@ -103,21 +103,21 @@ func (r *reconciler) ensureClusterBindingConditions(_ context.Context, clusterBi ) } else if ago < time.Second*10 { conditions.MarkFalse(clusterBinding, - kubebindv1alpha1.ClusterBindingConditionHealthy, + kubebindv1alpha2.ClusterBindingConditionHealthy, "HeartbeatTimeDrift", conditionsapi.ConditionSeverityWarning, "Clocks of consumer cluster and service account cluster seem to be off by more than 10s", ) } else { conditions.MarkTrue(clusterBinding, - kubebindv1alpha1.ClusterBindingConditionHealthy, + kubebindv1alpha2.ClusterBindingConditionHealthy, ) } return nil } -func (r *reconciler) ensureRBACClusterRole(ctx context.Context, clusterBinding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureRBACClusterRole(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding) error { name := "kube-binder-" + clusterBinding.Namespace role, err := r.getClusterRole(name) if err != nil && !errors.IsNotFound(err) { @@ -148,11 +148,25 @@ func (r *reconciler) ensureRBACClusterRole(ctx context.Context, clusterBinding * }, } for _, export := range exports { - expected.Rules = append(expected.Rules, rbacv1.PolicyRule{ - APIGroups: []string{export.Spec.Group}, - Resources: []string{export.Spec.Names.Plural}, - Verbs: []string{"get", "list", "watch", "update", "patch", "delete", "create"}, - }) + for _, res := range export.Spec.Resources { + schema, err := r.getAPIResourceSchema(ctx, clusterBinding.Namespace, res.Name) + if err != nil { + return fmt.Errorf("failed to get APIResourceSchema %w", err) + } + + expected.Rules = append(expected.Rules, + rbacv1.PolicyRule{ + APIGroups: []string{schema.Spec.APIResourceSchemaCRDSpec.Group}, + Resources: []string{schema.Spec.APIResourceSchemaCRDSpec.Names.Plural}, + Verbs: []string{"get", "list", "watch", "update", "patch", "delete", "create"}, + }, + rbacv1.PolicyRule{ + APIGroups: []string{kubebindv1alpha2.GroupName}, + Resources: []string{"apiresourceschemas"}, + Verbs: []string{"get", "list", "watch"}, + }, + ) + } } if role == nil { @@ -170,14 +184,14 @@ func (r *reconciler) ensureRBACClusterRole(ctx context.Context, clusterBinding * return nil } -func (r *reconciler) ensureRBACClusterRoleBinding(ctx context.Context, clusterBinding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureRBACClusterRoleBinding(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding) error { name := "kube-binder-" + clusterBinding.Namespace binding, err := r.getClusterRoleBinding(name) if err != nil && !errors.IsNotFound(err) { return fmt.Errorf("failed to get ClusterRoleBinding %s: %w", name, err) } - if r.scope != kubebindv1alpha1.ClusterScope { + if r.scope != kubebindv1alpha2.ClusterScope { if err := r.deleteClusterRoleBinding(ctx, name); err != nil && !errors.IsNotFound(err) { return fmt.Errorf("failed to delete ClusterRoleBinding %s: %w", name, err) } @@ -231,7 +245,7 @@ func (r *reconciler) ensureRBACClusterRoleBinding(ctx context.Context, clusterBi return nil } -func (r *reconciler) ensureRBACRoleBinding(ctx context.Context, clusterBinding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureRBACRoleBinding(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding) error { binding, err := r.getRoleBinding(clusterBinding.Namespace, "kube-binder") if err != nil && !errors.IsNotFound(err) { return fmt.Errorf("failed to get RoleBinding \"kube-binder\": %w", err) diff --git a/contrib/example-backend/controllers/serviceexport/serviceexport_controller.go b/contrib/example-backend/controllers/serviceexport/serviceexport_controller.go index 897e5129f..3089b053b 100644 --- a/contrib/example-backend/controllers/serviceexport/serviceexport_controller.go +++ b/contrib/example-backend/controllers/serviceexport/serviceexport_controller.go @@ -36,10 +36,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -79,10 +79,13 @@ func NewController( getCRD: func(name string) (*apiextensionsv1.CustomResourceDefinition, error) { return crdInformer.Lister().Get(name) }, + getAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + return bindClient.KubeBindV1alpha2().APIResourceSchemas().Get(ctx, name, metav1.GetOptions{}) + }, deleteServiceExport: func(ctx context.Context, ns, name string) error { - return bindClient.KubeBindV1alpha1().APIServiceExports(ns).Delete(ctx, name, metav1.DeleteOptions{}) + return bindClient.KubeBindV1alpha2().APIServiceExports(ns).Delete(ctx, name, metav1.DeleteOptions{}) }, - requeue: func(export *kubebindv1alpha1.APIServiceExport) { + requeue: func(export *kubebindv1alpha2.APIServiceExport) { key, err := cache.MetaNamespaceKeyFunc(export) if err != nil { runtime.HandleError(err) @@ -92,9 +95,9 @@ func NewController( }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceExport, *kubebindv1alpha1.APIServiceExportSpec, *kubebindv1alpha1.APIServiceExportStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceExport] { - return bindClient.KubeBindV1alpha1().APIServiceExports(ns) + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceExport, *kubebindv1alpha2.APIServiceExportSpec, *kubebindv1alpha2.APIServiceExportStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceExport] { + return bindClient.KubeBindV1alpha2().APIServiceExports(ns) }, ), } @@ -104,13 +107,13 @@ func NewController( }) if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -118,13 +121,13 @@ func NewController( } if _, err := crdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueCRD(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueCRD(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueCRD(logger, obj) }, }); err != nil { @@ -134,7 +137,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceExportSpec, *kubebindv1alpha1.APIServiceExportStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceExportSpec, *kubebindv1alpha2.APIServiceExportStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // Controller reconciles ServiceNamespaces by creating a Namespace for each, and deleting it if @@ -155,7 +158,7 @@ type Controller struct { commit CommitFunc } -func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceExport(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -166,7 +169,7 @@ func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { c.queue.Add(key) } -func (c *Controller) enqueueCRD(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueCRD(logger klog.Logger, obj any) { crdKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -180,7 +183,7 @@ func (c *Controller) enqueueCRD(logger klog.Logger, obj interface{}) { } for _, obj := range exports { - export, ok := obj.(*kubebindv1alpha1.APIServiceExport) + export, ok := obj.(*kubebindv1alpha2.APIServiceExport) if !ok { runtime.HandleError(fmt.Errorf("unexpected type %T", obj)) return diff --git a/contrib/example-backend/controllers/serviceexport/serviceexport_reconcile.go b/contrib/example-backend/controllers/serviceexport/serviceexport_reconcile.go index 115b1de1f..02b9fdb57 100644 --- a/contrib/example-backend/controllers/serviceexport/serviceexport_reconcile.go +++ b/contrib/example-backend/controllers/serviceexport/serviceexport_reconcile.go @@ -18,77 +18,89 @@ package serviceexport import ( "context" + "crypto/sha256" + "encoding/hex" + "slices" + "sort" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" - kubebindhelpers "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1/helpers" - conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + kubebindhelpers "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" ) type reconciler struct { - getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) - deleteServiceExport func(ctx context.Context, namespace, name string) error + getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) + getAPIResourceSchema func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) + deleteServiceExport func(ctx context.Context, namespace, name string) error - requeue func(export *kubebindv1alpha1.APIServiceExport) + requeue func(export *kubebindv1alpha2.APIServiceExport) } -func (r *reconciler) reconcile(ctx context.Context, export *kubebindv1alpha1.APIServiceExport) error { +func (r *reconciler) reconcile(ctx context.Context, export *kubebindv1alpha2.APIServiceExport) error { var errs []error if specChanged, err := r.ensureSchema(ctx, export); err != nil { errs = append(errs, err) } else if specChanged { - r.requeue(export) + // TODO: This should be separate controller for apiresourceschemas. + // This is wrong place now. + // r.requeue(export) return nil } return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureSchema(ctx context.Context, export *kubebindv1alpha1.APIServiceExport) (specChanged bool, err error) { +func (r *reconciler) ensureSchema(ctx context.Context, export *kubebindv1alpha2.APIServiceExport) (specChanged bool, err error) { logger := klog.FromContext(ctx) + leafHashes := make([]string, 0, len(export.Spec.Resources)) + for _, resourceRef := range export.Spec.Resources { + if resourceRef.Type != "APIResourceSchema" { + logger.V(1).Info("Skipping unsupported resource type", "type", resourceRef.Type) + continue + } - crd, err := r.getCRD(export.Name) - if err != nil && !errors.IsNotFound(err) { - return false, err - } + schema, err := r.getAPIResourceSchema(ctx, resourceRef.Name) + if err != nil { + if errors.IsNotFound(err) { + continue + } + return false, err + } - if crd == nil { - // CRD missing => delete SER too - logger.V(1).Info("Deleting APIServiceExport because CRD is missing") - return false, r.deleteServiceExport(ctx, export.Namespace, export.Name) + hash := kubebindhelpers.APIResourceSchemaCRDSpecHash(&schema.Spec.APIResourceSchemaCRDSpec) + leafHashes = append(leafHashes, hash) } - expected, err := kubebindhelpers.CRDToServiceExport(crd) - if err != nil { - conditions.MarkFalse( - export, - kubebindv1alpha1.APIServiceExportConditionProviderInSync, - "CustomResourceDefinitionUpdateFailed", - conditionsapi.ConditionSeverityError, - "CustomResourceDefinition %s cannot be converted into a APIServiceExport: %s", - export.Name, err, - ) - return false, nil // nothing we can do - } + hashOfHashes := hashOfHashes(leafHashes) - if hash := kubebindhelpers.APIServiceExportCRDSpecHash(expected); export.Annotations[kubebindv1alpha1.SourceSpecHashAnnotationKey] != hash { + if export.Annotations[kubebindv1alpha2.SourceSpecHashAnnotationKey] != hashOfHashes { // both exist, update APIServiceExport - logger.V(1).Info("Updating APIServiceExport") - export.Spec.APIServiceExportCRDSpec = *expected + logger.V(1).Info("Updating APIServiceExport. Hash mismatch", "hash", hashOfHashes, "expected", export.Annotations[kubebindv1alpha2.SourceSpecHashAnnotationKey]) if export.Annotations == nil { export.Annotations = map[string]string{} } - export.Annotations[kubebindv1alpha1.SourceSpecHashAnnotationKey] = hash + export.Annotations[kubebindv1alpha2.SourceSpecHashAnnotationKey] = hashOfHashes return true, nil } - conditions.MarkTrue(export, kubebindv1alpha1.APIServiceExportConditionProviderInSync) + conditions.MarkTrue(export, kubebindv1alpha2.APIServiceExportConditionProviderInSync) return false, nil } + +func hashOfHashes(hashes []string) string { + hexHashes := slices.Clone(hashes) + sort.Strings(hexHashes) + + rootHasher := sha256.New() + for _, h := range hexHashes { + rootHasher.Write([]byte(h)) + } + return hex.EncodeToString(rootHasher.Sum(nil)) +} diff --git a/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_controller.go b/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_controller.go index 393ea7e1a..5937de1df 100644 --- a/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_controller.go +++ b/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_controller.go @@ -37,10 +37,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -51,11 +51,12 @@ const ( // creating corresponding APIServiceExports. func NewController( config *rest.Config, - scope kubebindv1alpha1.Scope, - isolation kubebindv1alpha1.Isolation, + scope kubebindv1alpha2.InformerScope, + isolation kubebindv1alpha2.Isolation, serviceExportRequestInformer bindinformers.APIServiceExportRequestInformer, serviceExportInformer bindinformers.APIServiceExportInformer, crdInformer apiextensionsinformers.CustomResourceDefinitionInformer, + apiResourceSchemaInformer bindinformers.APIResourceSchemaInformer, ) (*Controller, error) { queue := workqueue.NewTypedRateLimitingQueueWithConfig(workqueue.DefaultTypedControllerRateLimiter[string](), workqueue.TypedRateLimitingQueueConfig[string]{Name: controllerName}) @@ -88,26 +89,35 @@ func NewController( crdLister: crdInformer.Lister(), crdIndexer: crdInformer.Informer().GetIndexer(), + apiResourceSchemaLister: apiResourceSchemaInformer.Lister(), + apiResourceSchemaIndexer: apiResourceSchemaInformer.Informer().GetIndexer(), + reconciler: reconciler{ informerScope: scope, clusterScopedIsolation: isolation, getCRD: func(name string) (*apiextensionsv1.CustomResourceDefinition, error) { return crdInformer.Lister().Get(name) }, - getServiceExport: func(ns, name string) (*kubebindv1alpha1.APIServiceExport, error) { + getAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + return apiResourceSchemaInformer.Lister().Get(name) + }, + getServiceExport: func(ns, name string) (*kubebindv1alpha2.APIServiceExport, error) { return serviceExportInformer.Lister().APIServiceExports(ns).Get(name) }, - createServiceExport: func(ctx context.Context, resource *kubebindv1alpha1.APIServiceExport) (*kubebindv1alpha1.APIServiceExport, error) { - return bindClient.KubeBindV1alpha1().APIServiceExports(resource.Namespace).Create(ctx, resource, metav1.CreateOptions{}) + createServiceExport: func(ctx context.Context, resource *kubebindv1alpha2.APIServiceExport) (*kubebindv1alpha2.APIServiceExport, error) { + return bindClient.KubeBindV1alpha2().APIServiceExports(resource.Namespace).Create(ctx, resource, metav1.CreateOptions{}) + }, + createAPIResourceSchema: func(ctx context.Context, schema *kubebindv1alpha2.APIResourceSchema) (*kubebindv1alpha2.APIResourceSchema, error) { + return bindClient.KubeBindV1alpha2().APIResourceSchemas().Create(ctx, schema, metav1.CreateOptions{}) }, deleteServiceExportRequest: func(ctx context.Context, ns, name string) error { - return bindClient.KubeBindV1alpha1().APIServiceExportRequests(ns).Delete(ctx, name, metav1.DeleteOptions{}) + return bindClient.KubeBindV1alpha2().APIServiceExportRequests(ns).Delete(ctx, name, metav1.DeleteOptions{}) }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceExportRequest, *kubebindv1alpha1.APIServiceExportRequestSpec, *kubebindv1alpha1.APIServiceExportRequestStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceExportRequest] { - return bindClient.KubeBindV1alpha1().APIServiceExportRequests(ns) + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceExportRequest, *kubebindv1alpha2.APIServiceExportRequestSpec, *kubebindv1alpha2.APIServiceExportRequestStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceExportRequest] { + return bindClient.KubeBindV1alpha2().APIServiceExportRequests(ns) }, ), } @@ -120,13 +130,13 @@ func NewController( }) if _, err := serviceExportRequestInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExportRequest(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueServiceExportRequest(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExportRequest(logger, obj) }, }); err != nil { @@ -134,13 +144,13 @@ func NewController( } if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -148,13 +158,13 @@ func NewController( } if _, err := crdInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueCRD(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { + UpdateFunc: func(old, newObj any) { c.enqueueCRD(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueCRD(logger, obj) }, }); err != nil { @@ -164,7 +174,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceExportRequestSpec, *kubebindv1alpha1.APIServiceExportRequestStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceExportRequestSpec, *kubebindv1alpha2.APIServiceExportRequestStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // Controller to reconcile APIServiceExportRequests by creating corresponding APIServiceExports. @@ -183,12 +193,15 @@ type Controller struct { crdLister apiextensionslisters.CustomResourceDefinitionLister crdIndexer cache.Indexer + apiResourceSchemaLister bindlisters.APIResourceSchemaLister + apiResourceSchemaIndexer cache.Indexer + reconciler commit CommitFunc } -func (c *Controller) enqueueServiceExportRequest(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceExportRequest(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -199,7 +212,7 @@ func (c *Controller) enqueueServiceExportRequest(logger klog.Logger, obj interfa c.queue.Add(key) } -func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceExport(logger klog.Logger, obj any) { seKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -222,7 +235,7 @@ func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { } } -func (c *Controller) enqueueCRD(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueCRD(logger klog.Logger, obj any) { crdKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) diff --git a/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_reconcile.go b/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_reconcile.go index 5ac15b5cb..48623aba3 100644 --- a/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_reconcile.go +++ b/contrib/example-backend/controllers/serviceexportrequest/serviceexportrequest_reconcile.go @@ -26,24 +26,25 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" - "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1/helpers" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" ) type reconciler struct { - informerScope kubebindv1alpha1.Scope - clusterScopedIsolation kubebindv1alpha1.Isolation - - getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) - getServiceExport func(ns, name string) (*kubebindv1alpha1.APIServiceExport, error) - createServiceExport func(ctx context.Context, resource *kubebindv1alpha1.APIServiceExport) (*kubebindv1alpha1.APIServiceExport, error) - + informerScope kubebindv1alpha2.InformerScope + clusterScopedIsolation kubebindv1alpha2.Isolation + + getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) + getAPIResourceSchema func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) + getServiceExport func(ns, name string) (*kubebindv1alpha2.APIServiceExport, error) + createServiceExport func(ctx context.Context, resource *kubebindv1alpha2.APIServiceExport) (*kubebindv1alpha2.APIServiceExport, error) + createAPIResourceSchema func(ctx context.Context, schema *kubebindv1alpha2.APIResourceSchema) (*kubebindv1alpha2.APIResourceSchema, error) deleteServiceExportRequest func(ctx context.Context, namespace, name string) error } -func (r *reconciler) reconcile(ctx context.Context, req *kubebindv1alpha1.APIServiceExportRequest) error { +func (r *reconciler) reconcile(ctx context.Context, req *kubebindv1alpha2.APIServiceExportRequest) error { var errs []error if err := r.ensureExports(ctx, req); err != nil { @@ -55,29 +56,48 @@ func (r *reconciler) reconcile(ctx context.Context, req *kubebindv1alpha1.APISer return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureExports(ctx context.Context, req *kubebindv1alpha1.APIServiceExportRequest) error { +func (r *reconciler) ensureExports(ctx context.Context, req *kubebindv1alpha2.APIServiceExportRequest) error { logger := klog.FromContext(ctx) - if req.Status.Phase == kubebindv1alpha1.APIServiceExportRequestPhasePending { + if req.Status.Phase == kubebindv1alpha2.APIServiceExportRequestPhasePending { failure := false for _, res := range req.Spec.Resources { + // backend is created using CRD's as backup. But this is not required. name := res.Resource + "." + res.Group - crd, err := r.getCRD(name) - if err != nil && !apierrors.IsNotFound(err) { + + apiResourceSchema, err := r.getAPIResourceSchema(ctx, name) + switch { + case apierrors.IsNotFound(err): + logger.V(1).Info("APIResourceSchema not found, continuing with fallback to CRD conversion to APIResourceSchema", "name", name) + crd, err := r.getCRD(name) + if err != nil && !apierrors.IsNotFound(err) { + return err + } + if apierrors.IsNotFound(err) { + conditions.MarkFalse( + req, + kubebindv1alpha2.APIServiceExportRequestConditionExportsReady, + "CRDNotFound", + conditionsapi.ConditionSeverityError, + "CustomResourceDefinition %s in the service provider cluster not found", + name, + ) + failure = true + break + } + schema, err := helpers.CRDToAPIResourceSchema(crd, "") + if err != nil { + return err + } + schema.Namespace = req.Namespace + + logger.V(1).Info("Creating APIResourceSchema", "name", schema.Name, "namespace", schema.Namespace) + if apiResourceSchema, err = r.createAPIResourceSchema(ctx, schema); err != nil { + return err + } + case err != nil: return err } - if apierrors.IsNotFound(err) { - conditions.MarkFalse( - req, - kubebindv1alpha1.APIServiceExportRequestConditionExportsReady, - "CRDNotFound", - conditionsapi.ConditionSeverityError, - "CustomResourceDefinition %s in the service provider cluster not found", - name, - ) - failure = true - break - } if _, err := r.getServiceExport(req.Namespace, name); err != nil && !apierrors.IsNotFound(err) { return err @@ -85,35 +105,26 @@ func (r *reconciler) ensureExports(ctx context.Context, req *kubebindv1alpha1.AP continue } - exportSpec, err := helpers.CRDToServiceExport(crd) - if err != nil { - conditions.MarkFalse( - req, - kubebindv1alpha1.APIServiceExportRequestConditionExportsReady, - "CRDInvalid", - conditionsapi.ConditionSeverityError, - "CustomResourceDefinition %s cannot be converted to a APIServiceExport: %v", - name, - err, - ) - failure = true - break - } - hash := helpers.APIServiceExportCRDSpecHash(exportSpec) - export := &kubebindv1alpha1.APIServiceExport{ + hash := helpers.APIResourceSchemaCRDSpecHash(&apiResourceSchema.Spec.APIResourceSchemaCRDSpec) + export := &kubebindv1alpha2.APIServiceExport{ ObjectMeta: metav1.ObjectMeta{ - Name: crd.Name, + Name: req.Name, Namespace: req.Namespace, Annotations: map[string]string{ - kubebindv1alpha1.SourceSpecHashAnnotationKey: hash, + kubebindv1alpha2.SourceSpecHashAnnotationKey: hash, }, }, - Spec: kubebindv1alpha1.APIServiceExportSpec{ - APIServiceExportCRDSpec: *exportSpec, - InformerScope: r.informerScope, + Spec: kubebindv1alpha2.APIServiceExportSpec{ + Resources: []kubebindv1alpha2.APIResourceSchemaReference{ + { + Type: "APIResourceSchema", + Name: apiResourceSchema.Name, + }, + }, + InformerScope: r.informerScope, }, } - if exportSpec.Scope == apiextensionsv1.ClusterScoped { + if apiResourceSchema.Spec.Scope == apiextensionsv1.ClusterScoped { export.Spec.ClusterScopedIsolation = r.clusterScopedIsolation } @@ -124,14 +135,14 @@ func (r *reconciler) ensureExports(ctx context.Context, req *kubebindv1alpha1.AP } if !failure { - conditions.MarkTrue(req, kubebindv1alpha1.APIServiceExportRequestConditionExportsReady) - req.Status.Phase = kubebindv1alpha1.APIServiceExportRequestPhaseSucceeded + conditions.MarkTrue(req, kubebindv1alpha2.APIServiceExportRequestConditionExportsReady) + req.Status.Phase = kubebindv1alpha2.APIServiceExportRequestPhaseSucceeded return nil } if time.Since(req.CreationTimestamp.Time) > time.Minute { - req.Status.Phase = kubebindv1alpha1.APIServiceExportRequestPhaseFailed - req.Status.TerminalMessage = conditions.GetMessage(req, kubebindv1alpha1.APIServiceExportRequestConditionExportsReady) + req.Status.Phase = kubebindv1alpha2.APIServiceExportRequestPhaseFailed + req.Status.TerminalMessage = conditions.GetMessage(req, kubebindv1alpha2.APIServiceExportRequestConditionExportsReady) } return nil diff --git a/contrib/example-backend/controllers/servicenamespace/servicenamespace_controller.go b/contrib/example-backend/controllers/servicenamespace/servicenamespace_controller.go index 5e0fe84dc..f487dad2f 100644 --- a/contrib/example-backend/controllers/servicenamespace/servicenamespace_controller.go +++ b/contrib/example-backend/controllers/servicenamespace/servicenamespace_controller.go @@ -41,10 +41,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -54,7 +54,7 @@ const ( // NewController returns a new controller for ServiceNamespaces. func NewController( config *rest.Config, - scope kubebindv1alpha1.Scope, + scope kubebindv1alpha2.InformerScope, serviceNamespaceInformer bindinformers.APIServiceNamespaceInformer, clusterBindingInformer bindinformers.ClusterBindingInformer, serviceExportInformer bindinformers.APIServiceExportInformer, @@ -124,9 +124,9 @@ func NewController( }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceNamespace, *kubebindv1alpha1.APIServiceNamespaceSpec, *kubebindv1alpha1.APIServiceNamespaceStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceNamespace] { - return bindClient.KubeBindV1alpha1().APIServiceNamespaces(ns) + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceNamespace, *kubebindv1alpha2.APIServiceNamespaceSpec, *kubebindv1alpha2.APIServiceNamespaceStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceNamespace] { + return bindClient.KubeBindV1alpha2().APIServiceNamespaces(ns) }, ), } @@ -136,13 +136,13 @@ func NewController( }) if _, err := namespaceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueNamespace(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueNamespace(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueNamespace(logger, obj) }, }); err != nil { @@ -150,13 +150,13 @@ func NewController( } if _, err := serviceNamespaceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceNamespace(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, }); err != nil { @@ -164,7 +164,7 @@ func NewController( } if _, err := clusterBindingInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueClusterBinding(logger, obj) }, }); err != nil { @@ -172,15 +172,15 @@ func NewController( } if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { - oldExport, ok := old.(*kubebindv1alpha1.APIServiceExport) + UpdateFunc: func(old, newObj any) { + oldExport, ok := old.(*kubebindv1alpha2.APIServiceExport) if !ok { return } - newExport, ok := old.(*kubebindv1alpha1.APIServiceExport) + newExport, ok := old.(*kubebindv1alpha2.APIServiceExport) if !ok { return } @@ -189,7 +189,7 @@ func NewController( } c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -199,7 +199,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceNamespaceSpec, *kubebindv1alpha1.APIServiceNamespaceStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceNamespaceSpec, *kubebindv1alpha2.APIServiceNamespaceStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // Controller reconciles ServiceNamespaces by creating a Namespace for each, and deleting it if @@ -233,7 +233,7 @@ type Controller struct { commit CommitFunc } -func (c *Controller) enqueueServiceNamespace(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceNamespace(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -244,7 +244,7 @@ func (c *Controller) enqueueServiceNamespace(logger klog.Logger, obj interface{} c.queue.Add(key) } -func (c *Controller) enqueueClusterBinding(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueClusterBinding(logger klog.Logger, obj any) { cbKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -272,7 +272,7 @@ func (c *Controller) enqueueClusterBinding(logger klog.Logger, obj interface{}) } } -func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceExport(logger klog.Logger, obj any) { seKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -300,7 +300,7 @@ func (c *Controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { } } -func (c *Controller) enqueueNamespace(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueNamespace(logger klog.Logger, obj any) { nsKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) diff --git a/contrib/example-backend/controllers/servicenamespace/servicenamespace_reconcile.go b/contrib/example-backend/controllers/servicenamespace/servicenamespace_reconcile.go index ea6d55cc7..232db42a3 100644 --- a/contrib/example-backend/controllers/servicenamespace/servicenamespace_reconcile.go +++ b/contrib/example-backend/controllers/servicenamespace/servicenamespace_reconcile.go @@ -27,11 +27,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kuberesources "github.com/kube-bind/kube-bind/contrib/example-backend/kubernetes/resources" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type reconciler struct { - scope kubebindv1alpha1.Scope + scope kubebindv1alpha2.InformerScope getNamespace func(name string) (*corev1.Namespace, error) createNamespace func(ctx context.Context, ns *corev1.Namespace) (*corev1.Namespace, error) @@ -42,7 +42,7 @@ type reconciler struct { updateRoleBinding func(ctx context.Context, cr *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error) } -func (c *reconciler) reconcile(ctx context.Context, sns *kubebindv1alpha1.APIServiceNamespace) error { +func (c *reconciler) reconcile(ctx context.Context, sns *kubebindv1alpha2.APIServiceNamespace) error { var ns *corev1.Namespace nsName := sns.Namespace + "-" + sns.Name if sns.Status.Namespace != "" { @@ -54,7 +54,7 @@ func (c *reconciler) reconcile(ctx context.Context, sns *kubebindv1alpha1.APISer ObjectMeta: metav1.ObjectMeta{ Name: nsName, Annotations: map[string]string{ - kubebindv1alpha1.APIServiceNamespaceAnnotationKey: sns.Namespace + "/" + sns.Name, + kubebindv1alpha2.APIServiceNamespaceAnnotationKey: sns.Namespace + "/" + sns.Name, }, }, } @@ -63,7 +63,7 @@ func (c *reconciler) reconcile(ctx context.Context, sns *kubebindv1alpha1.APISer } } - if c.scope == kubebindv1alpha1.NamespacedScope { + if c.scope == kubebindv1alpha2.NamespacedScope { if err := c.ensureRBACRoleBinding(ctx, nsName, sns); err != nil { return fmt.Errorf("failed to ensure RBAC: %w", err) } @@ -76,7 +76,7 @@ func (c *reconciler) reconcile(ctx context.Context, sns *kubebindv1alpha1.APISer return nil } -func (c *reconciler) ensureRBACRoleBinding(ctx context.Context, ns string, sns *kubebindv1alpha1.APIServiceNamespace) error { +func (c *reconciler) ensureRBACRoleBinding(ctx context.Context, ns string, sns *kubebindv1alpha2.APIServiceNamespace) error { objName := "kube-binder" binding, err := c.getRoleBinding(ns, objName) if err != nil && !errors.IsNotFound(err) { diff --git a/contrib/example-backend/deploy/01-clusterrole.yaml b/contrib/example-backend/deploy/01-clusterrole.yaml index 9bae036e1..3488b382c 100644 --- a/contrib/example-backend/deploy/01-clusterrole.yaml +++ b/contrib/example-backend/deploy/01-clusterrole.yaml @@ -43,3 +43,23 @@ rules: resources: - "apiservicenamespaces" verbs: ["create","delete","patch","update","get","list","watch"] +- apiGroups: + - "kube-bind.io" + resources: + - "apiresourceschemas" + verbs: ["create","delete","patch","update","get","list","watch"] +- apiGroups: + - "kube-bind.io" + resources: + - "apiresourceschemas/status" + verbs: ["get","patch","update"] +- apiGroups: + - "kube-bind.io" + resources: + - "boundapiresourceschemas" + verbs: ["create","delete","patch","update","get","list","watch"] +- apiGroups: + - "kube-bind.io" + resources: + - "boundapiresourceschemas/status" + verbs: ["get","patch","update"] diff --git a/contrib/example-backend/http/handler.go b/contrib/example-backend/http/handler.go index 91398b05b..734a28634 100644 --- a/contrib/example-backend/http/handler.go +++ b/contrib/example-backend/http/handler.go @@ -45,7 +45,7 @@ import ( "github.com/kube-bind/kube-bind/contrib/example-backend/kubernetes/resources" "github.com/kube-bind/kube-bind/contrib/example-backend/template" bindversion "github.com/kube-bind/kube-bind/pkg/version" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) var ( @@ -62,7 +62,7 @@ var noCacheHeaders = map[string]string{ type handler struct { oidc *OIDCServiceProvider - scope kubebindv1alpha1.Scope + scope kubebindv1alpha2.InformerScope oidcAuthorizeURL string backendCallbackURL string providerPrettyName string @@ -80,7 +80,7 @@ func NewHandler( provider *OIDCServiceProvider, oidcAuthorizeURL, backendCallbackURL, providerPrettyName, testingAutoSelect string, cookieSigningKey, cookieEncryptionKey []byte, - scope kubebindv1alpha1.Scope, + scope kubebindv1alpha2.InformerScope, mgr *kubernetes.Manager, apiextensionsLister apiextensionslisters.CustomResourceDefinitionLister, ) (*handler, error) { @@ -121,17 +121,17 @@ func (h *handler) handleServiceExport(w http.ResponseWriter, r *http.Request) { ver = "v0.0.0" } - provider := &kubebindv1alpha1.BindingProvider{ + provider := &kubebindv1alpha2.BindingProvider{ TypeMeta: metav1.TypeMeta{ - APIVersion: kubebindv1alpha1.GroupVersion, + APIVersion: kubebindv1alpha2.GroupVersion, Kind: "BindingProvider", }, Version: ver, ProviderPrettyName: "example-backend", - AuthenticationMethods: []kubebindv1alpha1.AuthenticationMethod{ + AuthenticationMethods: []kubebindv1alpha2.AuthenticationMethod{ { Method: "OAuth2CodeGrant", - OAuth2CodeGrant: &kubebindv1alpha1.OAuth2CodeGrant{ + OAuth2CodeGrant: &kubebindv1alpha2.OAuth2CodeGrant{ AuthenticatedURL: oidcAuthorizeURL, }, }, @@ -306,18 +306,26 @@ func (h *handler) handleResources(w http.ResponseWriter, r *http.Request) { }) rightScopedCRDs := []*apiextensionsv1.CustomResourceDefinition{} for _, crd := range crds { - if h.scope == kubebindv1alpha1.ClusterScope || crd.Spec.Scope == apiextensionsv1.NamespaceScoped { + if h.scope == kubebindv1alpha2.ClusterScope || crd.Spec.Scope == apiextensionsv1.NamespaceScoped { rightScopedCRDs = append(rightScopedCRDs, crd) } } + apiResourceSchemas, err := h.kubeManager.ListAPIResourceSchemas(r.Context()) + if err != nil { + logger.Error(err, "failed to get api resource schemas") + http.Error(w, "internal error", http.StatusInternalServerError) + return + } bs := bytes.Buffer{} if err := resourcesTemplate.Execute(&bs, struct { - SessionID string - CRDs []*apiextensionsv1.CustomResourceDefinition + SessionID string + CRDs []*apiextensionsv1.CustomResourceDefinition + APIResourceSchemas []kubebindv1alpha2.APIResourceSchema }{ - SessionID: r.URL.Query().Get("s"), - CRDs: rightScopedCRDs, + SessionID: r.URL.Query().Get("s"), + CRDs: rightScopedCRDs, + APIResourceSchemas: apiResourceSchemas.Items, }); err != nil { logger.Error(err, "failed to execute template") http.Error(w, "internal error", http.StatusInternalServerError) @@ -368,20 +376,20 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { return } - request := kubebindv1alpha1.APIServiceExportRequestResponse{ + request := kubebindv1alpha2.APIServiceExportRequestResponse{ TypeMeta: metav1.TypeMeta{ - APIVersion: kubebindv1alpha1.SchemeGroupVersion.String(), + APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), Kind: "APIServiceExportRequest", }, - ObjectMeta: kubebindv1alpha1.NameObjectMeta{ + ObjectMeta: kubebindv1alpha2.NameObjectMeta{ // this is good for one resource. If there are more (in the future), // we need a better name heuristic. Note: it does not have to be unique. // But pretty is better. Name: resource + "." + group, }, - Spec: kubebindv1alpha1.APIServiceExportRequestSpec{ - Resources: []kubebindv1alpha1.APIServiceExportRequestResource{ - {GroupResource: kubebindv1alpha1.GroupResource{Group: group, Resource: resource}}, + Spec: kubebindv1alpha2.APIServiceExportRequestSpec{ + Resources: []kubebindv1alpha2.APIServiceExportRequestResource{ + {GroupResource: kubebindv1alpha2.GroupResource{Group: group, Resource: resource}}, }, }, } @@ -393,13 +401,13 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { http.Error(w, "internal error", http.StatusInternalServerError) return } - response := kubebindv1alpha1.BindingResponse{ + response := kubebindv1alpha2.BindingResponse{ TypeMeta: metav1.TypeMeta{ - APIVersion: kubebindv1alpha1.SchemeGroupVersion.String(), + APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), Kind: "BindingResponse", }, - Authentication: kubebindv1alpha1.BindingResponseAuthentication{ - OAuth2CodeGrant: &kubebindv1alpha1.BindingResponseAuthenticationOAuth2CodeGrant{ + Authentication: kubebindv1alpha2.BindingResponseAuthentication{ + OAuth2CodeGrant: &kubebindv1alpha2.BindingResponseAuthenticationOAuth2CodeGrant{ SessionID: state.SessionID, ID: idToken.Issuer + "/" + idToken.Subject, }, diff --git a/contrib/example-backend/http/server.go b/contrib/example-backend/http/server.go index 1ecb5db74..7efdfd787 100644 --- a/contrib/example-backend/http/server.go +++ b/contrib/example-backend/http/server.go @@ -18,6 +18,7 @@ package http import ( "context" + "log" "net" "net/http" "strconv" @@ -62,6 +63,7 @@ func (s *Server) Addr() net.Addr { } func (s *Server) Start(ctx context.Context) error { + log.Println("Starting HTTP server") server := &http.Server{ Handler: s.Router, ReadHeaderTimeout: 1 * time.Minute, @@ -73,8 +75,10 @@ func (s *Server) Start(ctx context.Context) error { go func() { if s.options.KeyFile == "" { + log.Println("Serving HTTP on", s.listener.Addr()) server.Serve(s.listener) //nolint:errcheck } else { + log.Println("Serving HTTPS on", s.listener.Addr()) server.ServeTLS(s.listener, s.options.CertFile, s.options.KeyFile) //nolint:errcheck } }() diff --git a/contrib/example-backend/kubernetes/indexers.go b/contrib/example-backend/kubernetes/indexers.go index 600871677..08a7032a6 100644 --- a/contrib/example-backend/kubernetes/indexers.go +++ b/contrib/example-backend/kubernetes/indexers.go @@ -26,7 +26,7 @@ const ( NamespacesByIdentity = "namespacesByIdentity" ) -func IndexNamespacesByIdentity(obj interface{}) ([]string, error) { +func IndexNamespacesByIdentity(obj any) ([]string, error) { ns, ok := obj.(*corev1.Namespace) if !ok { return nil, nil diff --git a/contrib/example-backend/kubernetes/manager.go b/contrib/example-backend/kubernetes/manager.go index c0ecf3c78..1a2335710 100644 --- a/contrib/example-backend/kubernetes/manager.go +++ b/contrib/example-backend/kubernetes/manager.go @@ -32,9 +32,10 @@ import ( kuberesources "github.com/kube-bind/kube-bind/contrib/example-backend/kubernetes/resources" "github.com/kube-bind/kube-bind/pkg/indexers" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) type Manager struct { @@ -132,7 +133,7 @@ func (m *Manager) HandleResources(ctx context.Context, identity, resource, group // first look for ClusterBinding to get old secret name kubeconfigSecretName := kuberesources.KubeconfigSecretName - cb, err := m.bindClient.KubeBindV1alpha1().ClusterBindings(ns).Get(ctx, kuberesources.ClusterBindingName, metav1.GetOptions{}) + cb, err := m.bindClient.KubeBindV1alpha2().ClusterBindings(ns).Get(ctx, kuberesources.ClusterBindingName, metav1.GetOptions{}) switch { case errors.IsNotFound(err): if err := kuberesources.CreateClusterBinding(ctx, m.bindClient, ns, "kubeconfig", m.providerPrettyName); err != nil { @@ -162,3 +163,7 @@ func (m *Manager) HandleResources(ctx context.Context, identity, resource, group return kfgSecret.Data["kubeconfig"], nil } + +func (m *Manager) ListAPIResourceSchemas(ctx context.Context) (*kubebindv1alpha2.APIResourceSchemaList, error) { + return m.bindClient.KubeBindV1alpha2().APIResourceSchemas().List(ctx, metav1.ListOptions{}) +} diff --git a/contrib/example-backend/kubernetes/resources/cluster_binding.go b/contrib/example-backend/kubernetes/resources/cluster_binding.go index 09c526317..96d805aaa 100644 --- a/contrib/example-backend/kubernetes/resources/cluster_binding.go +++ b/contrib/example-backend/kubernetes/resources/cluster_binding.go @@ -22,21 +22,21 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" ) func CreateClusterBinding(ctx context.Context, client bindclient.Interface, ns, secretName, providerPrettyName string) error { logger := klog.FromContext(ctx) - clusterBinding := &kubebindv1alpha1.ClusterBinding{ + clusterBinding := &kubebindv1alpha2.ClusterBinding{ ObjectMeta: metav1.ObjectMeta{ Name: ClusterBindingName, Namespace: ns, }, - Spec: kubebindv1alpha1.ClusterBindingSpec{ + Spec: kubebindv1alpha2.ClusterBindingSpec{ ProviderPrettyName: providerPrettyName, - KubeconfigSecretRef: kubebindv1alpha1.LocalSecretKeyRef{ + KubeconfigSecretRef: kubebindv1alpha2.LocalSecretKeyRef{ Name: secretName, Key: "kubeconfig", }, @@ -44,6 +44,6 @@ func CreateClusterBinding(ctx context.Context, client bindclient.Interface, ns, } logger.V(3).Info("Creating ClusterBinding") - _, err := client.KubeBindV1alpha1().ClusterBindings(ns).Create(ctx, clusterBinding, metav1.CreateOptions{}) + _, err := client.KubeBindV1alpha2().ClusterBindings(ns).Create(ctx, clusterBinding, metav1.CreateOptions{}) return err } diff --git a/contrib/example-backend/options/options.go b/contrib/example-backend/options/options.go index f9d9e4b08..730cf570d 100644 --- a/contrib/example-backend/options/options.go +++ b/contrib/example-backend/options/options.go @@ -27,7 +27,7 @@ import ( "k8s.io/component-base/logs" logsv1 "k8s.io/component-base/logs/api/v1" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type Options struct { @@ -80,8 +80,8 @@ func NewOptions() *Options { ExtraOptions: ExtraOptions{ NamespacePrefix: "cluster", PrettyName: "Example Backend", - ConsumerScope: string(kubebindv1alpha1.NamespacedScope), - ClusterScopedIsolation: string(kubebindv1alpha1.IsolationPrefixed), + ConsumerScope: string(kubebindv1alpha2.NamespacedScope), + ClusterScopedIsolation: string(kubebindv1alpha2.IsolationPrefixed), }, } } @@ -118,18 +118,18 @@ func (options *Options) Complete() (*CompletedOptions, error) { // normalize the scope and the isolation if strings.ToLower(options.ConsumerScope) == "namespaced" { - options.ConsumerScope = string(kubebindv1alpha1.NamespacedScope) + options.ConsumerScope = string(kubebindv1alpha2.NamespacedScope) } if strings.ToLower(options.ConsumerScope) == "cluster" { - options.ConsumerScope = string(kubebindv1alpha1.ClusterScope) + options.ConsumerScope = string(kubebindv1alpha2.ClusterScope) } switch strings.ToLower(options.ClusterScopedIsolation) { case "prefixed": - options.ClusterScopedIsolation = string(kubebindv1alpha1.IsolationPrefixed) + options.ClusterScopedIsolation = string(kubebindv1alpha2.IsolationPrefixed) case "namespaced": - options.ClusterScopedIsolation = string(kubebindv1alpha1.IsolationNamespaced) + options.ClusterScopedIsolation = string(kubebindv1alpha2.IsolationNamespaced) case "none": - options.ClusterScopedIsolation = string(kubebindv1alpha1.IsolationNone) + options.ClusterScopedIsolation = string(kubebindv1alpha2.IsolationNone) } if options.ExternalCAFile != "" && options.ExternalCA != nil { @@ -168,8 +168,8 @@ func (options *CompletedOptions) Validate() error { if err := options.Cookie.Validate(); err != nil { return err } - if options.ConsumerScope != string(kubebindv1alpha1.NamespacedScope) && options.ConsumerScope != string(kubebindv1alpha1.ClusterScope) { - return fmt.Errorf("consumer scope must be either %q or %q", kubebindv1alpha1.NamespacedScope, kubebindv1alpha1.ClusterScope) + if options.ConsumerScope != string(kubebindv1alpha2.NamespacedScope) && options.ConsumerScope != string(kubebindv1alpha2.ClusterScope) { + return fmt.Errorf("consumer scope must be either %q or %q", kubebindv1alpha2.NamespacedScope, kubebindv1alpha2.ClusterScope) } if options.ExternalAddress != "" { diff --git a/contrib/example-backend/server.go b/contrib/example-backend/server.go index 2bfddd0ab..48c4e5797 100644 --- a/contrib/example-backend/server.go +++ b/contrib/example-backend/server.go @@ -20,6 +20,7 @@ import ( "context" "encoding/base64" "fmt" + "log" "net" "k8s.io/apimachinery/pkg/util/sets" @@ -33,7 +34,7 @@ import ( "github.com/kube-bind/kube-bind/contrib/example-backend/deploy" examplehttp "github.com/kube-bind/kube-bind/contrib/example-backend/http" examplekube "github.com/kube-bind/kube-bind/contrib/example-backend/kubernetes" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type Server struct { @@ -86,7 +87,7 @@ func NewServer(config *Config) (*Server, error) { config.Options.ExternalCA, config.Options.TLSExternalServerName, config.KubeInformers.Core().V1().Namespaces(), - config.BindInformers.KubeBind().V1alpha1().APIServiceExports(), + config.BindInformers.KubeBind().V1alpha2().APIServiceExports(), ) if err != nil { return nil, fmt.Errorf("error setting up Kubernetes Manager: %w", err) @@ -114,7 +115,7 @@ func NewServer(config *Config) (*Server, error) { config.Options.TestingAutoSelect, signingKey, encryptionKey, - kubebindv1alpha1.Scope(config.Options.ConsumerScope), + kubebindv1alpha2.InformerScope(config.Options.ConsumerScope), s.Kubernetes, config.ApiextensionsInformers.Apiextensions().V1().CustomResourceDefinitions().Lister(), ) @@ -126,9 +127,9 @@ func NewServer(config *Config) (*Server, error) { // construct controllers s.ClusterBinding, err = clusterbinding.NewController( config.ClientConfig, - kubebindv1alpha1.Scope(config.Options.ConsumerScope), - config.BindInformers.KubeBind().V1alpha1().ClusterBindings(), - config.BindInformers.KubeBind().V1alpha1().APIServiceExports(), + kubebindv1alpha2.InformerScope(config.Options.ConsumerScope), + config.BindInformers.KubeBind().V1alpha2().ClusterBindings(), + config.BindInformers.KubeBind().V1alpha2().APIServiceExports(), config.KubeInformers.Rbac().V1().ClusterRoles(), config.KubeInformers.Rbac().V1().ClusterRoleBindings(), config.KubeInformers.Rbac().V1().RoleBindings(), @@ -139,10 +140,10 @@ func NewServer(config *Config) (*Server, error) { } s.ServiceNamespace, err = servicenamespace.NewController( config.ClientConfig, - kubebindv1alpha1.Scope(config.Options.ConsumerScope), - config.BindInformers.KubeBind().V1alpha1().APIServiceNamespaces(), - config.BindInformers.KubeBind().V1alpha1().ClusterBindings(), - config.BindInformers.KubeBind().V1alpha1().APIServiceExports(), + kubebindv1alpha2.InformerScope(config.Options.ConsumerScope), + config.BindInformers.KubeBind().V1alpha2().APIServiceNamespaces(), + config.BindInformers.KubeBind().V1alpha2().ClusterBindings(), + config.BindInformers.KubeBind().V1alpha2().APIServiceExports(), config.KubeInformers.Core().V1().Namespaces(), config.KubeInformers.Rbac().V1().Roles(), config.KubeInformers.Rbac().V1().RoleBindings(), @@ -152,7 +153,7 @@ func NewServer(config *Config) (*Server, error) { } s.ServiceExport, err = serviceexport.NewController( config.ClientConfig, - config.BindInformers.KubeBind().V1alpha1().APIServiceExports(), + config.BindInformers.KubeBind().V1alpha2().APIServiceExports(), config.ApiextensionsInformers.Apiextensions().V1().CustomResourceDefinitions(), ) if err != nil { @@ -160,11 +161,12 @@ func NewServer(config *Config) (*Server, error) { } s.ServiceExportRequest, err = serviceexportrequest.NewController( config.ClientConfig, - kubebindv1alpha1.Scope(config.Options.ConsumerScope), - kubebindv1alpha1.Isolation(config.Options.ClusterScopedIsolation), - config.BindInformers.KubeBind().V1alpha1().APIServiceExportRequests(), - config.BindInformers.KubeBind().V1alpha1().APIServiceExports(), + kubebindv1alpha2.InformerScope(config.Options.ConsumerScope), + kubebindv1alpha2.Isolation(config.Options.ClusterScopedIsolation), + config.BindInformers.KubeBind().V1alpha2().APIServiceExportRequests(), + config.BindInformers.KubeBind().V1alpha2().APIServiceExports(), config.ApiextensionsInformers.Apiextensions().V1().CustomResourceDefinitions(), + config.BindInformers.KubeBind().V1alpha2().APIResourceSchemas(), ) if err != nil { return nil, fmt.Errorf("error setting up ServiceExportRequest Controller: %w", err) @@ -214,6 +216,7 @@ func (s *Server) Run(ctx context.Context) error { go func() { <-ctx.Done() + log.Println("Context done") }() return s.WebServer.Start(ctx) } diff --git a/contrib/example-backend/template/resources.gohtml b/contrib/example-backend/template/resources.gohtml index d0d813ac3..fb8321c1e 100644 --- a/contrib/example-backend/template/resources.gohtml +++ b/contrib/example-backend/template/resources.gohtml @@ -8,9 +8,10 @@ - Resources + Resources - CRD +

CRD

{{$sid := .SessionID}}{{range .CRDs}}
@@ -25,7 +26,21 @@
{{end}}
- +

APIResourceSchema

+
+ {{$sid := .SessionID}}{{range .APIResourceSchemas}} +
+

{{.Spec.Names.Singular}}

+ +
+ Bind +
+
+ {{end}} +
diff --git a/deploy/crd/kube-bind.io_apiresourceschemas.yaml b/deploy/crd/kube-bind.io_apiresourceschemas.yaml index 6d9eb6887..992ad855d 100644 --- a/deploy/crd/kube-bind.io_apiresourceschemas.yaml +++ b/deploy/crd/kube-bind.io_apiresourceschemas.yaml @@ -13,8 +13,10 @@ spec: kind: APIResourceSchema listKind: APIResourceSchemaList plural: apiresourceschemas + shortNames: + - as singular: apiresourceschema - scope: Namespaced + scope: Cluster versions: - additionalPrinterColumns: - jsonPath: .metadata.creationTimestamp @@ -265,6 +267,15 @@ spec: description: |- schema describes the structural schema used for validation, pruning, and defaulting of this version of the custom resource. + properties: + openAPIV3Schema: + description: openAPIV3Schema is the OpenAPI v3 schema to + use for validation and pruning. + type: object + x-kubernetes-map-type: atomic + x-kubernetes-preserve-unknown-fields: true + required: + - openAPIV3Schema type: object x-kubernetes-map-type: atomic x-kubernetes-preserve-unknown-fields: true diff --git a/deploy/crd/kube-bind.io_apiservicebindings.yaml b/deploy/crd/kube-bind.io_apiservicebindings.yaml index ec2a15206..6eda6a293 100644 --- a/deploy/crd/kube-bind.io_apiservicebindings.yaml +++ b/deploy/crd/kube-bind.io_apiservicebindings.yaml @@ -151,6 +151,169 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.providerPrettyName + name: Provider + type: string + - jsonPath: .metadata.annotations.kube-bind\.io/resources + name: Resources + priority: 1 + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].message + name: Message + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: |- + APIServiceBinding binds an API service represented by a APIServiceExport + in a service provider cluster into a consumer cluster. This object lives in + the consumer cluster. + 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: |- + spec specifies how an API service from a service provider should be bound in the + local consumer cluster. + properties: + kubeconfigSecretRef: + description: kubeconfigSecretName is the secret ref that contains + the kubeconfig of the service cluster. + properties: + key: + description: The key of the secret to select from. Must be "kubeconfig". + enum: + - kubeconfig + type: string + name: + description: Name of the referent. + minLength: 1 + type: string + namespace: + description: Namespace of the referent. + minLength: 1 + type: string + required: + - key + - name + - namespace + type: object + x-kubernetes-validations: + - message: kubeconfigSecretRef is immutable + rule: self == oldSelf + required: + - kubeconfigSecretRef + type: object + status: + description: status contains reconciliation information for a service + binding. + properties: + boundSchemas: + description: |- + BoundSchemas contains references to all BoundAPIResourceSchema objects + associated with this APIServiceBinding, tracking consumer usage status. + items: + description: BoundSchemaReference contains a reference to a BoundAPIResourceSchema + with status information. + properties: + group: + default: "" + description: |- + group is the name of an API group. + For core groups this is the empty string '""'. + pattern: ^(|[a-z0-9]([-a-z0-9]*[a-z0-9](\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?)$ + type: string + resource: + description: |- + resource is the name of the resource. + Note: it is worth noting that you can not ask for permissions for resource provided by a CRD + not provided by an service binding export. + pattern: ^[a-z][-a-z0-9]*[a-z0-9]$ + type: string + required: + - resource + type: object + minItems: 1 + type: array + conditions: + description: conditions is a list of conditions that apply to the + APIServiceBinding. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + 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: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of 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. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + providerPrettyName: + description: |- + providerPrettyName is the pretty name of the service provider cluster. This + can be shared among different APIServiceBindings. + type: string + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/deploy/crd/kube-bind.io_apiserviceexportrequests.yaml b/deploy/crd/kube-bind.io_apiserviceexportrequests.yaml index 95c57ffe7..2fdff49dc 100644 --- a/deploy/crd/kube-bind.io_apiserviceexportrequests.yaml +++ b/deploy/crd/kube-bind.io_apiserviceexportrequests.yaml @@ -170,6 +170,164 @@ spec: - spec type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: |- + APIServiceExportRequest is represents a request session of kubectl-bind-apiservice. + + The service provider can prune these objects after some time. + 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: |- + spec specifies how an API service from a service provider should be bound in the + local consumer cluster. + properties: + parameters: + description: |- + parameters holds service provider specific parameters for this binding + request. + type: object + x-kubernetes-preserve-unknown-fields: true + x-kubernetes-validations: + - message: parameters are immutable + rule: self == oldSelf + resources: + description: resources is a list of resources that should be exported. + items: + properties: + group: + default: "" + description: |- + group is the name of an API group. + For core groups this is the empty string '""'. + pattern: ^(|[a-z0-9]([-a-z0-9]*[a-z0-9](\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?)$ + type: string + resource: + description: |- + resource is the name of the resource. + Note: it is worth noting that you can not ask for permissions for resource provided by a CRD + not provided by an service binding export. + pattern: ^[a-z][-a-z0-9]*[a-z0-9]$ + type: string + versions: + description: |- + versions is a list of versions that should be exported. If this is empty + a sensible default is chosen by the service provider. + items: + type: string + type: array + required: + - resource + type: object + minItems: 1 + type: array + x-kubernetes-validations: + - message: resources are immutable + rule: self == oldSelf + required: + - resources + type: object + status: + default: {} + description: status contains reconciliation information for a service + binding. + properties: + conditions: + description: |- + conditions is a list of conditions that apply to the ClusterBinding. It is + updated by the konnector and the service provider. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + 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: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of 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. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + phase: + default: Pending + description: |- + phase is the current phase of the binding request. It starts in Pending + and transitions to Succeeded or Failed. See the condition for detailed + information. + enum: + - Pending + - Failed + - Succeeded + type: string + terminalMessage: + description: |- + terminalMessage is a human readable message that describes the reason + for the current phase. + type: string + type: object + required: + - spec + type: object + served: true storage: true subresources: status: {} diff --git a/deploy/crd/kube-bind.io_apiserviceexports.yaml b/deploy/crd/kube-bind.io_apiserviceexports.yaml index 4b3728f68..972eca63c 100644 --- a/deploy/crd/kube-bind.io_apiserviceexports.yaml +++ b/deploy/crd/kube-bind.io_apiserviceexports.yaml @@ -426,6 +426,207 @@ spec: - message: informerScope is immutable rule: self.metadata.name == self.spec.names.plural+"."+self.spec.group served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Established")].status + name: Established + priority: 5 + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: |- + APIServiceExport specifies the resource to be exported. It is mostly a CRD: + - the spec is a CRD spec, but without webhooks + - the status reflects that on the consumer cluster + 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: spec specifies the resource. + properties: + clusterScopedIsolation: + description: |- + ClusterScopedIsolation specifies how cluster scoped service objects are isolated between multiple consumers on the provider side. + It can be "Prefixed", "Namespaced", or "None". + enum: + - Prefixed + - Namespaced + - None + type: string + informerScope: + description: |- + informerScope is the scope of the APIServiceExport. It can be either Cluster or Namespace. + + Cluster: The konnector has permission to watch all namespaces at once and cluster-scoped resources. + This is more efficient than watching each namespace individually. + Namespaced: The konnector has permission to watch only single namespaces. + This is more resource intensive. And it means cluster-scoped resources cannot be exported. + enum: + - Cluster + - Namespaced + type: string + x-kubernetes-validations: + - message: informerScope is immutable + rule: self == oldSelf + resources: + description: resources specifies the API resources to export + items: + description: APIResourceSchemaReference is a list of references + to APIResourceSchemas. + properties: + name: + description: Name is the name of the resource to export + type: string + type: + description: |- + Type of the resource to export + Currently only APIResourceSchema is supported + enum: + - APIResourceSchema + type: string + required: + - name + - type + type: object + type: array + required: + - informerScope + - resources + type: object + status: + description: status contains reconciliation information for the resource. + properties: + acceptedNames: + description: |- + acceptedNames are the names that are actually being used to serve discovery. + They may be different than the names in spec. + 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 + conditions: + description: |- + conditions is a list of conditions that apply to the APIServiceExport. It is + updated by the konnector on the consumer cluster. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + 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: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of 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. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + storedVersions: + description: |- + storedVersions lists all versions of CustomResources that were ever persisted. Tracking these + versions allows a migration path for stored versions in etcd. The field is mutable + so a migration controller can finish a migration to another version (ensuring + no old objects are left in storage), and then remove the rest of the + versions from this list. + Versions may not be removed from `spec.versions` while they exist in this list. + items: + type: string + type: array + type: object + required: + - spec + type: object + served: true storage: true subresources: status: {} diff --git a/deploy/crd/kube-bind.io_apiservicenamespaces.yaml b/deploy/crd/kube-bind.io_apiservicenamespaces.yaml index d6a4b7f60..7eeda90a3 100644 --- a/deploy/crd/kube-bind.io_apiservicenamespaces.yaml +++ b/deploy/crd/kube-bind.io_apiservicenamespaces.yaml @@ -66,6 +66,59 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.namespace + name: Namespace + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: |- + APIServiceNamespace defines how consumer namespaces map to service namespaces. + These objects are created by the konnector, and a service namespace is then + created by the service provider. + + The name of the APIServiceNamespace equals the namespace name in the consumer + cluster. + 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: spec specifies a service namespace. + type: object + status: + description: status contains reconciliation information for a service + namespace + properties: + namespace: + description: |- + namespace is the service provider namespace name that will be bound to the + consumer namespace named like this object. + type: string + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml b/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml index 31cb1015a..b71f65533 100644 --- a/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml +++ b/deploy/crd/kube-bind.io_boundapiresourceschemas.yaml @@ -13,6 +13,8 @@ spec: kind: BoundAPIResourceSchema listKind: BoundAPIResourceSchemaList plural: boundapiresourceschemas + shortNames: + - bas singular: boundapiresourceschema scope: Namespaced versions: @@ -267,6 +269,15 @@ spec: description: |- schema describes the structural schema used for validation, pruning, and defaulting of this version of the custom resource. + properties: + openAPIV3Schema: + description: openAPIV3Schema is the OpenAPI v3 schema to + use for validation and pruning. + type: object + x-kubernetes-map-type: atomic + x-kubernetes-preserve-unknown-fields: true + required: + - openAPIV3Schema type: object x-kubernetes-map-type: atomic x-kubernetes-preserve-unknown-fields: true @@ -350,60 +361,95 @@ spec: description: BoundAPIResourceSchemaStatus defines the observed state of the BoundAPIResourceSchema. properties: + acceptedNames: + description: |- + acceptedNames are the names that are actually being used to serve discovery. + They may be different than the names in spec. + 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 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. + description: Condition defines an observation of a object operational + state. 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. + 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 + A human readable message indicating details about the transition. + This field may be empty. 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. + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. type: string status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown + description: Status of the condition, one of 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])$ + 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. type: string required: - lastTransitionTime - - message - - reason - status - type type: object @@ -412,6 +458,17 @@ spec: description: Instantiations tracks the number of instances of the resource on the consumer side. type: integer + storedVersions: + description: |- + storedVersions lists all versions of CustomResources that were ever persisted. Tracking these + versions allows a migration path for stored versions in etcd. The field is mutable + so a migration controller can finish a migration to another version (ensuring + no old objects are left in storage), and then remove the rest of the + versions from this list. + Versions may not be removed from `spec.versions` while they exist in this list. + items: + type: string + type: array type: object type: object served: true diff --git a/deploy/crd/kube-bind.io_clusterbindings.yaml b/deploy/crd/kube-bind.io_clusterbindings.yaml index b7fbb454f..088315df4 100644 --- a/deploy/crd/kube-bind.io_clusterbindings.yaml +++ b/deploy/crd/kube-bind.io_clusterbindings.yaml @@ -169,6 +169,162 @@ spec: - message: cluster binding name should be cluster rule: self.metadata.name == "cluster" served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.konnectorVersion + name: Konnector Version + type: string + - jsonPath: .status.lastHeartbeatTime + name: Last Heartbeat + type: date + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha2 + schema: + openAPIV3Schema: + description: |- + ClusterBinding represents a bound consumer cluster. It lives in a service + provider cluster and is a singleton named "cluster" per namespace. + 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: spec represents the data in the newly created ClusterBinding. + properties: + kubeconfigSecretRef: + description: kubeconfigSecretName is the secret ref that contains + the kubeconfig of the service cluster. + properties: + key: + description: The key of the secret to select from. Must be "kubeconfig". + enum: + - kubeconfig + type: string + name: + description: Name of the referent. + minLength: 1 + type: string + required: + - key + - name + type: object + x-kubernetes-validations: + - message: kubeconfigSecretRef is immutable + rule: self == oldSelf + providerPrettyName: + description: |- + providerPrettyName is the pretty name of the service provider cluster. This + can be shared among different ServiceBindings. + minLength: 1 + type: string + serviceProviderSpec: + description: |- + serviceProviderSpec contains all the data and information about the service which has been bound to the service + binding request. The service providers decide what they need and what to configure based on what then include in + this field, such as service region, type, tiers, etc... + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - kubeconfigSecretRef + - providerPrettyName + type: object + status: + description: status contains reconciliation information for the service + binding. + properties: + conditions: + description: |- + conditions is a list of conditions that apply to the ClusterBinding. It is + updated by the konnector and the service provider. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + 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: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of 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. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + heartbeatInterval: + description: |- + heartbeatInterval is the maximal interval between heartbeats that the + konnector promises to send. The service provider can assume that the + konnector is not unhealthy if it does not receive a heartbeat within + this time. + type: string + konnectorVersion: + description: |- + konnectorVersion is the version of the konnector that is running on the + consumer cluster. + type: string + lastHeartbeatTime: + description: lastHeartbeatTime is the last time the konnector updated + the status. + format: date-time + type: string + type: object + required: + - spec + type: object + x-kubernetes-validations: + - message: cluster binding name should be cluster + rule: self.metadata.name == "cluster" + served: true storage: true subresources: status: {} diff --git a/deploy/examples/apiresourceschema.yaml b/deploy/examples/apiresourceschema.yaml new file mode 100644 index 000000000..5479f3de5 --- /dev/null +++ b/deploy/examples/apiresourceschema.yaml @@ -0,0 +1,39 @@ +apiVersion: kube-bind.io/v1alpha2 +kind: APIResourceSchema +metadata: + name: mangodbs.mangodb.com +spec: + informerScope: Namespaced + group: mangodb.com + names: + kind: MangoDB + listKind: MangoDBList + plural: mangodbs + singular: mangodb + scope: Namespaced + versions: + - name: v1alpha1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + tier: + type: string + enum: + - Dedicated + - Shared + default: Shared + status: + type: object + properties: + phase: + type: string + required: + - spec + subresources: + status: {} \ No newline at end of file diff --git a/deploy/examples/mangodb.yaml b/deploy/examples/mangodb.yaml new file mode 100644 index 000000000..e29cebcfb --- /dev/null +++ b/deploy/examples/mangodb.yaml @@ -0,0 +1,12 @@ +apiVersion: mangodb.com/v1alpha1 +kind: MangoDB + +metadata: + name: my-first-mangodb-instance + namespace: default + +spec: + tier: Dedicated + +status: + phase: Pending \ No newline at end of file diff --git a/docs/content/setup/local-setup-with-kind.md b/docs/content/setup/local-setup-with-kind.md index 2eab27f31..621f297b0 100644 --- a/docs/content/setup/local-setup-with-kind.md +++ b/docs/content/setup/local-setup-with-kind.md @@ -1,11 +1,13 @@ # Local kube-bind with kind This guide will walk you through setting up kube-bind between two Kubernetes clusters, where -* **Backend cluster**: - * Deploys: dex, cert-manager, kube-bind/example-backend - * Provides: kube-bind compatible backend for MangoDB resources -* **App cluster**: - * Provides: an application consuming MangoDBs + +**Backend cluster**: + * Deploys dex, cert-manager and kube-bind/example-backend + * Provides kube-bind compatible backend for MangoDB resources + +**App cluster**: + * Provides an application consuming MangoDBs ## Pre-requisites @@ -28,9 +30,9 @@ To install `kubectl-bind` plugin, please download the archive for your platform > > See https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files for more details. -## Backend cluster +## Provider cluster -The backend cluster we'll prepare in this section will provide a kube-bind compatible backend that will provide a controller for a demo resource "MangoDB" we'll consume in another cluster later. +The provider cluster we'll prepare in this section will provide a kube-bind compatible backend that will provide a controller for a demo resource "MangoDB" we'll consume in another cluster later. > What is MangoDB? It is just an example CRD to demonstrate kube-bind's capabilities and testing, without any workloads. See its definition in [/test/e2e/bind/fixtures/provider/crd-mangodb.yaml](/test/e2e/bind/fixtures/provider/crd-mangodb.yaml). diff --git a/docs/content/setup/quickstart.md b/docs/content/setup/quickstart.md index 4750d51dc..82ddabffa 100644 --- a/docs/content/setup/quickstart.md +++ b/docs/content/setup/quickstart.md @@ -11,4 +11,90 @@ description: > ## Start with Kube-Bind -If you are reading this page - we need help populating this page. \ No newline at end of file +This section allows you to run local kube-bind backend and konnector. +The main challenge when running it locally is to have multiple clusters available and accessible. + +For this we use [kcp](https://github.com/kcp-dev/kcp) to create a local clusters under single kcp instance. +By having a single kcp instance, we can have multiple clusters available and accessible via same url. + +To run kcp, you need to have a kcp binary. + +```shell +$ make run-kcp +``` + +To run the current backend, there must be an OIDC issuer installed in place to do the +the oauth2 workflow. + +We use dex to manage OIDC, following the steps below you can run a local OIDC issuer using dex: +* First, clone the dex repo: `git clone https://github.com/dexidp/dex.git` +* `cd dex` and then build the dex binary `make build` +* The binary will be created in `bin/dex` +* Adjust the config file(`examples/config-dev.yaml`) for dex by specifying the server callback method: +```yaml +staticClients: +- id: kube-bind + redirectURIs: + - 'http://127.0.0.1:8080/callback' + name: 'Kube Bind' +``` +* Run dex: `./bin/dex serve examples/config-dev.yaml` + +Next you should be able to run the backend. For it you need a kubernetes cluster (e.g. kind) +accessible. + +***Note: make sure before running the backend that you have the dex server up and running as mentioned above +and that you have at least one k8s cluster. Take a look at the backend option in the cmd/main.go file*** + +Create copy of kcp kubeconfig and create provider cluster: + +```shell +$ cp .kcp/admin.kubeconfig .kcp/provider.kubeconfig +$ export KUBECONFIG=.kcp/provider.kubeconfig +$ kubectl ws create provider --enter +``` + +* apply the CRDs: `kubectl apply -f deploy/crd` +* In order to populate binding list on website, we need a CRD with label `kube-bind.io/exported: true`. Apply example APIResourceSchema for the CRD: `kubectl apply -f deploy/examples/crd-mangodb.yaml` +* start the backend binary with the right flags: +```shell +$ make build +$ bin/example-backend \ + --oidc-issuer-client-secret=ZXhhbXBsZS1hcHAtc2VjcmV0 \ + --oidc-issuer-client-id=kube-bind \ + --oidc-issuer-url=http://127.0.0.1:5556/dex \ + --oidc-callback-url=http://127.0.0.1:8080/callback \ + --pretty-name="BigCorp.com" \ + --namespace-prefix="kube-bind-" \ + --cookie-signing-key=bGMHz7SR9XcI9JdDB68VmjQErrjbrAR9JdVqjAOKHzE= \ + --cookie-encryption-key=wadqi4u+w0bqnSrVFtM38Pz2ykYVIeeadhzT34XlC1Y= +``` + +where `ZXhhbXBsZS1hcHAtc2VjcmV0` matches the value of the dex config file. + +The `--cookie-signing-key` and `--cookie-encryption-key` settings can be generated using: +```shell +$ openssl rand -base64 32 +WQh88mNOY0Z3tLy1/WOud7qIEEBxz+POc4j8BsYenYo= +``` + +The `--cookie-signing-key` option is required and supports 32 and 64 byte lengths. +The `--cookie-encryption-key` option is optional and supports byte lengths of 16, 24, 32 for AES-128, AES-192, or AES-256. + +### Consumer +Now create consumer cluster: + +```shell +$ export KUBECONFIG=.kcp/admin.kubeconfig +$ kubectl ws create consumer --enter +``` + +Now create the APIServiceExportRequest: + +```shell +$ ./bin/kubectl-bind http://127.0.0.1:8080/export --dry-run -o yaml > apiserviceexport.yaml +# This will wait for konnector to be ready. Once this gets running - start the konnector bellow +$ ./bin/kubectl-bind apiservice --remote-namespace kube-bind-77wsg --remote-kubeconfig .kcp/provider.kubeconfig -f apiserviceexport.yaml --skip-konnector +# run konnector +$ go run ./cmd/konnector/ --lease-namespace default +``` diff --git a/docs/generators/cli-doc/go.mod b/docs/generators/cli-doc/go.mod index f7a735ff0..855b2e37f 100644 --- a/docs/generators/cli-doc/go.mod +++ b/docs/generators/cli-doc/go.mod @@ -4,13 +4,13 @@ go 1.23.4 replace ( github.com/kube-bind/kube-bind => ../../../ - github.com/kube-bind/kube-bind/cli => ../../../cli - github.com/kube-bind/kube-bind/sdk => ../../../sdk + github.com/kube-bind/kube-bind/sdk/apis => ../../../sdk/apis + github.com/kube-bind/kube-bind/sdk/client => ../../../sdk/client ) require ( github.com/kcp-dev/kcp v0.26.1 - github.com/kube-bind/kube-bind/cli v0.0.0-00010101000000-000000000000 + github.com/kube-bind/kube-bind/cli v0.0.0-20250515145715-d9f20e7c840d ) require ( @@ -53,9 +53,9 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kube-bind/kube-bind v0.4.6 // indirect - github.com/kube-bind/kube-bind/sdk/apis v0.4.6 // indirect - github.com/kube-bind/kube-bind/sdk/client v0.4.6 // indirect + github.com/kube-bind/kube-bind v0.4.8 // indirect + github.com/kube-bind/kube-bind/sdk/apis v0.4.8 // indirect + github.com/kube-bind/kube-bind/sdk/client v0.4.8 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/docs/generators/cli-doc/go.sum b/docs/generators/cli-doc/go.sum index d7dc46831..62a2ef294 100644 --- a/docs/generators/cli-doc/go.sum +++ b/docs/generators/cli-doc/go.sum @@ -117,10 +117,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kube-bind/kube-bind/sdk/apis v0.4.6 h1:bZHGwq9ckrQIBi5dl+uoWL/aYQvNYn5NfrbP9DJVGgw= -github.com/kube-bind/kube-bind/sdk/apis v0.4.6/go.mod h1:gR234zh0uX7aRXKsb9UPhPPq33u+zhL5NuyrzJFJI2Y= -github.com/kube-bind/kube-bind/sdk/client v0.4.6 h1:zcBA3qWAnRmbRaZZX62JPdLUA30n0CrE+fxzEowH0Ok= -github.com/kube-bind/kube-bind/sdk/client v0.4.6/go.mod h1:BaLx9LytSHd6s+VRNiNdleqnNzHoV1A5AoUvskyJ9tc= +github.com/kube-bind/kube-bind/cli v0.0.0-20250515145715-d9f20e7c840d h1:XNKsPss6lwmEZdNIhiWxVB/dhT8apYwyBgtMAddAUrE= +github.com/kube-bind/kube-bind/cli v0.0.0-20250515145715-d9f20e7c840d/go.mod h1:+Si5+7jDEdgWGwZw0Pho2VGtkNnonEgDLVMThVN2LC4= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= diff --git a/go.mod b/go.mod index 374e18c18..a2a82e193 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,9 @@ module github.com/kube-bind/kube-bind go 1.23.4 replace ( + github.com/kube-bind/kube-bind => ./ github.com/kube-bind/kube-bind/cli => ./cli + github.com/kube-bind/kube-bind/contrib => ./contrib github.com/kube-bind/kube-bind/sdk/apis => ./sdk/apis github.com/kube-bind/kube-bind/sdk/client => ./sdk/client ) @@ -17,9 +19,9 @@ require ( github.com/gorilla/securecookie v1.1.1 github.com/headzoo/surf v1.0.1 github.com/kcp-dev/kcp/pkg/apis v0.11.0 - github.com/kube-bind/kube-bind/cli v0.0.0-00010101000000-000000000000 - github.com/kube-bind/kube-bind/sdk/apis v0.4.6 - github.com/kube-bind/kube-bind/sdk/client v0.4.6 + github.com/kube-bind/kube-bind/cli v0.0.0-20250515145715-d9f20e7c840d + github.com/kube-bind/kube-bind/sdk/apis v0.4.8 + github.com/kube-bind/kube-bind/sdk/client v0.0.0-20250515145715-d9f20e7c840d github.com/martinlindhe/base36 v1.1.1 github.com/pierrec/lz4 v2.6.1+incompatible github.com/spf13/cobra v1.8.1 diff --git a/hack/kind-example-setup/app-cluster.sh b/hack/kind-example-setup/app-cluster.sh index d970642b0..6c7bb871d 100755 --- a/hack/kind-example-setup/app-cluster.sh +++ b/hack/kind-example-setup/app-cluster.sh @@ -17,8 +17,12 @@ set -o nounset set -o pipefail -source "$(dirname "$0")/host-ip.sh" -get_host_ip +DEFAULT_KONNECTOR_IMAGE="ghcr.io/kube-bind/konnector:v0.4.6" + +if [[ -z "${HOST_IP:-}" ]]; then + source "$(dirname "$0")/host-ip.sh" + get_host_ip +fi cat << EOF_AppClusterDefinition | kind create cluster --config=- apiVersion: kind.x-k8s.io/v1alpha4 @@ -28,4 +32,22 @@ networking: apiServerAddress: ${HOST_IP} EOF_AppClusterDefinition -kubectl bind http://${HOST_IP}:8080/export +kubectl config use-context kind-app + +if [[ -n "${KONNECTOR_IMAGE:-}" ]]; then + pushd "$(dirname "$0")/../.." + KIND_CLUSTER=app make kind-load + popd + + if [[ -z "${TAG:-}" ]]; then + REV=$(git rev-parse --short HEAD) + TAG=${REV} + fi + konnector_image="${KONNECTOR_IMAGE}:${TAG}" + echo "Using override konnector image: ${konnector_image}" + $(dirname "$0")/../../bin/kubectl-bind --konnector-image=${konnector_image} http://${HOST_IP}:8080/export +else + konnector_image=${DEFAULT_KONNECTOR_IMAGE} + echo "Using default konnector image: ${konnector_image}" + kubectl bind --konnector-image=${konnector_image} http://${HOST_IP}:8080/export +fi diff --git a/hack/kind-example-setup/backend-cluster.sh b/hack/kind-example-setup/backend-cluster.sh index 8f6bd971b..69128e3fe 100755 --- a/hack/kind-example-setup/backend-cluster.sh +++ b/hack/kind-example-setup/backend-cluster.sh @@ -18,13 +18,19 @@ set -o errexit set -o nounset set -o pipefail -source "$(dirname "$0")/host-ip.sh" -get_host_ip +DEFAULT_EXAMPLE_BACKEND_IMAGE="ghcr.io/kube-bind/example-backend:v0.4.6" + +if [[ -z "${HOST_IP:-}" ]]; then + source "$(dirname "$0")/host-ip.sh" + get_host_ip +fi cat << EOF_BackendClusterDefinition | kind create cluster --config=- apiVersion: kind.x-k8s.io/v1alpha4 kind: Cluster name: backend +networking: + apiServerAddress: ${HOST_IP} nodes: - role: control-plane extraPortMappings: @@ -38,6 +44,22 @@ nodes: protocol: TCP EOF_BackendClusterDefinition +if [[ -n "${EXAMPLE_BACKEND_IMAGE:-}" ]]; then + pushd "$(dirname "$0")/../.." + KIND_CLUSTER=backend make kind-load + popd + + if [[ -z "${TAG:-}" ]]; then + REV=$(git rev-parse --short HEAD) + TAG=${REV} + fi + example_backend_image="${EXAMPLE_BACKEND_IMAGE}:${TAG}" + echo "Using override example backend image: ${example_backend_image}" +else + example_backend_image=${DEFAULT_EXAMPLE_BACKEND_IMAGE} + echo "Using default example backend image: ${example_backend_image}" +fi + helm repo add jetstack https://charts.jetstack.io helm install \ --create-namespace \ @@ -95,8 +117,8 @@ helm install \ dex dex/dex \ -f - -kubectl apply -f ../../deploy/crd -kubectl apply -f ../../test/e2e/bind/fixtures/provider/crd-mangodb.yaml +kubectl apply -f $(dirname "$0")/../../deploy/crd +kubectl apply -f $(dirname "$0")/../../test/e2e/bind/fixtures/provider/crd-mangodb.yaml kubectl create namespace backend # This is the address that will be used when generating kubeconfigs the App cluster, # and so we need to be able to reach it from outside. @@ -106,7 +128,7 @@ kubectl create clusterrolebinding backend-admin --clusterrole cluster-admin --se # Create a new Deployment for the MangoDB backend. kubectl --namespace backend \ create deployment mangodb \ - --image ghcr.io/kube-bind/example-backend:v0.4.6 \ + --image ${example_backend_image} \ --port 8080 \ -- /ko-app/example-backend \ --listen-address 0.0.0.0:8080 \ diff --git a/hack/update-codegen-clients-kcp.sh b/hack/update-codegen-clients-kcp.sh index d31d3c11c..470efc4d8 100755 --- a/hack/update-codegen-clients-kcp.sh +++ b/hack/update-codegen-clients-kcp.sh @@ -36,6 +36,7 @@ ${KUBE_APPLYCONFIGURATION_GEN} \ --output-pkg github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration \ --output-dir "sdk/kcp/applyconfiguration" \ github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1 \ + github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2 \ github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1 \ k8s.io/apimachinery/pkg/apis/meta/v1 \ k8s.io/apimachinery/pkg/runtime \ @@ -43,6 +44,7 @@ ${KUBE_APPLYCONFIGURATION_GEN} \ "${KUBE_CLIENT_GEN}" \ --input github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1 \ + --input github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2 \ --input-base="" \ --apply-configuration-package=github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration \ --clientset-name "versioned" \ @@ -57,4 +59,4 @@ ${CODE_GENERATOR} \ "informer:outputPackagePath=github.com/kube-bind/kube-bind/sdk/kcp,singleClusterClientPackagePath=github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned,apiPackagePath=github.com/kube-bind/kube-bind/sdk/apis,headerFile=${BOILERPLATE_HEADER}" \ "paths=./..." \ "output:dir=../kcp" -popd \ No newline at end of file +popd diff --git a/pkg/indexers/crd.go b/pkg/indexers/crd.go index 15f9d868c..e59fe6bba 100644 --- a/pkg/indexers/crd.go +++ b/pkg/indexers/crd.go @@ -5,14 +5,14 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) const ( CRDByServiceBinding = "CRDByServiceBinding" ) -func IndexCRDByServiceBinding(obj interface{}) ([]string, error) { +func IndexCRDByServiceBinding(obj any) ([]string, error) { crd, ok := obj.(*apiextensionsv1.CustomResourceDefinition) if !ok { return nil, nil @@ -21,7 +21,7 @@ func IndexCRDByServiceBinding(obj interface{}) ([]string, error) { bindings := []string{} for _, ref := range crd.OwnerReferences { parts := strings.SplitN(ref.APIVersion, "/", 2) - if parts[0] != kubebindv1alpha1.SchemeGroupVersion.Group || ref.Kind != "APIServiceBinding" { + if parts[0] != kubebindv1alpha2.SchemeGroupVersion.Group || ref.Kind != "APIServiceBinding" { continue } bindings = append(bindings, ref.Name) diff --git a/pkg/indexers/servicebinding.go b/pkg/indexers/servicebinding.go index f52c61fd1..4c2ce544f 100644 --- a/pkg/indexers/servicebinding.go +++ b/pkg/indexers/servicebinding.go @@ -17,7 +17,7 @@ limitations under the License. package indexers import ( - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) const ( @@ -25,15 +25,15 @@ const ( ByServiceBindingKubeconfigSecret = "byKubeconfigSecret" ) -func IndexServiceBindingByKubeconfigSecret(obj interface{}) ([]string, error) { - binding, ok := obj.(*kubebindv1alpha1.APIServiceBinding) +func IndexServiceBindingByKubeconfigSecret(obj any) ([]string, error) { + binding, ok := obj.(*kubebindv1alpha2.APIServiceBinding) if !ok { return nil, nil } return []string{ByServiceBindingKubeconfigSecretKey(binding)}, nil } -func ByServiceBindingKubeconfigSecretKey(binding *kubebindv1alpha1.APIServiceBinding) string { +func ByServiceBindingKubeconfigSecretKey(binding *kubebindv1alpha2.APIServiceBinding) string { ref := &binding.Spec.KubeconfigSecretRef return ref.Namespace + "/" + ref.Name } diff --git a/pkg/indexers/serviceexport.go b/pkg/indexers/serviceexport.go index 0f5601a84..5f8104267 100644 --- a/pkg/indexers/serviceexport.go +++ b/pkg/indexers/serviceexport.go @@ -17,15 +17,15 @@ limitations under the License. package indexers import ( - "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) const ( ServiceExportByCustomResourceDefinition = "serviceExportByCustomResourceDefinition" ) -func IndexServiceExportByCustomResourceDefinition(obj interface{}) ([]string, error) { - export, ok := obj.(*v1alpha1.APIServiceExport) +func IndexServiceExportByCustomResourceDefinition(obj any) ([]string, error) { + export, ok := obj.(*v1alpha2.APIServiceExport) if !ok { return nil, nil } diff --git a/pkg/indexers/serviceexportrequest.go b/pkg/indexers/serviceexportrequest.go index 627e8a62d..ab664bdcf 100644 --- a/pkg/indexers/serviceexportrequest.go +++ b/pkg/indexers/serviceexportrequest.go @@ -17,7 +17,7 @@ limitations under the License. package indexers import ( - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) const ( @@ -25,8 +25,8 @@ const ( ServiceExportRequestByServiceExport = "ServiceExportRequestByServiceExport" ) -func IndexServiceExportRequestByGroupResource(obj interface{}) ([]string, error) { - sbr, ok := obj.(*kubebindv1alpha1.APIServiceExportRequest) +func IndexServiceExportRequestByGroupResource(obj any) ([]string, error) { + sbr, ok := obj.(*kubebindv1alpha2.APIServiceExportRequest) if !ok { return nil, nil } @@ -37,8 +37,8 @@ func IndexServiceExportRequestByGroupResource(obj interface{}) ([]string, error) return keys, nil } -func IndexServiceExportRequestByServiceExport(obj interface{}) ([]string, error) { - sbr, ok := obj.(*kubebindv1alpha1.APIServiceExportRequest) +func IndexServiceExportRequestByServiceExport(obj any) ([]string, error) { + sbr, ok := obj.(*kubebindv1alpha2.APIServiceExportRequest) if !ok { return nil, nil } diff --git a/pkg/indexers/servicenamespace.go b/pkg/indexers/servicenamespace.go index db8d6f457..5a0a5bfc1 100644 --- a/pkg/indexers/servicenamespace.go +++ b/pkg/indexers/servicenamespace.go @@ -17,15 +17,15 @@ limitations under the License. package indexers import ( - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) const ( ServiceNamespaceByNamespace = "ServiceNamespaceByNamespace" ) -func IndexServiceNamespaceByNamespace(obj interface{}) ([]string, error) { - sn, ok := obj.(*kubebindv1alpha1.APIServiceNamespace) +func IndexServiceNamespaceByNamespace(obj any) ([]string, error) { + sn, ok := obj.(*kubebindv1alpha2.APIServiceNamespace) if !ok || sn.Status.Namespace == "" { return nil, nil } diff --git a/pkg/konnector/controllers/cluster/cluster_controller.go b/pkg/konnector/controllers/cluster/cluster_controller.go index 40005e923..471048403 100644 --- a/pkg/konnector/controllers/cluster/cluster_controller.go +++ b/pkg/konnector/controllers/cluster/cluster_controller.go @@ -39,12 +39,12 @@ import ( "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/servicebinding" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -57,7 +57,7 @@ const ( func NewController( consumerSecretRefKey string, providerNamespace string, - reconcileServiceBinding func(binding *kubebindv1alpha1.APIServiceBinding) bool, + reconcileServiceBinding func(binding *kubebindv1alpha2.APIServiceBinding) bool, consumerConfig, providerConfig *rest.Config, namespaceInformer dynamic.Informer[corelisters.NamespaceLister], serviceBindingInformer dynamic.Informer[bindlisters.APIServiceBindingLister], @@ -106,9 +106,9 @@ func NewController( heartbeatInterval, consumerConfig, providerConfig, - providerBindInformers.KubeBind().V1alpha1().ClusterBindings(), + providerBindInformers.KubeBind().V1alpha2().ClusterBindings(), serviceBindingInformer, - providerBindInformers.KubeBind().V1alpha1().APIServiceExports(), + providerBindInformers.KubeBind().V1alpha2().APIServiceExports(), consumerSecretInformers.Core().V1().Secrets(), providerKubeInformers.Core().V1().Secrets(), ) @@ -118,7 +118,7 @@ func NewController( namespacedeletionCtrl, err := namespacedeletion.NewController( providerConfig, providerNamespace, - providerBindInformers.KubeBind().V1alpha1().APIServiceNamespaces(), + providerBindInformers.KubeBind().V1alpha2().APIServiceNamespaces(), namespaceInformer, ) if err != nil { @@ -131,7 +131,7 @@ func NewController( consumerConfig, providerConfig, serviceBindingInformer, - providerBindInformers.KubeBind().V1alpha1().APIServiceExports(), + providerBindInformers.KubeBind().V1alpha2().APIServiceExports(), crdInformer, ) if err != nil { @@ -142,8 +142,8 @@ func NewController( providerNamespace, consumerConfig, providerConfig, - providerBindInformers.KubeBind().V1alpha1().APIServiceExports(), - providerBindInformers.KubeBind().V1alpha1().APIServiceNamespaces(), + providerBindInformers.KubeBind().V1alpha2().APIServiceExports(), + providerBindInformers.KubeBind().V1alpha2().APIServiceNamespaces(), serviceBindingInformer, crdInformer, ) @@ -221,10 +221,10 @@ func (c *controller) Start(ctx context.Context) { case <-ctx.Done(): // timeout logger.Info("informers did not sync in time", "timeout", heartbeatInterval/2) - c.updateServiceBindings(ctx, func(binding *kubebindv1alpha1.APIServiceBinding) { + c.updateServiceBindings(ctx, func(binding *kubebindv1alpha2.APIServiceBinding) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionInformersSynced, + kubebindv1alpha2.APIServiceBindingConditionInformersSynced, "InformerSyncTimeout", conditionsapi.ConditionSeverityError, "Informers did not sync within %s", @@ -242,8 +242,8 @@ func (c *controller) Start(ctx context.Context) { } logger.V(2).Info("setting InformersSynced condition to true on service binding") - c.updateServiceBindings(ctx, func(binding *kubebindv1alpha1.APIServiceBinding) { - conditions.MarkTrue(binding, kubebindv1alpha1.APIServiceBindingConditionInformersSynced) + c.updateServiceBindings(ctx, func(binding *kubebindv1alpha2.APIServiceBinding) { + conditions.MarkTrue(binding, kubebindv1alpha2.APIServiceBindingConditionInformersSynced) }) go c.clusterbindingCtrl.Start(ctx, 2) @@ -254,7 +254,7 @@ func (c *controller) Start(ctx context.Context) { <-ctx.Done() } -func (c *controller) updateServiceBindings(ctx context.Context, update func(*kubebindv1alpha1.APIServiceBinding)) { +func (c *controller) updateServiceBindings(ctx context.Context, update func(*kubebindv1alpha2.APIServiceBinding)) { logger := klog.FromContext(ctx) objs, err := c.serviceBindingIndexer.ByIndex(indexers.ByServiceBindingKubeconfigSecret, c.consumerSecretRefKey) @@ -263,13 +263,13 @@ func (c *controller) updateServiceBindings(ctx context.Context, update func(*kub return } for _, obj := range objs { - binding := obj.(*kubebindv1alpha1.APIServiceBinding) + binding := obj.(*kubebindv1alpha2.APIServiceBinding) orig := binding binding = binding.DeepCopy() update(binding) if !reflect.DeepEqual(binding.Status.Conditions, orig.Status.Conditions) { logger.V(2).Info("updating service binding", "binding", binding.Name) - if _, err := c.bindClient.KubeBindV1alpha1().APIServiceBindings().UpdateStatus(ctx, binding, metav1.UpdateOptions{}); err != nil { + if _, err := c.bindClient.KubeBindV1alpha2().APIServiceBindings().UpdateStatus(ctx, binding, metav1.UpdateOptions{}); err != nil { logger.Error(err, "failed to update service binding", "binding", binding.Name) continue } diff --git a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go index 82c47ac9c..80f95dd8d 100644 --- a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go +++ b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go @@ -39,12 +39,12 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -136,21 +136,21 @@ func NewController( }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.ClusterBinding, *kubebindv1alpha1.ClusterBindingSpec, *kubebindv1alpha1.ClusterBindingStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.ClusterBinding] { - return providerBindClient.KubeBindV1alpha1().ClusterBindings(ns) + commit: committer.NewCommitter[*kubebindv1alpha2.ClusterBinding, *kubebindv1alpha2.ClusterBindingSpec, *kubebindv1alpha2.ClusterBindingStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.ClusterBinding] { + return providerBindClient.KubeBindV1alpha2().ClusterBindings(ns) }, ), } if _, err := clusterBindingInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueClusterBinding(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueClusterBinding(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueClusterBinding(logger, obj) }, }); err != nil { @@ -158,13 +158,13 @@ func NewController( } if _, err := providerSecretInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueProviderSecret(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueProviderSecret(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueProviderSecret(logger, obj) }, }); err != nil { @@ -172,13 +172,13 @@ func NewController( } if _, err := consumerSecretInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueConsumerSecret(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueConsumerSecret(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueConsumerSecret(logger, obj) }, }); err != nil { @@ -186,15 +186,15 @@ func NewController( } if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(old, newObj interface{}) { - oldExport, ok := old.(*kubebindv1alpha1.APIServiceExport) + UpdateFunc: func(old, newObj any) { + oldExport, ok := old.(*kubebindv1alpha2.APIServiceExport) if !ok { return } - newExport, ok := old.(*kubebindv1alpha1.APIServiceExport) + newExport, ok := old.(*kubebindv1alpha2.APIServiceExport) if !ok { return } @@ -203,7 +203,7 @@ func NewController( } c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -213,7 +213,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.ClusterBindingSpec, *kubebindv1alpha1.ClusterBindingStatus] +type Resource = committer.Resource[*kubebindv1alpha2.ClusterBindingSpec, *kubebindv1alpha2.ClusterBindingStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // controller reconciles ClusterBindings on the service provider cluster, including heartbeating. @@ -241,7 +241,7 @@ type controller struct { commit CommitFunc } -func (c *controller) enqueueClusterBinding(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueClusterBinding(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -252,7 +252,7 @@ func (c *controller) enqueueClusterBinding(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *controller) enqueueConsumerSecret(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueConsumerSecret(logger klog.Logger, obj any) { secretKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -266,7 +266,7 @@ func (c *controller) enqueueConsumerSecret(logger klog.Logger, obj interface{}) } } -func (c *controller) enqueueProviderSecret(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueProviderSecret(logger klog.Logger, obj any) { secretKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -298,7 +298,7 @@ func (c *controller) enqueueProviderSecret(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceExport(logger klog.Logger, obj any) { seKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -408,10 +408,10 @@ func (c *controller) process(ctx context.Context, key string) error { errs = append(errs, err) // try to update service bindings - c.updateServiceBindings(ctx, func(binding *kubebindv1alpha1.APIServiceBinding) { + c.updateServiceBindings(ctx, func(binding *kubebindv1alpha2.APIServiceBinding) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionHeartbeating, + kubebindv1alpha2.APIServiceBindingConditionHeartbeating, "ClusterBindingUpdateFailed", conditionsapi.ConditionSeverityWarning, "Failed to update service provider ClusterBinding: %v", err, @@ -419,15 +419,15 @@ func (c *controller) process(ctx context.Context, key string) error { }) } else { // try to update service bindings - c.updateServiceBindings(ctx, func(binding *kubebindv1alpha1.APIServiceBinding) { - conditions.MarkTrue(binding, kubebindv1alpha1.APIServiceBindingConditionHeartbeating) + c.updateServiceBindings(ctx, func(binding *kubebindv1alpha2.APIServiceBinding) { + conditions.MarkTrue(binding, kubebindv1alpha2.APIServiceBindingConditionHeartbeating) }) } return utilerrors.NewAggregate(errs) } -func (c *controller) updateServiceBindings(ctx context.Context, update func(*kubebindv1alpha1.APIServiceBinding)) { +func (c *controller) updateServiceBindings(ctx context.Context, update func(*kubebindv1alpha2.APIServiceBinding)) { logger := klog.FromContext(ctx) objs, err := c.serviceBindingInformer.Informer().GetIndexer().ByIndex(indexers.ByServiceBindingKubeconfigSecret, c.consumerSecretRefKey) @@ -436,13 +436,13 @@ func (c *controller) updateServiceBindings(ctx context.Context, update func(*kub return } for _, obj := range objs { - binding := obj.(*kubebindv1alpha1.APIServiceBinding) + binding := obj.(*kubebindv1alpha2.APIServiceBinding) orig := binding binding = binding.DeepCopy() update(binding) if !reflect.DeepEqual(binding.Status.Conditions, orig.Status.Conditions) { logger.V(2).Info("updating service binding", "binding", binding.Name) - if _, err := c.consumerBindClient.KubeBindV1alpha1().APIServiceBindings().UpdateStatus(ctx, binding, metav1.UpdateOptions{}); err != nil { + if _, err := c.consumerBindClient.KubeBindV1alpha2().APIServiceBindings().UpdateStatus(ctx, binding, metav1.UpdateOptions{}); err != nil { logger.Error(err, "failed to update service binding", "binding", binding.Name) continue } diff --git a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go index bff3187a5..0fb1171ed 100644 --- a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go +++ b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go @@ -29,7 +29,7 @@ import ( "k8s.io/klog/v2" "github.com/kube-bind/kube-bind/pkg/version" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" ) @@ -46,7 +46,7 @@ type reconciler struct { createConsumerSecret func(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error) } -func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha2.ClusterBinding) error { var errs []error if err := r.ensureConsumerSecret(ctx, binding); err != nil { @@ -66,7 +66,7 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.Cl return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureHeartbeat(_ context.Context, binding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureHeartbeat(_ context.Context, binding *kubebindv1alpha2.ClusterBinding) error { binding.Status.HeartbeatInterval.Duration = r.heartbeatInterval if now := time.Now(); binding.Status.LastHeartbeatTime.IsZero() || now.After(binding.Status.LastHeartbeatTime.Add(r.heartbeatInterval/2)) { binding.Status.LastHeartbeatTime.Time = now @@ -75,7 +75,7 @@ func (r *reconciler) ensureHeartbeat(_ context.Context, binding *kubebindv1alpha return nil } -func (r *reconciler) ensureConsumerSecret(ctx context.Context, binding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureConsumerSecret(ctx context.Context, binding *kubebindv1alpha2.ClusterBinding) error { logger := klog.FromContext(ctx) providerSecret, err := r.getProviderSecret() @@ -84,7 +84,7 @@ func (r *reconciler) ensureConsumerSecret(ctx context.Context, binding *kubebind } else if errors.IsNotFound(err) { conditions.MarkFalse( binding, - kubebindv1alpha1.ClusterBindingConditionSecretValid, + kubebindv1alpha2.ClusterBindingConditionSecretValid, "ProviderSecretNotFound", conditionsapi.ConditionSeverityWarning, "Provider secret %s/%s not found", @@ -96,7 +96,7 @@ func (r *reconciler) ensureConsumerSecret(ctx context.Context, binding *kubebind if _, found := providerSecret.Data[binding.Spec.KubeconfigSecretRef.Key]; !found { conditions.MarkFalse( binding, - kubebindv1alpha1.ClusterBindingConditionSecretValid, + kubebindv1alpha2.ClusterBindingConditionSecretValid, "ProviderSecretInvalid", conditionsapi.ConditionSeverityWarning, "Provider secret %s/%s is missing %q string key.", @@ -143,13 +143,13 @@ func (r *reconciler) ensureConsumerSecret(ctx context.Context, binding *kubebind conditions.MarkTrue( binding, - kubebindv1alpha1.ClusterBindingConditionSecretValid, + kubebindv1alpha2.ClusterBindingConditionSecretValid, ) return nil } -func (r *reconciler) ensureKonnectorVersion(_ context.Context, binding *kubebindv1alpha1.ClusterBinding) error { +func (r *reconciler) ensureKonnectorVersion(_ context.Context, binding *kubebindv1alpha2.ClusterBinding) error { gitVersion := componentbaseversion.Get().GitVersion ver, err := version.BinaryVersion(gitVersion) if err != nil { @@ -157,7 +157,7 @@ func (r *reconciler) ensureKonnectorVersion(_ context.Context, binding *kubebind conditions.MarkFalse( binding, - kubebindv1alpha1.ClusterBindingConditionValidVersion, + kubebindv1alpha2.ClusterBindingConditionValidVersion, "ParseError", conditionsapi.ConditionSeverityWarning, "Konnector binary version string %q cannot be parsed: %v", @@ -171,7 +171,7 @@ func (r *reconciler) ensureKonnectorVersion(_ context.Context, binding *kubebind conditions.MarkTrue( binding, - kubebindv1alpha1.ClusterBindingConditionValidVersion, + kubebindv1alpha2.ClusterBindingConditionValidVersion, ) return nil diff --git a/pkg/konnector/controllers/cluster/namespacedeletion/namespacedeletion_controller.go b/pkg/konnector/controllers/cluster/namespacedeletion/namespacedeletion_controller.go index 94d89d0d7..3f0ffb6be 100644 --- a/pkg/konnector/controllers/cluster/namespacedeletion/namespacedeletion_controller.go +++ b/pkg/konnector/controllers/cluster/namespacedeletion/namespacedeletion_controller.go @@ -34,10 +34,10 @@ import ( "k8s.io/klog/v2" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -82,22 +82,22 @@ func NewController( getNamespace: namespaceInformer.Lister().Get, - getServiceNamespace: func(ns, name string) (*kubebindv1alpha1.APIServiceNamespace, error) { + getServiceNamespace: func(ns, name string) (*kubebindv1alpha2.APIServiceNamespace, error) { return serviceNamespaceInformer.Lister().APIServiceNamespaces(ns).Get(name) }, deleteServiceNamespace: func(ctx context.Context, ns, name string) error { - return bindClient.KubeBindV1alpha1().APIServiceNamespaces(ns).Delete(ctx, name, metav1.DeleteOptions{}) + return bindClient.KubeBindV1alpha2().APIServiceNamespaces(ns).Delete(ctx, name, metav1.DeleteOptions{}) }, } if _, err := serviceNamespaceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceNamespace(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, }); err != nil { @@ -123,11 +123,11 @@ type controller struct { serviceNamespaceIndexer cache.Indexer getNamespace func(name string) (*corev1.Namespace, error) - getServiceNamespace func(ns, name string) (*kubebindv1alpha1.APIServiceNamespace, error) + getServiceNamespace func(ns, name string) (*kubebindv1alpha2.APIServiceNamespace, error) deleteServiceNamespace func(ctx context.Context, ns, name string) error } -func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -138,7 +138,7 @@ func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj interface{} c.queue.Add(key) } -func (c *controller) enqueueNamespace(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueNamespace(logger klog.Logger, obj any) { nsKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -161,13 +161,13 @@ func (c *controller) Start(ctx context.Context, numThreads int) { defer logger.Info("Shutting down controller") c.namespaceInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueNamespace(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueNamespace(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueNamespace(logger, obj) }, }) diff --git a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_controller.go b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_controller.go index 5c917143f..f41d16c21 100644 --- a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_controller.go +++ b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_controller.go @@ -37,10 +37,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -50,7 +50,7 @@ const ( // NewController returns a new controller for ServiceBindings. func NewController( consumerSecretRefKey, providerNamespace string, - reconcileServiceBinding func(binding *kubebindv1alpha1.APIServiceBinding) bool, + reconcileServiceBinding func(binding *kubebindv1alpha2.APIServiceBinding) bool, consumerConfig, providerConfig *rest.Config, serviceBindingInformer dynamic.Informer[bindlisters.APIServiceBindingLister], serviceExportInformer bindinformers.APIServiceExportInformer, @@ -70,7 +70,7 @@ func NewController( if err != nil { return nil, err } - apiextensionsClient, err := apiextensionsclient.NewForConfig(consumerConfig) + consumerAPIExtensionsClient, err := apiextensionsclient.NewForConfig(consumerConfig) if err != nil { return nil, err } @@ -94,32 +94,38 @@ func NewController( providerNamespace: providerNamespace, reconcileServiceBinding: reconcileServiceBinding, - getServiceExport: func(name string) (*kubebindv1alpha1.APIServiceExport, error) { + getServiceExport: func(name string) (*kubebindv1alpha2.APIServiceExport, error) { return serviceExportInformer.Lister().APIServiceExports(providerNamespace).Get(name) }, - getServiceBinding: func(name string) (*kubebindv1alpha1.APIServiceBinding, error) { + getServiceBinding: func(name string) (*kubebindv1alpha2.APIServiceBinding, error) { return serviceBindingInformer.Lister().Get(name) }, - getClusterBinding: func(ctx context.Context) (*kubebindv1alpha1.ClusterBinding, error) { - return providerBindClient.KubeBindV1alpha1().ClusterBindings(providerNamespace).Get(ctx, "cluster", metav1.GetOptions{}) + getClusterBinding: func(ctx context.Context) (*kubebindv1alpha2.ClusterBinding, error) { + return providerBindClient.KubeBindV1alpha2().ClusterBindings(providerNamespace).Get(ctx, "cluster", metav1.GetOptions{}) }, - updateServiceExportStatus: func(ctx context.Context, export *kubebindv1alpha1.APIServiceExport) (*kubebindv1alpha1.APIServiceExport, error) { - return providerBindClient.KubeBindV1alpha1().APIServiceExports(providerNamespace).UpdateStatus(ctx, export, metav1.UpdateOptions{}) + getAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + return providerBindClient.KubeBindV1alpha2().APIResourceSchemas().Get(ctx, name, metav1.GetOptions{}) + }, + getBoundAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + return providerBindClient.KubeBindV1alpha2().BoundAPIResourceSchemas(providerNamespace).Get(ctx, name, metav1.GetOptions{}) + }, + updateServiceExportStatus: func(ctx context.Context, export *kubebindv1alpha2.APIServiceExport) (*kubebindv1alpha2.APIServiceExport, error) { + return providerBindClient.KubeBindV1alpha2().APIServiceExports(providerNamespace).UpdateStatus(ctx, export, metav1.UpdateOptions{}) }, getCRD: func(name string) (*apiextensionsv1.CustomResourceDefinition, error) { return crdInformer.Lister().Get(name) }, updateCRD: func(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) (*apiextensionsv1.CustomResourceDefinition, error) { - return apiextensionsClient.ApiextensionsV1().CustomResourceDefinitions().Update(ctx, crd, metav1.UpdateOptions{}) + return consumerAPIExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Update(ctx, crd, metav1.UpdateOptions{}) }, createCRD: func(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) (*apiextensionsv1.CustomResourceDefinition, error) { - return apiextensionsClient.ApiextensionsV1().CustomResourceDefinitions().Create(ctx, crd, metav1.CreateOptions{}) + return consumerAPIExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Create(ctx, crd, metav1.CreateOptions{}) }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceBinding, *kubebindv1alpha1.APIServiceBindingSpec, *kubebindv1alpha1.APIServiceBindingStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceBinding] { - return consumerBindClient.KubeBindV1alpha1().APIServiceBindings() + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceBinding, *kubebindv1alpha2.APIServiceBindingSpec, *kubebindv1alpha2.APIServiceBindingStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceBinding] { + return consumerBindClient.KubeBindV1alpha2().APIServiceBindings() }, ), } @@ -129,13 +135,13 @@ func NewController( }) if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -145,7 +151,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceBindingSpec, *kubebindv1alpha1.APIServiceBindingStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceBindingSpec, *kubebindv1alpha2.APIServiceBindingStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // controller reconciles ServiceBindings with there ServiceExports counterparts. @@ -164,7 +170,7 @@ type controller struct { commit CommitFunc } -func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceBinding(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -175,15 +181,15 @@ func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *controller) enqueueServiceExport(logger klog.Logger, _ interface{}) { - bindings, err := c.serviceBindingInformer.Informer().GetIndexer().ByIndex(indexers.ByServiceBindingKubeconfigSecret, c.consumerSecretRefKey) +func (c *controller) enqueueServiceExport(logger klog.Logger, _ any) { + bindings, err := c.serviceBindingInformer.Informer().GetIndexer().ByIndex(indexers.ByServiceBindingKubeconfigSecret, c.reconciler.consumerSecretRefKey) if err != nil { runtime.HandleError(err) return } for _, obj := range bindings { - binding := obj.(*kubebindv1alpha1.APIServiceBinding) + binding := obj.(*kubebindv1alpha2.APIServiceBinding) key, err := cache.MetaNamespaceKeyFunc(binding) if err != nil { runtime.HandleError(err) @@ -194,7 +200,7 @@ func (c *controller) enqueueServiceExport(logger klog.Logger, _ interface{}) { } } -func (c *controller) enqueueCRD(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueCRD(logger klog.Logger, obj any) { name, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -207,7 +213,7 @@ func (c *controller) enqueueCRD(logger klog.Logger, obj interface{}) { return } for _, obj := range exports { - export := obj.(*kubebindv1alpha1.APIServiceExport) + export := obj.(*kubebindv1alpha2.APIServiceExport) key := export.Name logger.V(2).Info("queueing APIServiceBinding", "key", key, "reason", "CustomResourceDefinition", "CustomResourceDefinitionKey", name) c.queue.Add(key) @@ -225,25 +231,25 @@ func (c *controller) Start(ctx context.Context, numThreads int) { defer logger.Info("Shutting down controller") c.serviceBindingInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceBinding(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, }) c.crdInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueCRD(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueCRD(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueCRD(logger, obj) }, }) diff --git a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go index 7bac0e788..5281003d7 100644 --- a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go +++ b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go @@ -18,6 +18,7 @@ package servicebinding import ( "context" + "fmt" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -25,8 +26,8 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/utils/ptr" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" - kubebindhelpers "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1/helpers" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + kubebindhelpers "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" ) @@ -34,19 +35,21 @@ import ( type reconciler struct { consumerSecretRefKey, providerNamespace string - reconcileServiceBinding func(binding *kubebindv1alpha1.APIServiceBinding) bool - getServiceExport func(ns string) (*kubebindv1alpha1.APIServiceExport, error) - getServiceBinding func(name string) (*kubebindv1alpha1.APIServiceBinding, error) - getClusterBinding func(ctx context.Context) (*kubebindv1alpha1.ClusterBinding, error) + reconcileServiceBinding func(binding *kubebindv1alpha2.APIServiceBinding) bool + getServiceExport func(name string) (*kubebindv1alpha2.APIServiceExport, error) + getServiceBinding func(name string) (*kubebindv1alpha2.APIServiceBinding, error) + getClusterBinding func(ctx context.Context) (*kubebindv1alpha2.ClusterBinding, error) + getAPIResourceSchema func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) + getBoundAPIResourceSchema func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) - updateServiceExportStatus func(ctx context.Context, export *kubebindv1alpha1.APIServiceExport) (*kubebindv1alpha1.APIServiceExport, error) + updateServiceExportStatus func(ctx context.Context, export *kubebindv1alpha2.APIServiceExport) (*kubebindv1alpha2.APIServiceExport, error) getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) updateCRD func(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) (*apiextensionsv1.CustomResourceDefinition, error) createCRD func(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) (*apiextensionsv1.CustomResourceDefinition, error) } -func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { var errs []error // As konnector is running APIServiceBinding controller for each provider cluster, @@ -72,13 +75,13 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureValidServiceExport(_ context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) ensureValidServiceExport(_ context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { if _, err := r.getServiceExport(binding.Name); err != nil && !errors.IsNotFound(err) { return err } else if errors.IsNotFound(err) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, + kubebindv1alpha2.APIServiceBindingConditionConnected, "APIServiceExportNotFound", conditionsapi.ConditionSeverityError, "APIServiceExport %s not found on the service provider cluster. Rerun kubectl bind for repair.", @@ -89,13 +92,13 @@ func (r *reconciler) ensureValidServiceExport(_ context.Context, binding *kubebi conditions.MarkTrue( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, + kubebindv1alpha2.APIServiceBindingConditionConnected, ) return nil } -func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { var errs []error export, err := r.getServiceExport(binding.Name) @@ -104,7 +107,7 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha1.A } else if errors.IsNotFound(err) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, + kubebindv1alpha2.APIServiceBindingConditionConnected, "APIServiceExportNotFound", conditionsapi.ConditionSeverityError, "APIServiceExport %s not found on the service provider cluster.", @@ -113,22 +116,94 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha1.A return nil // nothing we can do here } - crd, err := kubebindhelpers.ServiceExportToCRD(export) + // Get all APIResourceSchema objects referenced by the export + schemas, err := r.getAPIResourceSchemasFromExport(ctx, export) if err != nil { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, - "APIServiceExportInvalid", + kubebindv1alpha2.APIServiceBindingConditionConnected, + "APIResourceSchemaFetchFailed", conditionsapi.ConditionSeverityError, - "APIServiceExport %s on the service provider cluster is invalid: %s", + "Failed to fetch APIResourceSchema objects: %s", + err, + ) + // We dont have schema - try again. Might be a race on provider side. + return err + } + + // Process each schema + for _, schema := range schemas { + if err := r.referenceBoundAPIResourceSchema(ctx, binding, schema.Name); err != nil { + errs = append(errs, err) + } + + if err := r.ensureCRDsFromAPIResourceSchema(ctx, binding, schema); err != nil { + errs = append(errs, err) + } + } + + // If we processed all schemas without errors, mark the binding as connected + if len(errs) == 0 && !conditions.IsFalse(binding, kubebindv1alpha2.APIServiceBindingConditionConnected) { + conditions.MarkTrue(binding, kubebindv1alpha2.APIServiceBindingConditionConnected) + conditions.MarkTrue(binding, kubebindv1alpha2.APIServiceBindingConditionSchemaInSync) + } + + return utilerrors.NewAggregate(errs) +} + +func (r *reconciler) referenceBoundAPIResourceSchema(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding, name string) error { + boundSchema, err := r.getBoundAPIResourceSchema(ctx, name) + if err != nil && !errors.IsNotFound(err) { + return fmt.Errorf("failed to get BoundAPIResourceSchema %s: %w", name, err) + } + + if boundSchema == nil { + return nil + } + + group := boundSchema.Spec.APIResourceSchemaCRDSpec.Group + resource := boundSchema.Spec.APIResourceSchemaCRDSpec.Names.Plural + + if len(binding.Status.BoundSchemas) > 0 { + for _, ref := range binding.Status.BoundSchemas { + if ref.Group == group && ref.Resource == resource { + return nil + } + } + } + + if binding.Status.BoundSchemas == nil { + binding.Status.BoundSchemas = []kubebindv1alpha2.BoundSchemaReference{} + } + + binding.Status.BoundSchemas = append(binding.Status.BoundSchemas, + kubebindv1alpha2.BoundSchemaReference{ + GroupResource: kubebindv1alpha2.GroupResource{ + Group: group, + Resource: resource, + }, + }) + + return nil +} + +func (r *reconciler) ensureCRDsFromAPIResourceSchema(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding, schema *kubebindv1alpha2.APIResourceSchema) error { + var errs []error + crd, err := kubebindhelpers.APIResourceSchemaToCRD(schema) + if err != nil { + conditions.MarkFalse( + binding, + kubebindv1alpha2.APIServiceBindingConditionConnected, + "APIResourceSchemaInvalid", + conditionsapi.ConditionSeverityError, + "APIResourceSchema %s is invalid: %s", binding.Name, err, ) - return nil // nothing we can do here + return nil } - // put binding owner reference on the CRD. newReference := metav1.OwnerReference{ - APIVersion: kubebindv1alpha1.SchemeGroupVersion.String(), + APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), Kind: "APIServiceBinding", Name: binding.Name, UID: binding.UID, @@ -145,28 +220,25 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha1.A } else if errors.IsInvalid(err) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, + kubebindv1alpha2.APIServiceBindingConditionConnected, "CustomResourceDefinitionCreateFailed", conditionsapi.ConditionSeverityError, "CustomResourceDefinition %s cannot be created: %s", - binding.Name, err, + crd.Name, err, ) return nil } - conditions.MarkTrue(binding, kubebindv1alpha1.APIServiceBindingConditionConnected) - return nil // we wait for a new reconcile to update APIServiceExport status + return nil } - - // first check this really ours and we don't override something else if !kubebindhelpers.IsOwnedByBinding(binding.Name, binding.UID, existing.OwnerReferences) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, + kubebindv1alpha2.APIServiceBindingConditionConnected, "ForeignCustomResourceDefinition", conditionsapi.ConditionSeverityError, "CustomResourceDefinition %s is not owned by kube-bind.io.", - binding.Name, + crd.Name, ) return nil } @@ -177,7 +249,7 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha1.A } else if errors.IsInvalid(err) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionConnected, + kubebindv1alpha2.APIServiceBindingConditionConnected, "CustomResourceDefinitionUpdateFailed", conditionsapi.ConditionSeverityError, "CustomResourceDefinition %s cannot be updated: %s", @@ -186,12 +258,10 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *kubebindv1alpha1.A return nil } - conditions.MarkTrue(binding, kubebindv1alpha1.APIServiceBindingConditionConnected) - return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensurePrettyName(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) ensurePrettyName(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { clusterBinding, err := r.getClusterBinding(ctx) if err != nil && !errors.IsNotFound(err) { return err @@ -204,3 +274,24 @@ func (r *reconciler) ensurePrettyName(ctx context.Context, binding *kubebindv1al return nil } + +func (r *reconciler) getAPIResourceSchemasFromExport(ctx context.Context, export *kubebindv1alpha2.APIServiceExport) ([]*kubebindv1alpha2.APIResourceSchema, error) { + schemas := make([]*kubebindv1alpha2.APIResourceSchema, 0, len(export.Spec.Resources)) + + for _, ref := range export.Spec.Resources { + if ref.Type != "APIResourceSchema" { + return nil, fmt.Errorf("unsupported resource type %q in APIServiceExport %s", + ref.Type, export.Name) + } + + schema, err := r.getAPIResourceSchema(ctx, ref.Name) + if err != nil { + return nil, fmt.Errorf("failed to get APIResourceSchema %s: %w", + ref.Name, err) + } + + schemas = append(schemas, schema) + } + + return schemas, nil +} diff --git a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile_test.go b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile_test.go index 2ef2d46bc..aa5f41687 100644 --- a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile_test.go +++ b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" ) @@ -34,46 +34,78 @@ func TestEnsureCRDs(t *testing.T) { tests := []struct { name string bindingName string - getServiceExport func(name string) (*kubebindv1alpha1.APIServiceExport, error) getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) + boundSchema *kubebindv1alpha2.BoundAPIResourceSchema + schema *kubebindv1alpha2.APIResourceSchema + serviceExport *kubebindv1alpha2.APIServiceExport expectConditions conditionsapi.Conditions + wantErr bool }{ { - name: "create-when-crd-missing", - bindingName: "foo", - getCRD: newGetCRD("bar", newCRD("bar")), - getServiceExport: newGetServiceExport("foo", newServiceExport("foo")), + name: "create-when-crd-missing", + bindingName: "test-binding", + getCRD: func(name string) (*apiextensionsv1.CustomResourceDefinition, error) { + return nil, errors.NewNotFound(apiextensionsv1.SchemeGroupVersion.WithResource("customresourcedefinitions").GroupResource(), name) + }, + schema: newAPIResourceSchema("test-schema", "default", "example.com", "tests"), + boundSchema: newBoundAPIResourceSchema("test-schema", "default", "example.com", "tests"), + serviceExport: newServiceExportWithResources("test-binding", "default", []kubebindv1alpha2.APIResourceSchemaReference{ + {Name: "test-schema", Type: "APIResourceSchema"}, + }), expectConditions: conditionsapi.Conditions{ conditionsapi.Condition{Type: "Connected", Status: "True"}, + conditionsapi.Condition{Type: "SchemaInSync", Status: "True"}, }, }, { - name: "fail-when-external-crd-present", - bindingName: "foo", - getCRD: newGetCRD("foo", newCRD("foo")), - getServiceExport: newGetServiceExport("foo", newServiceExport("foo")), + name: "fail-when-external-crd-present", + bindingName: "test-binding", + getCRD: newGetCRD("tests.example.com", newCRD("tests.example.com")), + schema: newAPIResourceSchema("test-schema", "default", "example.com", "tests"), + boundSchema: newBoundAPIResourceSchema("test-schema", "default", "example.com", "tests"), + serviceExport: newServiceExportWithResources("test-binding", "default", []kubebindv1alpha2.APIResourceSchemaReference{ + {Name: "test-schema", Type: "APIResourceSchema"}, + }), expectConditions: conditionsapi.Conditions{ conditionsapi.Condition{ - Type: "Connected", Status: "False", + Type: "Connected", + Status: "False", Severity: "Error", Reason: "ForeignCustomResourceDefinition", - Message: "CustomResourceDefinition foo is not owned by kube-bind.io.", + Message: "CustomResourceDefinition tests.example.com is not owned by kube-bind.io.", }, }, }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { r := &reconciler{ getCRD: tt.getCRD, - getServiceExport: tt.getServiceExport, + getServiceExport: newGetServiceExport(tt.serviceExport.Name, tt.serviceExport), + getAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + if name == tt.schema.Name { + return tt.schema, nil + } + return nil, errors.NewNotFound(kubebindv1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas").GroupResource(), name) + }, + getBoundAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + if name == tt.schema.Name { + return tt.boundSchema, nil + } + return nil, errors.NewNotFound(kubebindv1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas").GroupResource(), name) + }, createCRD: func(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) (*apiextensionsv1.CustomResourceDefinition, error) { return crd.DeepCopy(), nil }, updateCRD: func(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) (*apiextensionsv1.CustomResourceDefinition, error) { return crd.DeepCopy(), nil }, + reconcileServiceBinding: func(binding *kubebindv1alpha2.APIServiceBinding) bool { + return true + }, } + b := newBinding(tt.bindingName) err := r.ensureCRDs(context.Background(), b) require.NoError(t, err) @@ -85,6 +117,51 @@ func TestEnsureCRDs(t *testing.T) { }) } } +func newBoundAPIResourceSchema(name, namespace string, group, plural string) *kubebindv1alpha2.BoundAPIResourceSchema { + return &kubebindv1alpha2.BoundAPIResourceSchema{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: kubebindv1alpha2.BoundAPIResourceSchemaSpec{ + APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{ + Group: group, + Names: apiextensionsv1.CustomResourceDefinitionNames{ + Plural: plural, + }, + }, + }, + } +} + +func newAPIResourceSchema(name, namespace, group, plural string) *kubebindv1alpha2.APIResourceSchema { + return &kubebindv1alpha2.APIResourceSchema{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: kubebindv1alpha2.APIResourceSchemaSpec{ + APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{ + Group: group, + Names: apiextensionsv1.CustomResourceDefinitionNames{ + Plural: plural, + }, + }, + }, + } +} + +func newServiceExportWithResources(name, namespace string, resources []kubebindv1alpha2.APIResourceSchemaReference) *kubebindv1alpha2.APIServiceExport { + return &kubebindv1alpha2.APIServiceExport{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: kubebindv1alpha2.APIServiceExportSpec{ + Resources: resources, + }, + } +} func newGetCRD(name string, crd *apiextensionsv1.CustomResourceDefinition) func(name string) (*apiextensionsv1.CustomResourceDefinition, error) { return func(n string) (*apiextensionsv1.CustomResourceDefinition, error) { @@ -103,26 +180,17 @@ func newCRD(name string) *apiextensionsv1.CustomResourceDefinition { } } -func newGetServiceExport(name string, crd *kubebindv1alpha1.APIServiceExport) func(name string) (*kubebindv1alpha1.APIServiceExport, error) { - return func(n string) (*kubebindv1alpha1.APIServiceExport, error) { +func newGetServiceExport(name string, crd *kubebindv1alpha2.APIServiceExport) func(name string) (*kubebindv1alpha2.APIServiceExport, error) { + return func(n string) (*kubebindv1alpha2.APIServiceExport, error) { if n == name { return crd, nil } - return nil, errors.NewNotFound(kubebindv1alpha1.SchemeGroupVersion.WithResource("apiserviceexports").GroupResource(), "not found") - } -} - -func newServiceExport(name string) *kubebindv1alpha1.APIServiceExport { - return &kubebindv1alpha1.APIServiceExport{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - }, - Spec: kubebindv1alpha1.APIServiceExportSpec{}, + return nil, errors.NewNotFound(kubebindv1alpha2.SchemeGroupVersion.WithResource("apiserviceexports").GroupResource(), "not found") } } -func newBinding(name string) *kubebindv1alpha1.APIServiceBinding { - return &kubebindv1alpha1.APIServiceBinding{ +func newBinding(name string) *kubebindv1alpha2.APIServiceBinding { + return &kubebindv1alpha2.APIServiceBinding{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, diff --git a/pkg/konnector/controllers/cluster/serviceexport/multinsinformer/informer.go b/pkg/konnector/controllers/cluster/serviceexport/multinsinformer/informer.go index 08c772e41..3a2d92d6a 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/multinsinformer/informer.go +++ b/pkg/konnector/controllers/cluster/serviceexport/multinsinformer/informer.go @@ -37,8 +37,8 @@ import ( "github.com/kube-bind/kube-bind/pkg/indexers" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -109,13 +109,13 @@ func (inf *DynamicMultiNamespaceInformer) Start(ctx context.Context) { defer logger.Info("Shutting down controller") inf.serviceNamespaceInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { inf.enqueueServiceNamespace(obj) }, - UpdateFunc: func(oldObj, newObj interface{}) { + UpdateFunc: func(oldObj, newObj any) { inf.enqueueServiceNamespace(newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { inf.enqueueServiceNamespace(obj) }, }) @@ -131,7 +131,7 @@ func (inf *DynamicMultiNamespaceInformer) Start(ctx context.Context) { }() } -func (inf *DynamicMultiNamespaceInformer) enqueueServiceNamespace(obj interface{}) { +func (inf *DynamicMultiNamespaceInformer) enqueueServiceNamespace(obj any) { logger := klog.FromContext(context.Background()).WithValues("controller", controllerName, "gvr", inf.gvr) key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) @@ -221,7 +221,7 @@ func (inf *DynamicMultiNamespaceInformer) Get(ns, name string) (runtime.Object, } else if len(snss) > 1 { return nil, fmt.Errorf("unexpected multiple APIServiceNamespaces for namespace %s", ns) } - sns := snss[0].(*kubebindv1alpha1.APIServiceNamespace) + sns := snss[0].(*kubebindv1alpha2.APIServiceNamespace) inf.lock.RLock() defer inf.lock.RUnlock() @@ -242,7 +242,7 @@ func (inf *DynamicMultiNamespaceInformer) List(ns string) ([]runtime.Object, err } else if len(snss) > 1 { return nil, fmt.Errorf("unexpected multiple APIServiceNamespaces for namespace %s", ns) } - sns := snss[0].(*kubebindv1alpha1.APIServiceNamespace) + sns := snss[0].(*kubebindv1alpha2.APIServiceNamespace) inf.lock.RLock() defer inf.lock.RUnlock() diff --git a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_controller.go b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_controller.go index b8f261fc1..75cb35632 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_controller.go +++ b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_controller.go @@ -24,6 +24,7 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionslisters "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" @@ -35,10 +36,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -98,14 +99,26 @@ func NewController( getCRD: func(name string) (*apiextensionsv1.CustomResourceDefinition, error) { return crdInformer.Lister().Get(name) }, - getServiceBinding: func(name string) (*kubebindv1alpha1.APIServiceBinding, error) { + getServiceBinding: func(name string) (*kubebindv1alpha2.APIServiceBinding, error) { return serviceBindingInformer.Lister().Get(name) }, + getAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + return providerBindClient.KubeBindV1alpha2().APIResourceSchemas().Get(ctx, name, metav1.GetOptions{}) + }, + getBoundAPIResourceSchema: func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + return providerBindClient.KubeBindV1alpha2().BoundAPIResourceSchemas(providerNamespace).Get(ctx, name, metav1.GetOptions{}) + }, + createBoundAPIResourceSchema: func(ctx context.Context, boundSchema *kubebindv1alpha2.BoundAPIResourceSchema) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + return providerBindClient.KubeBindV1alpha2().BoundAPIResourceSchemas(providerNamespace).Create(ctx, boundSchema, metav1.CreateOptions{}) + }, + updateBoundAPIResourceSchema: func(ctx context.Context, boundSchema *kubebindv1alpha2.BoundAPIResourceSchema) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + return providerBindClient.KubeBindV1alpha2().BoundAPIResourceSchemas(providerNamespace).Update(ctx, boundSchema, metav1.UpdateOptions{}) + }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceExport, *kubebindv1alpha1.APIServiceExportSpec, *kubebindv1alpha1.APIServiceExportStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceExport] { - return providerBindClient.KubeBindV1alpha1().APIServiceExports(ns) + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceExport, *kubebindv1alpha2.APIServiceExportSpec, *kubebindv1alpha2.APIServiceExportStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceExport] { + return providerBindClient.KubeBindV1alpha2().APIServiceExports(ns) }, ), } @@ -115,13 +128,13 @@ func NewController( }) if _, err := serviceExportInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceExport(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceExport(logger, obj) }, }); err != nil { @@ -131,7 +144,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceExportSpec, *kubebindv1alpha1.APIServiceExportStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceExportSpec, *kubebindv1alpha2.APIServiceExportStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // controller reconciles ServiceExportResources and starts and stop syncers. @@ -152,7 +165,7 @@ type controller struct { commit CommitFunc } -func (c *controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceExport(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -163,8 +176,8 @@ func (c *controller) enqueueServiceExport(logger klog.Logger, obj interface{}) { c.queue.Add(key) } -func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) { - binding, ok := obj.(*kubebindv1alpha1.APIServiceBinding) +func (c *controller) enqueueServiceBinding(logger klog.Logger, obj any) { + binding, ok := obj.(*kubebindv1alpha2.APIServiceBinding) if !ok { runtime.HandleError(fmt.Errorf("unexpected type %T", obj)) return @@ -175,7 +188,7 @@ func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *controller) enqueueCRD(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueCRD(logger klog.Logger, obj any) { crdKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -198,25 +211,25 @@ func (c *controller) Start(ctx context.Context, numThreads int) { defer logger.Info("Shutting down controller") c.serviceBindingInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceBinding(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, }) c.crdInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueCRD(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueCRD(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueCRD(logger, obj) }, }) diff --git a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go index f963b05cc..a625490f7 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go +++ b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile.go @@ -18,6 +18,9 @@ package serviceexport import ( "context" + "fmt" + "reflect" + "strings" "sync" "time" @@ -37,10 +40,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/spec" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/status" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) type reconciler struct { @@ -54,8 +57,12 @@ type reconciler struct { lock sync.Mutex syncContext map[string]syncContext // by CRD name - getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) - getServiceBinding func(name string) (*kubebindv1alpha1.APIServiceBinding, error) + getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) + getServiceBinding func(name string) (*kubebindv1alpha2.APIServiceBinding, error) + getAPIResourceSchema func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) + getBoundAPIResourceSchema func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) + createBoundAPIResourceSchema func(ctx context.Context, boundSchema *kubebindv1alpha2.BoundAPIResourceSchema) (*kubebindv1alpha2.BoundAPIResourceSchema, error) + updateBoundAPIResourceSchema func(ctx context.Context, boundSchema *kubebindv1alpha2.BoundAPIResourceSchema) (*kubebindv1alpha2.BoundAPIResourceSchema, error) } type syncContext struct { @@ -63,7 +70,7 @@ type syncContext struct { cancel func() } -func (r *reconciler) reconcile(ctx context.Context, name string, export *kubebindv1alpha1.APIServiceExport) error { +func (r *reconciler) reconcile(ctx context.Context, name string, export *kubebindv1alpha2.APIServiceExport) error { errs := []error{} if err := r.ensureControllers(ctx, name, export); err != nil { @@ -74,7 +81,7 @@ func (r *reconciler) reconcile(ctx context.Context, name string, export *kubebin if err := r.ensureServiceBindingConditionCopied(ctx, export); err != nil { errs = append(errs, err) } - if err := r.ensureCRDConditionsCopied(ctx, export); err != nil { + if err := r.ensureCRDConditionsCopiedToBoundSchema(ctx, export); err != nil { errs = append(errs, err) } } @@ -82,35 +89,22 @@ func (r *reconciler) reconcile(ctx context.Context, name string, export *kubebin return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureControllers(ctx context.Context, name string, export *kubebindv1alpha1.APIServiceExport) error { +func (r *reconciler) ensureControllers(ctx context.Context, name string, export *kubebindv1alpha2.APIServiceExport) error { logger := klog.FromContext(ctx) if export == nil { // stop dangling syncers on delete r.lock.Lock() defer r.lock.Unlock() - if c, found := r.syncContext[name]; found { - logger.V(1).Info("Stopping APIServiceExport sync", "reason", "APIServiceExport deleted") - c.cancel() - delete(r.syncContext, name) - } - return nil - } - var errs []error - crd, err := r.getCRD(export.Name) - if err != nil && !errors.IsNotFound(err) { - return err - } else if errors.IsNotFound(err) { - // stop it - r.lock.Lock() - defer r.lock.Unlock() - if c, found := r.syncContext[export.Name]; found { - logger.V(1).Info("Stopping APIServiceExport sync", "reason", "NoCustomResourceDefinition") - c.cancel() - delete(r.syncContext, export.Name) + // Clean up any controllers associated with this export + for key, c := range r.syncContext { + if strings.HasSuffix(key, "."+name) { + logger.V(1).Info("Stopping APIServiceExport sync", "key", key, "reason", "APIServiceExport deleted") + c.cancel() + delete(r.syncContext, key) + } } - return nil } @@ -120,44 +114,174 @@ func (r *reconciler) ensureControllers(ctx context.Context, name string, export return err } if binding == nil { - // stop it + // Stop all controllers for this export r.lock.Lock() defer r.lock.Unlock() - if c, found := r.syncContext[export.Name]; found { - logger.V(1).Info("Stopping APIServiceExport sync", "reason", "NoAPIServiceBinding") - c.cancel() - delete(r.syncContext, export.Name) + for key, c := range r.syncContext { + if strings.HasSuffix(key, "."+export.Name) { + logger.V(1).Info("Stopping APIServiceExport sync", "key", key, "reason", "NoAPIServiceBinding") + c.cancel() + delete(r.syncContext, key) + } } - return nil } + // Process each resource referenced by the export + var errs []error + processedSchemas := make(map[string]bool) + + for _, resourceRef := range export.Spec.Resources { + if resourceRef.Type != "APIResourceSchema" { + logger.V(1).Info("Skipping unsupported resource type", "type", resourceRef.Type) + continue + } + + // Fetch the APIResourceSchema + schema, err := r.getAPIResourceSchema(ctx, resourceRef.Name) + if err != nil { + if errors.IsNotFound(err) { + // Stop the controller for this schema if it exists + r.lock.Lock() + key := resourceRef.Name + "." + export.Name + if c, found := r.syncContext[key]; found { + logger.V(1).Info("Stopping APIServiceExport resource sync", "key", key, "reason", "APIResourceSchema not found") + c.cancel() + delete(r.syncContext, key) + } + r.lock.Unlock() + continue + } + errs = append(errs, err) + continue + } + + // Ensure BoundAPIResourceSchema exists for tracking status + if err := r.ensureBoundAPIResourceSchema(ctx, export, schema); err != nil { + errs = append(errs, err) + continue + } + + // Start/update controller for this schema + if err := r.ensureControllerForSchema(ctx, export, schema); err != nil { + errs = append(errs, err) + } + + processedSchemas[resourceRef.Name] = true + } + + // Stop controllers for schemas that are no longer referenced r.lock.Lock() - c, found := r.syncContext[export.Name] + for key, c := range r.syncContext { + parts := strings.Split(key, ".") + if len(parts) == 2 && parts[1] == export.Name { + schemaName := parts[0] + if !processedSchemas[schemaName] { + logger.V(1).Info("Stopping APIServiceExport resource sync", "key", key, "reason", "Schema no longer referenced") + c.cancel() + delete(r.syncContext, key) + } + } + } + r.lock.Unlock() + + return utilerrors.NewAggregate(errs) +} + +func (r *reconciler) ensureBoundAPIResourceSchema(ctx context.Context, export *kubebindv1alpha2.APIServiceExport, schema *kubebindv1alpha2.APIResourceSchema) error { + boundSchema, err := r.getBoundAPIResourceSchema(ctx, schema.Name) + if err != nil { + if errors.IsNotFound(err) { + // Create new BoundAPIResourceSchema + boundSchema = &kubebindv1alpha2.BoundAPIResourceSchema{ + ObjectMeta: metav1.ObjectMeta{ + Name: schema.Name, + Namespace: export.Namespace, + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), + Kind: "APIServiceExport", + Name: export.Name, + UID: export.UID, + Controller: func() *bool { b := true; return &b }(), + }, + }, + }, + Spec: kubebindv1alpha2.BoundAPIResourceSchemaSpec{ + InformerScope: schema.Spec.InformerScope, + APIResourceSchemaCRDSpec: schema.Spec.APIResourceSchemaCRDSpec, + }, + } + + conditions.MarkFalse( + boundSchema, + kubebindv1alpha2.BoundAPIResourceSchemaValid, + string(kubebindv1alpha2.BoundAPIResourceSchemaPending), + conditionsapi.ConditionSeverityInfo, + "Waiting for CRD to be created in consumer cluster", + ) + + _, err := r.createBoundAPIResourceSchema(ctx, boundSchema) + if err != nil { + return fmt.Errorf("failed to create BoundAPIResourceSchema %s: %w", boundSchema.Name, err) + } + return nil + } + return err + } + + // Check if InformerScope needs updating + if boundSchema.Spec.InformerScope != schema.Spec.InformerScope { + boundSchema.Spec.InformerScope = schema.Spec.InformerScope + } + + if !reflect.DeepEqual(boundSchema.Spec.APIResourceSchemaCRDSpec, schema.Spec.APIResourceSchemaCRDSpec) { + boundSchema.Spec.APIResourceSchemaCRDSpec = schema.Spec.APIResourceSchemaCRDSpec + } + + _, err = r.updateBoundAPIResourceSchema(ctx, boundSchema) + if err != nil { + return fmt.Errorf("failed to update BoundAPIResourceSchema %s: %w", boundSchema.Name, err) + } + + return nil +} + +func (r *reconciler) ensureControllerForSchema(ctx context.Context, export *kubebindv1alpha2.APIServiceExport, schema *kubebindv1alpha2.APIResourceSchema) error { + logger := klog.FromContext(ctx) + key := schema.Name + "." + export.Name + + r.lock.Lock() + c, found := r.syncContext[key] if found { if c.generation == export.Generation { r.lock.Unlock() return nil // all as expected } - // technically, we could be less aggressive here if nothing big changed in the resource, e.g. just schemas. But ¯\_(ツ)_/¯ - - logger.V(1).Info("Stopping APIServiceExport sync", "reason", "GenerationChanged", "generation", export.Generation) + logger.V(1).Info("Stopping APIServiceExport resource sync", "key", key, "reason", "GenerationChanged", "generation", schema.Generation) c.cancel() - delete(r.syncContext, export.Name) + delete(r.syncContext, key) } r.lock.Unlock() // start a new syncer - var syncVersion string - for _, v := range export.Spec.Versions { + for _, v := range schema.Spec.Versions { if v.Served { syncVersion = v.Name break } } - gvr := runtimeschema.GroupVersionResource{Group: export.Spec.Group, Version: syncVersion, Resource: export.Spec.Names.Plural} + if syncVersion == "" { + return fmt.Errorf("no served version found for APIResourceSchema %s", schema.Name) + } + + gvr := runtimeschema.GroupVersionResource{ + Group: schema.Spec.Group, + Version: syncVersion, + Resource: schema.Spec.Names.Plural, + } dynamicConsumerClient := dynamicclient.NewForConfigOrDie(r.consumerConfig) dynamicProviderClient := dynamicclient.NewForConfigOrDie(r.providerConfig) @@ -176,7 +300,7 @@ func (r *reconciler) ensureControllers(ctx context.Context, name string, export consumerInf := dynamicinformer.NewDynamicSharedInformerFactory(dynamicConsumerClient, time.Minute*30) var providerInf multinsinformer.GetterInformer - if crd.Spec.Scope == apiextensionsv1.ClusterScoped || export.Spec.InformerScope == kubebindv1alpha1.ClusterScope { + if schema.Spec.Scope == apiextensionsv1.ClusterScoped || schema.Spec.InformerScope == kubebindv1alpha2.ClusterScope { factory := dynamicinformer.NewDynamicSharedInformerFactory(dynamicProviderClient, time.Minute*30) factory.ForResource(gvr).Lister() // wire the GVR up in the informer factory providerInf = multinsinformer.GetterInformerWrapper{ @@ -184,6 +308,7 @@ func (r *reconciler) ensureControllers(ctx context.Context, name string, export Delegate: factory, } } else { + var err error providerInf, err = multinsinformer.NewDynamicMultiNamespaceInformer( gvr, r.providerNamespace, @@ -209,6 +334,7 @@ func (r *reconciler) ensureControllers(ctx context.Context, name string, export runtime.HandleError(err) return nil // nothing we can do here } + statusCtrl, err := status.NewController( gvr, r.providerNamespace, @@ -224,44 +350,138 @@ func (r *reconciler) ensureControllers(ctx context.Context, name string, export return nil // nothing we can do here } - ctx, cancel := context.WithCancel(ctx) + // Create a new context for this controller + ctxWithCancel, cancel := context.WithCancel(ctx) - consumerInf.Start(ctx.Done()) - providerInf.Start(ctx) + consumerInf.Start(ctxWithCancel.Done()) + providerInf.Start(ctxWithCancel) go func() { // to not block the main thread - consumerSynced := consumerInf.WaitForCacheSync(ctx.Done()) - logger.V(2).Info("Synced informers", "consumer", consumerSynced) + consumerSynced := consumerInf.WaitForCacheSync(ctxWithCancel.Done()) + logger.V(2).Info("Synced informers", "key", key, "consumer", consumerSynced) - providerSynced := providerInf.WaitForCacheSync(ctx.Done()) - logger.V(2).Info("Synced informers", "provider", providerSynced) + providerSynced := providerInf.WaitForCacheSync(ctxWithCancel.Done()) + logger.V(2).Info("Synced informers", "key", key, "provider", providerSynced) - go specCtrl.Start(ctx, 1) - go statusCtrl.Start(ctx, 1) + go specCtrl.Start(ctxWithCancel, 1) + go statusCtrl.Start(ctxWithCancel, 1) }() r.lock.Lock() defer r.lock.Unlock() - if c, found := r.syncContext[export.Name]; found { + if c, found := r.syncContext[key]; found { c.cancel() } - r.syncContext[export.Name] = syncContext{ - generation: export.Generation, + r.syncContext[key] = syncContext{ + generation: schema.Generation, cancel: cancel, } + return nil +} + +func (r *reconciler) ensureCRDConditionsCopiedToBoundSchema(ctx context.Context, export *kubebindv1alpha2.APIServiceExport) error { + if export == nil { + return nil + } + var errs []error + allValid := true // assume all BoundAPIResourceSchemas are valid + for _, resourceRef := range export.Spec.Resources { + schema, err := r.getAPIResourceSchema(ctx, resourceRef.Name) + if err != nil { + if errors.IsNotFound(err) { + continue + } + errs = append(errs, err) + continue + } + + crd, err := r.getCRD(schema.Name) + if err != nil { + if errors.IsNotFound(err) { + continue + } + errs = append(errs, err) + continue + } + + boundSchema, err := r.getBoundAPIResourceSchema(ctx, schema.Name) + if err != nil { + if errors.IsNotFound(err) { + continue // BoundAPIResourceSchema not found, nothing to update + } + errs = append(errs, err) + continue + } + + boundSchemaIndex := map[conditionsapi.ConditionType]int{} + for i, c := range boundSchema.Status.Conditions { + boundSchemaIndex[c.Type] = i + } + for _, c := range crd.Status.Conditions { + if conditionsapi.ConditionType(c.Type) == conditionsapi.ReadyCondition { + continue + } + + severity := conditionsapi.ConditionSeverityError + if c.Status == apiextensionsv1.ConditionTrue { + severity = conditionsapi.ConditionSeverityNone + } + copied := conditionsapi.Condition{ + Type: conditionsapi.ConditionType(c.Type), + Status: corev1.ConditionStatus(c.Status), + Severity: severity, // CRD conditions have no severity + LastTransitionTime: c.LastTransitionTime, + Reason: c.Reason, + Message: c.Message, + } + + // update or append + if i, found := boundSchemaIndex[conditionsapi.ConditionType(c.Type)]; found { + boundSchema.Status.Conditions[i] = copied + } else { + boundSchema.Status.Conditions = append(boundSchema.Status.Conditions, copied) + } + } + conditions.SetSummary(boundSchema) + + boundSchema.Status.AcceptedNames = crd.Status.AcceptedNames + boundSchema.Status.StoredVersions = crd.Status.StoredVersions + + if _, err := r.updateBoundAPIResourceSchema(ctx, boundSchema); err != nil { + errs = append(errs, err) + allValid = false // at least one BoundAPIResourceSchema is not valid + } + } + + // Set APIServiceExport Ready condition based on all BoundAPIResourceSchemas + if allValid { + conditions.MarkTrue( + export, + kubebindv1alpha2.APIServiceExportConditionConnected, + ) + } else { + conditions.MarkFalse( + export, + kubebindv1alpha2.APIServiceExportConditionConnected, + "BoundAPIResourceSchemasNotValid", + conditionsapi.ConditionSeverityWarning, + "One or more BoundAPIResourceSchemas are not valid", + ) + } + return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureServiceBindingConditionCopied(_ context.Context, export *kubebindv1alpha1.APIServiceExport) error { +func (r *reconciler) ensureServiceBindingConditionCopied(_ context.Context, export *kubebindv1alpha2.APIServiceExport) error { binding, err := r.getServiceBinding(export.Name) if err != nil && !errors.IsNotFound(err) { return err } else if errors.IsNotFound(err) { conditions.MarkFalse( export, - kubebindv1alpha1.APIServiceExportConditionConnected, + kubebindv1alpha2.APIServiceExportConditionConnected, "APIServiceBindingNotFound", conditionsapi.ConditionSeverityInfo, "No APIServiceBinding exists.", @@ -269,7 +489,7 @@ func (r *reconciler) ensureServiceBindingConditionCopied(_ context.Context, expo conditions.MarkFalse( export, - kubebindv1alpha1.APIServiceExportConditionConsumerInSync, + kubebindv1alpha2.APIServiceExportConditionConsumerInSync, "NA", conditionsapi.ConditionSeverityInfo, "No APIServiceBinding exists.", @@ -278,16 +498,16 @@ func (r *reconciler) ensureServiceBindingConditionCopied(_ context.Context, expo return nil } - conditions.MarkTrue(export, kubebindv1alpha1.APIServiceExportConditionConnected) + conditions.MarkTrue(export, kubebindv1alpha2.APIServiceExportConditionConnected) - if inSync := conditions.Get(binding, kubebindv1alpha1.APIServiceBindingConditionSchemaInSync); inSync != nil { + if inSync := conditions.Get(binding, kubebindv1alpha2.APIServiceBindingConditionSchemaInSync); inSync != nil { inSync := inSync.DeepCopy() - inSync.Type = kubebindv1alpha1.APIServiceExportConditionConsumerInSync + inSync.Type = kubebindv1alpha2.APIServiceExportConditionConsumerInSync conditions.Set(export, inSync) } else { conditions.MarkFalse( export, - kubebindv1alpha1.APIServiceExportConditionConsumerInSync, + kubebindv1alpha2.APIServiceExportConditionConsumerInSync, "Unknown", conditionsapi.ConditionSeverityInfo, "APIServiceBinding %s in the consumer cluster does not have a SchemaInSync condition.", @@ -297,48 +517,3 @@ func (r *reconciler) ensureServiceBindingConditionCopied(_ context.Context, expo return nil } - -func (r *reconciler) ensureCRDConditionsCopied(_ context.Context, export *kubebindv1alpha1.APIServiceExport) error { - crd, err := r.getCRD(export.Name) - if err != nil && !errors.IsNotFound(err) { - return err - } else if errors.IsNotFound(err) { - return nil // nothing to copy - } - - exportIndex := map[conditionsapi.ConditionType]int{} - for i, c := range export.Status.Conditions { - exportIndex[c.Type] = i - } - for _, c := range crd.Status.Conditions { - if conditionsapi.ConditionType(c.Type) == conditionsapi.ReadyCondition { - continue - } - - severity := conditionsapi.ConditionSeverityError - if c.Status == apiextensionsv1.ConditionTrue { - severity = conditionsapi.ConditionSeverityNone - } - copied := conditionsapi.Condition{ - Type: conditionsapi.ConditionType(c.Type), - Status: corev1.ConditionStatus(c.Status), - Severity: severity, // CRD conditions have no severity - LastTransitionTime: c.LastTransitionTime, - Reason: c.Reason, - Message: c.Message, - } - - // update or append - if i, found := exportIndex[conditionsapi.ConditionType(c.Type)]; found { - export.Status.Conditions[i] = copied - } else { - export.Status.Conditions = append(export.Status.Conditions, copied) - } - } - conditions.SetSummary(export) - - export.Status.AcceptedNames = crd.Status.AcceptedNames - export.Status.StoredVersions = crd.Status.StoredVersions - - return nil -} diff --git a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile_test.go b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile_test.go index e073772bd..f38f3a8a5 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile_test.go +++ b/pkg/konnector/controllers/cluster/serviceexport/serviceexport_reconcile_test.go @@ -27,50 +27,68 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" ) -func TestEnsureCRDConditionsCopied(t *testing.T) { +func TestEnsureCRDConditionsCopiedToBoundSchema(t *testing.T) { tests := []struct { - name string - getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) - export *kubebindv1alpha1.APIServiceExport - expected *kubebindv1alpha1.APIServiceExport - wantErr bool + name string + getCRD func(name string) (*apiextensionsv1.CustomResourceDefinition, error) + schema *kubebindv1alpha2.APIResourceSchema + boundSchema *kubebindv1alpha2.BoundAPIResourceSchema + export *kubebindv1alpha2.APIServiceExport + expected *kubebindv1alpha2.BoundAPIResourceSchema + wantErr bool }{ { name: "merging", - getCRD: newGetCRD("foo", newCRD("foo", []apiextensionsv1.CustomResourceDefinitionCondition{ + getCRD: newGetCRD("foo-schema", newCRD("foo-schema", []apiextensionsv1.CustomResourceDefinitionCondition{ {Type: "Something", Status: "True", Reason: "Reason", Message: "message"}, {Type: "Established", Status: "True", Reason: "Reason", Message: "message"}, })), - export: newExport("foo", []conditionsapi.Condition{ + schema: newAPIResourceSchema("foo-schema", "default", "example.com", "foos"), + boundSchema: newBoundAPIResourceSchema("foo-schema", []conditionsapi.Condition{ {Type: "Ready", Status: "False", Severity: "Warning", Reason: "SomethingElseWrong", Message: "something else went wrong"}, {Type: "Established", Status: "True", Severity: "None", Reason: "Reason", Message: "message"}, {Type: "Structural", Status: "False", Severity: "Warning", Reason: "SomethingWrong", Message: "something went wrong"}, }), - expected: newExport("foo", []conditionsapi.Condition{ + export: newExportWithResources("test-export", "default", []kubebindv1alpha2.APIResourceSchemaReference{ + {Name: "foo-schema", Type: "APIResourceSchema"}, + }), + expected: newBoundAPIResourceSchema("foo-schema", []conditionsapi.Condition{ {Type: "Ready", Status: "False", Severity: "Warning", Reason: "SomethingWrong", Message: "something went wrong"}, {Type: "Established", Status: "True", Severity: "", Reason: "Reason", Message: "message"}, - {Type: "Something", Status: "True", Reason: "Reason", Message: "message"}, + {Type: "Something", Status: "True", Severity: "", Reason: "Reason", Message: "message"}, {Type: "Structural", Status: "False", Severity: "Warning", Reason: "SomethingWrong", Message: "something went wrong"}, }), }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + // Track updated schema + var updatedSchema *kubebindv1alpha2.BoundAPIResourceSchema + ctx := context.Background() r := &reconciler{ - getCRD: tt.getCRD, + getCRD: tt.getCRD, + getAPIResourceSchema: newGetAPIResourceSchema(ctx, tt.schema), + getBoundAPIResourceSchema: newGetBoundAPIResourceSchema(ctx, tt.boundSchema), + updateBoundAPIResourceSchema: newUpdateBoundAPIResourceSchema(&updatedSchema), } - export := tt.export.DeepCopy() - if err := r.ensureCRDConditionsCopied(context.Background(), export); (err != nil) != tt.wantErr { - t.Errorf("ensureCRDConditionsCopied() error = %v, wantErr %v", err, tt.wantErr) - } else if err == nil { - for i := range export.Status.Conditions { - export.Status.Conditions[i].LastTransitionTime = metav1.Time{} // this is hard to compare + + if err := r.ensureCRDConditionsCopiedToBoundSchema(context.Background(), tt.export); (err != nil) != tt.wantErr { + t.Errorf("ensureCRDConditionsCopiedToBoundSchema() error = %v, wantErr %v", err, tt.wantErr) + } else if err == nil && updatedSchema != nil { + for i := range updatedSchema.Status.Conditions { + updatedSchema.Status.Conditions[i].LastTransitionTime = metav1.Time{} } - require.Equal(t, tt.expected, export, cmp.Diff(tt.expected, export)) + for i := range tt.expected.Status.Conditions { + tt.expected.Status.Conditions[i].LastTransitionTime = metav1.Time{} + } + + require.Equal(t, tt.expected.Status.Conditions, updatedSchema.Status.Conditions, + cmp.Diff(tt.expected.Status.Conditions, updatedSchema.Status.Conditions)) } }) } @@ -96,12 +114,66 @@ func newCRD(name string, conditions []apiextensionsv1.CustomResourceDefinitionCo } } -func newExport(name string, conditions []conditionsapi.Condition) *kubebindv1alpha1.APIServiceExport { - return &kubebindv1alpha1.APIServiceExport{ +func newAPIResourceSchema(name, namespace, group, plural string) *kubebindv1alpha2.APIResourceSchema { + return &kubebindv1alpha2.APIResourceSchema{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: kubebindv1alpha2.APIResourceSchemaSpec{ + APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{ + Group: group, + Names: apiextensionsv1.CustomResourceDefinitionNames{ + Plural: plural, + }, + }, + }, + } +} + +func newGetAPIResourceSchema(_ context.Context, schema *kubebindv1alpha2.APIResourceSchema) func(ctx context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + return func(_ context.Context, name string) (*kubebindv1alpha2.APIResourceSchema, error) { + if name == schema.Name { + return schema, nil + } + return nil, errors.NewNotFound(kubebindv1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas").GroupResource(), name) + } +} + +func newGetBoundAPIResourceSchema(_ context.Context, boundSchema *kubebindv1alpha2.BoundAPIResourceSchema) func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + return func(ctx context.Context, name string) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + if name == boundSchema.Name { + return boundSchema, nil + } + return nil, errors.NewNotFound(kubebindv1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas").GroupResource(), name) + } +} + +func newUpdateBoundAPIResourceSchema(updatedSchemaPtr **kubebindv1alpha2.BoundAPIResourceSchema) func(context.Context, *kubebindv1alpha2.BoundAPIResourceSchema) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + return func(ctx context.Context, boundSchema *kubebindv1alpha2.BoundAPIResourceSchema) (*kubebindv1alpha2.BoundAPIResourceSchema, error) { + *updatedSchemaPtr = boundSchema.DeepCopy() + return boundSchema, nil + } +} + +func newExportWithResources(name, namespace string, resources []kubebindv1alpha2.APIResourceSchemaReference) *kubebindv1alpha2.APIServiceExport { + return &kubebindv1alpha2.APIServiceExport{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: kubebindv1alpha2.APIServiceExportSpec{ + Resources: resources, + }, + } +} + +func newBoundAPIResourceSchema(name string, conditions []conditionsapi.Condition) *kubebindv1alpha2.BoundAPIResourceSchema { + return &kubebindv1alpha2.BoundAPIResourceSchema{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Status: kubebindv1alpha1.APIServiceExportStatus{ + Status: kubebindv1alpha2.BoundAPIResourceSchemaStatus{ Conditions: conditions, }, } diff --git a/pkg/konnector/controllers/cluster/serviceexport/spec/spec_controller.go b/pkg/konnector/controllers/cluster/serviceexport/spec/spec_controller.go index 9334f695b..884e1ec4b 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/spec/spec_controller.go +++ b/pkg/konnector/controllers/cluster/serviceexport/spec/spec_controller.go @@ -42,9 +42,9 @@ import ( clusterscoped "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/cluster-scoped" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/multinsinformer" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -99,11 +99,11 @@ func NewController( reconciler: reconciler{ providerNamespace: providerNamespace, - getServiceNamespace: func(name string) (*kubebindv1alpha1.APIServiceNamespace, error) { + getServiceNamespace: func(name string) (*kubebindv1alpha2.APIServiceNamespace, error) { return serviceNamespaceInformer.Lister().APIServiceNamespaces(providerNamespace).Get(name) }, - createServiceNamespace: func(ctx context.Context, sn *kubebindv1alpha1.APIServiceNamespace) (*kubebindv1alpha1.APIServiceNamespace, error) { - return providerBindClient.KubeBindV1alpha1().APIServiceNamespaces(providerNamespace).Create(ctx, sn, metav1.CreateOptions{}) + createServiceNamespace: func(ctx context.Context, sn *kubebindv1alpha2.APIServiceNamespace) (*kubebindv1alpha2.APIServiceNamespace, error) { + return providerBindClient.KubeBindV1alpha2().APIServiceNamespaces(providerNamespace).Create(ctx, sn, metav1.CreateOptions{}) }, getProviderObject: func(ns, name string) (*unstructured.Unstructured, error) { if ns != "" { @@ -189,13 +189,13 @@ func NewController( } if _, err := consumerDynamicInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueConsumer(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueConsumer(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueConsumer(logger, obj) }, }); err != nil { @@ -203,13 +203,13 @@ func NewController( } if err := providerDynamicInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueProvider(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueProvider(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueProvider(logger, obj) }, }); err != nil { @@ -236,7 +236,7 @@ type controller struct { reconciler } -func (c *controller) enqueueConsumer(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueConsumer(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -247,7 +247,7 @@ func (c *controller) enqueueConsumer(logger klog.Logger, obj interface{}) { c.queue.Add(key) } -func (c *controller) enqueueProvider(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueProvider(logger klog.Logger, obj any) { upstreamKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -268,7 +268,7 @@ func (c *controller) enqueueProvider(logger klog.Logger, obj interface{}) { return } for _, obj := range sns { - sn := obj.(*kubebindv1alpha1.APIServiceNamespace) + sn := obj.(*kubebindv1alpha2.APIServiceNamespace) if sn.Namespace == c.providerNamespace { key := fmt.Sprintf("%s/%s", sn.Name, name) logger.V(2).Info("queueing Unstructured", "key", key) @@ -288,7 +288,7 @@ func (c *controller) enqueueProvider(logger klog.Logger, obj interface{}) { c.queue.Add(downstreamKey) } -func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj any) { snKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -330,13 +330,13 @@ func (c *controller) Start(ctx context.Context, numThreads int) { defer logger.Info("Shutting down controller") c.serviceNamespaceInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceNamespace(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, }) diff --git a/pkg/konnector/controllers/cluster/serviceexport/spec/spec_reconcile.go b/pkg/konnector/controllers/cluster/serviceexport/spec/spec_reconcile.go index 5d2b668a0..0eae960ad 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/spec/spec_reconcile.go +++ b/pkg/konnector/controllers/cluster/serviceexport/spec/spec_reconcile.go @@ -28,14 +28,14 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type reconciler struct { providerNamespace string - getServiceNamespace func(name string) (*kubebindv1alpha1.APIServiceNamespace, error) - createServiceNamespace func(ctx context.Context, sn *kubebindv1alpha1.APIServiceNamespace) (*kubebindv1alpha1.APIServiceNamespace, error) + getServiceNamespace func(name string) (*kubebindv1alpha2.APIServiceNamespace, error) + createServiceNamespace func(ctx context.Context, sn *kubebindv1alpha2.APIServiceNamespace) (*kubebindv1alpha2.APIServiceNamespace, error) getProviderObject func(ns, name string) (*unstructured.Unstructured, error) createProviderObject func(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error) @@ -58,7 +58,7 @@ func (r *reconciler) reconcile(ctx context.Context, obj *unstructured.Unstructur return err } else if errors.IsNotFound(err) { logger.V(1).Info("creating APIServiceNamespace", "namespace", ns) - sn, err = r.createServiceNamespace(ctx, &kubebindv1alpha1.APIServiceNamespace{ + sn, err = r.createServiceNamespace(ctx, &kubebindv1alpha2.APIServiceNamespace{ ObjectMeta: metav1.ObjectMeta{ Name: ns, Namespace: r.providerNamespace, @@ -189,7 +189,7 @@ func (r *reconciler) ensureDownstreamFinalizer(ctx context.Context, obj *unstruc // check that downstream has our finalizer found := false for _, f := range obj.GetFinalizers() { - if f == kubebindv1alpha1.DownstreamFinalizer { + if f == kubebindv1alpha2.DownstreamFinalizer { found = true break } @@ -198,7 +198,7 @@ func (r *reconciler) ensureDownstreamFinalizer(ctx context.Context, obj *unstruc if !found { logger.V(2).Info("adding finalizer to downstream object") obj = obj.DeepCopy() - obj.SetFinalizers(append(obj.GetFinalizers(), kubebindv1alpha1.DownstreamFinalizer)) + obj.SetFinalizers(append(obj.GetFinalizers(), kubebindv1alpha2.DownstreamFinalizer)) var err error if obj, err = r.updateConsumerObject(ctx, obj); err != nil { return nil, err @@ -214,7 +214,7 @@ func (r *reconciler) removeDownstreamFinalizer(ctx context.Context, obj *unstruc finalizers := []string{} found := false for _, f := range obj.GetFinalizers() { - if f == kubebindv1alpha1.DownstreamFinalizer { + if f == kubebindv1alpha2.DownstreamFinalizer { found = true continue } diff --git a/pkg/konnector/controllers/cluster/serviceexport/status/status_controller.go b/pkg/konnector/controllers/cluster/serviceexport/status/status_controller.go index 9c0f575fa..1e7e4b506 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/status/status_controller.go +++ b/pkg/konnector/controllers/cluster/serviceexport/status/status_controller.go @@ -39,8 +39,8 @@ import ( clusterscoped "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/cluster-scoped" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/multinsinformer" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -94,15 +94,15 @@ func NewController( serviceNamespaceInformer: serviceNamespaceInformer, reconciler: reconciler{ - getServiceNamespace: func(upstreamNamespace string) (*kubebindv1alpha1.APIServiceNamespace, error) { + getServiceNamespace: func(upstreamNamespace string) (*kubebindv1alpha2.APIServiceNamespace, error) { sns, err := serviceNamespaceInformer.Informer().GetIndexer().ByIndex(indexers.ServiceNamespaceByNamespace, upstreamNamespace) if err != nil { return nil, err } if len(sns) == 0 { - return nil, errors.NewNotFound(kubebindv1alpha1.SchemeGroupVersion.WithResource("APIServiceNamespace").GroupResource(), upstreamNamespace) + return nil, errors.NewNotFound(kubebindv1alpha2.SchemeGroupVersion.WithResource("APIServiceNamespace").GroupResource(), upstreamNamespace) } - return sns[0].(*kubebindv1alpha1.APIServiceNamespace), nil + return sns[0].(*kubebindv1alpha2.APIServiceNamespace), nil }, getConsumerObject: func(ns, name string) (*unstructured.Unstructured, error) { if ns != "" { @@ -146,13 +146,13 @@ func NewController( } if _, err := consumerDynamicInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueConsumer(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueConsumer(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueConsumer(logger, obj) }, }); err != nil { @@ -160,13 +160,13 @@ func NewController( } if err := providerDynamicInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueProvider(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueProvider(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueProvider(logger, obj) }, }); err != nil { @@ -195,7 +195,7 @@ type controller struct { reconciler } -func (c *controller) enqueueProvider(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueProvider(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -213,7 +213,7 @@ func (c *controller) enqueueProvider(logger klog.Logger, obj interface{}) { return } for _, obj := range sns { - sns := obj.(*kubebindv1alpha1.APIServiceNamespace) + sns := obj.(*kubebindv1alpha2.APIServiceNamespace) if sns.Namespace == c.providerNamespace { logger.V(2).Info("queueing Unstructured", "key", key) c.queue.Add(key) @@ -232,7 +232,7 @@ func (c *controller) enqueueProvider(logger klog.Logger, obj interface{}) { c.queue.Add(key) } -func (c *controller) enqueueConsumer(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueConsumer(logger klog.Logger, obj any) { downstreamKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -266,7 +266,7 @@ func (c *controller) enqueueConsumer(logger klog.Logger, obj interface{}) { c.queue.Add(upstreamKey) } -func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceNamespace(logger klog.Logger, obj any) { snKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -316,13 +316,13 @@ func (c *controller) Start(ctx context.Context, numThreads int) { defer logger.Info("Shutting down controller") c.serviceNamespaceInformer.Informer().AddDynamicEventHandler(ctx, controllerName, cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceNamespace(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceNamespace(logger, obj) }, }) @@ -401,7 +401,7 @@ func (c *controller) removeDownstreamFinalizer(ctx context.Context, obj *unstruc finalizers := []string{} found := false for _, f := range obj.GetFinalizers() { - if f == kubebindv1alpha1.DownstreamFinalizer { + if f == kubebindv1alpha2.DownstreamFinalizer { found = true continue } diff --git a/pkg/konnector/controllers/cluster/serviceexport/status/status_reconcile.go b/pkg/konnector/controllers/cluster/serviceexport/status/status_reconcile.go index ce37d2435..216e5d048 100644 --- a/pkg/konnector/controllers/cluster/serviceexport/status/status_reconcile.go +++ b/pkg/konnector/controllers/cluster/serviceexport/status/status_reconcile.go @@ -25,11 +25,11 @@ import ( "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type reconciler struct { - getServiceNamespace func(upstreamNamespace string) (*kubebindv1alpha1.APIServiceNamespace, error) + getServiceNamespace func(upstreamNamespace string) (*kubebindv1alpha2.APIServiceNamespace, error) getConsumerObject func(ns, name string) (*unstructured.Unstructured, error) updateConsumerObjectStatus func(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error) diff --git a/pkg/konnector/controllers/dynamic/eventhandler.go b/pkg/konnector/controllers/dynamic/eventhandler.go index 0f0ef9045..78a49b498 100644 --- a/pkg/konnector/controllers/dynamic/eventhandler.go +++ b/pkg/konnector/controllers/dynamic/eventhandler.go @@ -72,21 +72,21 @@ func NewDynamicInformer[L any](informer StaticInformer[L]) (Informer[L], error) } if _, err := informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { di.sharedIndexInformer.lock.RLock() defer di.sharedIndexInformer.lock.RUnlock() for _, h := range di.sharedIndexInformer.handlers { h.OnAdd(obj, false) } }, - UpdateFunc: func(oldObj, newObj interface{}) { + UpdateFunc: func(oldObj, newObj any) { di.sharedIndexInformer.lock.RLock() defer di.sharedIndexInformer.lock.RUnlock() for _, h := range di.sharedIndexInformer.handlers { h.OnUpdate(oldObj, newObj) } }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { di.sharedIndexInformer.lock.RLock() defer di.sharedIndexInformer.lock.RUnlock() for _, h := range di.sharedIndexInformer.handlers { diff --git a/pkg/konnector/controllers/servicebinding/servicebinding_controller.go b/pkg/konnector/controllers/servicebinding/servicebinding_controller.go index 966a882a5..5398e4546 100644 --- a/pkg/konnector/controllers/servicebinding/servicebinding_controller.go +++ b/pkg/konnector/controllers/servicebinding/servicebinding_controller.go @@ -35,10 +35,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/committer" "github.com/kube-bind/kube-bind/pkg/indexers" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -77,9 +77,9 @@ func NewController( }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceBinding, *kubebindv1alpha1.APIServiceBindingSpec, *kubebindv1alpha1.APIServiceBindingStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceBinding] { - return consumerBindClient.KubeBindV1alpha1().APIServiceBindings() + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceBinding, *kubebindv1alpha2.APIServiceBindingSpec, *kubebindv1alpha2.APIServiceBindingStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceBinding] { + return consumerBindClient.KubeBindV1alpha2().APIServiceBindings() }, ), } @@ -89,13 +89,13 @@ func NewController( }) if _, err := serviceBindingInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceBinding(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, }); err != nil { @@ -103,13 +103,13 @@ func NewController( } if _, err := consumerSecretInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueConsumerSecret(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueConsumerSecret(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueConsumerSecret(logger, obj) }, }); err != nil { @@ -119,7 +119,7 @@ func NewController( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceBindingSpec, *kubebindv1alpha1.APIServiceBindingStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceBindingSpec, *kubebindv1alpha2.APIServiceBindingStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error // controller reconciles ServiceBindings' kubeconfig secret references. It is @@ -138,7 +138,7 @@ type controller struct { commit CommitFunc } -func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueServiceBinding(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -149,7 +149,7 @@ func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *controller) enqueueConsumerSecret(logger klog.Logger, obj interface{}) { +func (c *controller) enqueueConsumerSecret(logger klog.Logger, obj any) { secretKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -165,7 +165,7 @@ func (c *controller) enqueueConsumerSecret(logger klog.Logger, obj interface{}) } for _, obj := range bindings { - binding := obj.(*kubebindv1alpha1.APIServiceBinding) + binding := obj.(*kubebindv1alpha2.APIServiceBinding) key, err := cache.MetaNamespaceKeyFunc(binding) if err != nil { runtime.HandleError(err) diff --git a/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go b/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go index 42bb9dba2..688da43a9 100644 --- a/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go +++ b/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go @@ -24,7 +24,7 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/clientcmd" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions" ) @@ -33,7 +33,7 @@ type reconciler struct { getConsumerSecret func(ns, name string) (*corev1.Secret, error) } -func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { var errs []error if err := r.ensureValidKubeconfigSecret(ctx, binding); err != nil { @@ -45,14 +45,14 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { secret, err := r.getConsumerSecret(binding.Spec.KubeconfigSecretRef.Namespace, binding.Spec.KubeconfigSecretRef.Name) if err != nil && !errors.IsNotFound(err) { return err } else if errors.IsNotFound(err) { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, "KubeconfigSecretNotFound", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s not found. Rerun kubectl bind for repair.", @@ -65,7 +65,7 @@ func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kub if !found { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s is missing %q string key.", @@ -80,7 +80,7 @@ func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kub if err != nil { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: %v", @@ -94,7 +94,7 @@ func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kub if !found { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: current context %q not found", @@ -107,7 +107,7 @@ func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kub if kubeContext.Namespace == "" { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: current context %q has no namespace set", @@ -120,7 +120,7 @@ func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kub if _, err := clientcmd.RESTConfigFromKubeConfig(kubeconfig); err != nil { conditions.MarkFalse( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: %v", @@ -133,7 +133,7 @@ func (r *reconciler) ensureValidKubeconfigSecret(_ context.Context, binding *kub conditions.MarkTrue( binding, - kubebindv1alpha1.APIServiceBindingConditionSecretValid, + kubebindv1alpha2.APIServiceBindingConditionSecretValid, ) return nil diff --git a/pkg/konnector/konnector_controller.go b/pkg/konnector/konnector_controller.go index c137d9b81..edd01b95a 100644 --- a/pkg/konnector/konnector_controller.go +++ b/pkg/konnector/konnector_controller.go @@ -39,10 +39,10 @@ import ( "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/dynamic" "github.com/kube-bind/kube-bind/pkg/konnector/controllers/servicebinding" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" - bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha1" - bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha1" + bindinformers "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/kubebind/v1alpha2" + bindlisters "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" ) const ( @@ -106,7 +106,7 @@ func New( getSecret: func(ns, name string) (*corev1.Secret, error) { return secretInformer.Lister().Secrets(ns).Get(name) }, - newClusterController: func(consumerSecretRefKey, providerNamespace string, reconcileServiceBinding func(binding *kubebindv1alpha1.APIServiceBinding) bool, providerConfig *rest.Config) (startable, error) { + newClusterController: func(consumerSecretRefKey, providerNamespace string, reconcileServiceBinding func(binding *kubebindv1alpha2.APIServiceBinding) bool, providerConfig *rest.Config) (startable, error) { providerConfig = rest.CopyConfig(providerConfig) providerConfig = rest.AddUserAgent(providerConfig, controllerName) @@ -123,9 +123,9 @@ func New( }, }, - commit: committer.NewCommitter[*kubebindv1alpha1.APIServiceBinding, *kubebindv1alpha1.APIServiceBindingSpec, *kubebindv1alpha1.APIServiceBindingStatus]( - func(ns string) committer.Patcher[*kubebindv1alpha1.APIServiceBinding] { - return bindClient.KubeBindV1alpha1().APIServiceBindings() + commit: committer.NewCommitter[*kubebindv1alpha2.APIServiceBinding, *kubebindv1alpha2.APIServiceBindingSpec, *kubebindv1alpha2.APIServiceBindingStatus]( + func(ns string) committer.Patcher[*kubebindv1alpha2.APIServiceBinding] { + return bindClient.KubeBindV1alpha2().APIServiceBindings() }, ), } @@ -139,13 +139,13 @@ func New( }) if _, err := serviceBindingInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueServiceBinding(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueServiceBinding(logger, obj) }, }); err != nil { @@ -153,13 +153,13 @@ func New( } if _, err := secretInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { + AddFunc: func(obj any) { c.enqueueSecret(logger, obj) }, - UpdateFunc: func(_, newObj interface{}) { + UpdateFunc: func(_, newObj any) { c.enqueueSecret(logger, newObj) }, - DeleteFunc: func(obj interface{}) { + DeleteFunc: func(obj any) { c.enqueueSecret(logger, obj) }, }); err != nil { @@ -169,7 +169,7 @@ func New( return c, nil } -type Resource = committer.Resource[*kubebindv1alpha1.APIServiceBindingSpec, *kubebindv1alpha1.APIServiceBindingStatus] +type Resource = committer.Resource[*kubebindv1alpha2.APIServiceBindingSpec, *kubebindv1alpha2.APIServiceBindingStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error type GenericController interface { @@ -198,7 +198,7 @@ type Controller struct { commit CommitFunc } -func (c *Controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueServiceBinding(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) @@ -209,7 +209,7 @@ func (c *Controller) enqueueServiceBinding(logger klog.Logger, obj interface{}) c.queue.Add(key) } -func (c *Controller) enqueueSecret(logger klog.Logger, obj interface{}) { +func (c *Controller) enqueueSecret(logger klog.Logger, obj any) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) if err != nil { runtime.HandleError(err) diff --git a/pkg/konnector/konnector_reconcile.go b/pkg/konnector/konnector_reconcile.go index a0e41acb2..4f68cbfaa 100644 --- a/pkg/konnector/konnector_reconcile.go +++ b/pkg/konnector/konnector_reconcile.go @@ -27,7 +27,7 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type startable interface { @@ -38,7 +38,7 @@ type reconciler struct { lock sync.RWMutex controllers map[string]*controllerContext // by service binding name - newClusterController func(consumerSecretRefKey, providerNamespace string, reconcileServiceBinding func(binding *kubebindv1alpha1.APIServiceBinding) bool, providerConfig *rest.Config) (startable, error) + newClusterController func(consumerSecretRefKey, providerNamespace string, reconcileServiceBinding func(binding *kubebindv1alpha2.APIServiceBinding) bool, providerConfig *rest.Config) (startable, error) getSecret func(ns, name string) (*corev1.Secret, error) } @@ -48,7 +48,7 @@ type controllerContext struct { serviceBindings sets.Set[string] // when this is empty, the Controller should be stopped by closing the context } -func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { +func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha2.APIServiceBinding) error { logger := klog.FromContext(ctx) var kubeconfig string @@ -128,7 +128,7 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP ctrl, err := r.newClusterController( binding.Spec.KubeconfigSecretRef.Namespace+"/"+binding.Spec.KubeconfigSecretRef.Name, providerNamespace, - func(svcBinding *kubebindv1alpha1.APIServiceBinding) bool { + func(svcBinding *kubebindv1alpha2.APIServiceBinding) bool { r.lock.RLock() defer r.lock.RUnlock() return r.controllers[binding.Name].serviceBindings.Has(svcBinding.Name) diff --git a/pkg/konnector/server.go b/pkg/konnector/server.go index 7f0b8efea..532d6e80a 100644 --- a/pkg/konnector/server.go +++ b/pkg/konnector/server.go @@ -25,7 +25,7 @@ import ( "github.com/kube-bind/kube-bind/deploy/crd" healthz "github.com/kube-bind/kube-bind/pkg/konnector/healthz" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type Server struct { @@ -39,7 +39,7 @@ func NewServer(config *Config) (*Server, error) { // construct controllers k, err := New( config.ClientConfig, - config.BindInformers.KubeBind().V1alpha1().APIServiceBindings(), + config.BindInformers.KubeBind().V1alpha2().APIServiceBindings(), config.KubeInformers.Core().V1().Secrets(), // TODO(sttts): watch individual secrets for security and memory consumption config.KubeInformers.Core().V1().Namespaces(), config.ApiextensionsInformers.Apiextensions().V1().CustomResourceDefinitions(), @@ -81,7 +81,7 @@ func (s *Server) PrepareRun(ctx context.Context) (Prepared, error) { // install/upgrade CRDs if err := crd.Create(ctx, s.Config.ApiextensionsClient.ApiextensionsV1().CustomResourceDefinitions(), - metav1.GroupResource{Group: kubebindv1alpha1.GroupName, Resource: "apiservicebindings"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "apiservicebindings"}, ); err != nil { return Prepared{}, err } diff --git a/sdk/apis/kubebind/v1alpha2/apiresourceschema_types.go b/sdk/apis/kubebind/v1alpha2/apiresourceschema_types.go index 812741219..589f3ede0 100644 --- a/sdk/apis/kubebind/v1alpha2/apiresourceschema_types.go +++ b/sdk/apis/kubebind/v1alpha2/apiresourceschema_types.go @@ -37,8 +37,9 @@ const ( // APIResourceSchema // +crd // +genclient +// +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:resource:scope=Cluster,categories=kube-bindings,shortName=as // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" type APIResourceSchema struct { metav1.TypeMeta `json:",inline"` @@ -132,7 +133,7 @@ type APIResourceVersion struct { // +required // +kubebuilder:pruning:PreserveUnknownFields // +structType=atomic - Schema runtime.RawExtension `json:"schema"` + Schema CRDVersionSchema `json:"schema"` // subresources specify what subresources this version of the defined custom resource have. // // +optional @@ -147,6 +148,16 @@ type APIResourceVersion struct { AdditionalPrinterColumns []apiextensionsv1.CustomResourceColumnDefinition `json:"additionalPrinterColumns,omitempty"` } +type CRDVersionSchema struct { + // openAPIV3Schema is the OpenAPI v3 schema to use for validation and pruning. + // + // +kubebuilder:pruning:PreserveUnknownFields + // +structType=atomic + // +required + // +kubebuilder:validation:Required + OpenAPIV3Schema runtime.RawExtension `json:"openAPIV3Schema"` +} + // CustomResourceConversion describes how to convert different versions of a CR. // +kubebuilder:validation:XValidation:message="Webhook must be specified if strategy=Webhook",rule="(self.strategy == 'None' && !has(self.webhook)) || (self.strategy == 'Webhook' && has(self.webhook))" type CustomResourceConversion struct { @@ -222,11 +233,11 @@ type APIResourceSchemaList struct { } func (v *APIResourceVersion) GetSchema() (*apiextensionsv1.JSONSchemaProps, error) { - if v.Schema.Raw == nil { + if v.Schema.OpenAPIV3Schema.Raw == nil { return nil, nil } var schema apiextensionsv1.JSONSchemaProps - if err := json.Unmarshal(v.Schema.Raw, &schema); err != nil { + if err := json.Unmarshal(v.Schema.OpenAPIV3Schema.Raw, &schema); err != nil { return nil, err } return &schema, nil @@ -234,13 +245,13 @@ func (v *APIResourceVersion) GetSchema() (*apiextensionsv1.JSONSchemaProps, erro func (v *APIResourceVersion) SetSchema(schema *apiextensionsv1.JSONSchemaProps) error { if schema == nil { - v.Schema.Raw = nil + v.Schema.OpenAPIV3Schema.Raw = nil return nil } raw, err := json.Marshal(schema) if err != nil { return err } - v.Schema.Raw = raw + v.Schema.OpenAPIV3Schema.Raw = raw return nil } diff --git a/sdk/apis/kubebind/v1alpha2/apiservicebinding_types.go b/sdk/apis/kubebind/v1alpha2/apiservicebinding_types.go new file mode 100644 index 000000000..97cfc0450 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/apiservicebinding_types.go @@ -0,0 +1,148 @@ +/* +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" + + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +const ( + // APIServiceBindingConditionSecretValid is set when the secret is valid. + APIServiceBindingConditionSecretValid conditionsapi.ConditionType = "SecretValid" + + // APIServiceBindingConditionInformersSynced is set when the informers can sync. + APIServiceBindingConditionInformersSynced conditionsapi.ConditionType = "InformersSynced" + + // APIServiceBindingConditionHeartbeating is set when the ClusterBinding of the service provider + // is successfully heartbeated. + APIServiceBindingConditionHeartbeating conditionsapi.ConditionType = "Heartbeating" + + // APIServiceBindingConditionConnected means the APIServiceBinding has been connected to a APIServiceExport. + APIServiceBindingConditionConnected conditionsapi.ConditionType = "Connected" + + // APIServiceBindingConditionSchemaInSync is set to true when the APIServiceExport's + // schema is applied to the consumer cluster. + APIServiceBindingConditionSchemaInSync conditionsapi.ConditionType = "SchemaInSync" + + // DownstreamFinalizer is put on downstream objects to block their deletion until + // the upstream object has been deleted. + DownstreamFinalizer = "kubebind.io/syncer" +) + +// APIServiceBinding binds an API service represented by a APIServiceExport +// in a service provider cluster into a consumer cluster. This object lives in +// the consumer cluster. +// +// +crd +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Cluster,categories=kube-bindings,shortName=sb +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Provider",type="string",JSONPath=`.status.providerPrettyName`,priority=0 +// +kubebuilder:printcolumn:name="Resources",type="string",JSONPath=`.metadata.annotations.kube-bind\.io/resources`,priority=1 +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status`,priority=0 +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].message`,priority=0 +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0 +type APIServiceBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec specifies how an API service from a service provider should be bound in the + // local consumer cluster. + Spec APIServiceBindingSpec `json:"spec"` + + // status contains reconciliation information for a service binding. + Status APIServiceBindingStatus `json:"status,omitempty"` +} + +func (in *APIServiceBinding) GetConditions() conditionsapi.Conditions { + return in.Status.Conditions +} + +func (in *APIServiceBinding) SetConditions(conditions conditionsapi.Conditions) { + in.Status.Conditions = conditions +} + +type APIServiceBindingSpec struct { + // kubeconfigSecretName is the secret ref that contains the kubeconfig of the service cluster. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="kubeconfigSecretRef is immutable" + KubeconfigSecretRef ClusterSecretKeyRef `json:"kubeconfigSecretRef"` +} + +type APIServiceBindingStatus struct { + // providerPrettyName is the pretty name of the service provider cluster. This + // can be shared among different APIServiceBindings. + ProviderPrettyName string `json:"providerPrettyName,omitempty"` + + // conditions is a list of conditions that apply to the APIServiceBinding. + Conditions conditionsapi.Conditions `json:"conditions,omitempty"` + + // BoundSchemas contains references to all BoundAPIResourceSchema objects + // associated with this APIServiceBinding, tracking consumer usage status. + // +optional + // +kubebuilder:validation:MinItems=1 + BoundSchemas []BoundSchemaReference `json:"boundSchemas,omitempty"` +} + +// BoundSchemaReference contains a reference to a BoundAPIResourceSchema with status information. +type BoundSchemaReference struct { + GroupResource `json:",inline"` +} + +// APIServiceBindingList is a list of APIServiceBindings. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type APIServiceBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []APIServiceBinding `json:"items"` +} + +type LocalSecretKeyRef struct { + // Name of the referent. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Name string `json:"name"` + + // The key of the secret to select from. Must be "kubeconfig". + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Enum=kubeconfig + Key string `json:"key"` +} + +type ClusterSecretKeyRef struct { + LocalSecretKeyRef `json:",inline"` + + // Namespace of the referent. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Namespace string `json:"namespace"` +} diff --git a/sdk/apis/kubebind/v1alpha2/apiserviceexport_types.go b/sdk/apis/kubebind/v1alpha2/apiserviceexport_types.go new file mode 100644 index 000000000..2be34e89e --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/apiserviceexport_types.go @@ -0,0 +1,158 @@ +/* +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 ( + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +const ( + SourceSpecHashAnnotationKey = "kube-bind.io/source-spec-hash" +) + +const ( + // APIServiceExportConditionConnected means the APIServiceExport has been connected to a APIServiceBinding. + APIServiceExportConditionConnected conditionsapi.ConditionType = "Connected" + + // APIServiceExportConditionProviderInSync is set to true when the APIServiceExport + // is in-sync with the CRD in the service provider cluster. + APIServiceExportConditionProviderInSync conditionsapi.ConditionType = "ProviderInSync" + + // APIServiceExportConditionConsumerInSync is set to true when the APIServiceExport's + // schema is applied to the consumer cluster. + APIServiceExportConditionConsumerInSync conditionsapi.ConditionType = "ConsumerInSync" +) + +// APIServiceExport specifies the resource to be exported. It is mostly a CRD: +// - the spec is a CRD spec, but without webhooks +// - the status reflects that on the consumer cluster +// +// +crd +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Established",type="string",JSONPath=`.status.conditions[?(@.type=="Established")].status`,priority=5 +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0 +type APIServiceExport struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec specifies the resource. + // +required + // +kubebuilder:validation:Required + Spec APIServiceExportSpec `json:"spec"` + + // status contains reconciliation information for the resource. + Status APIServiceExportStatus `json:"status,omitempty"` +} + +func (in *APIServiceExport) GetConditions() conditionsapi.Conditions { + return in.Status.Conditions +} + +func (in *APIServiceExport) SetConditions(conditions conditionsapi.Conditions) { + in.Status.Conditions = conditions +} + +// APIServiceExportSpec defines the desired state of APIServiceExport. +type APIServiceExportSpec struct { + // resources specifies the API resources to export + // +required + Resources []APIResourceSchemaReference `json:"resources"` + // informerScope is the scope of the APIServiceExport. It can be either Cluster or Namespace. + // + // Cluster: The konnector has permission to watch all namespaces at once and cluster-scoped resources. + // This is more efficient than watching each namespace individually. + // Namespaced: The konnector has permission to watch only single namespaces. + // This is more resource intensive. And it means cluster-scoped resources cannot be exported. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="informerScope is immutable" + InformerScope InformerScope `json:"informerScope"` + + // ClusterScopedIsolation specifies how cluster scoped service objects are isolated between multiple consumers on the provider side. + // It can be "Prefixed", "Namespaced", or "None". + ClusterScopedIsolation Isolation `json:"clusterScopedIsolation,omitempty"` +} + +// APIResourceSchemaReference is a list of references to APIResourceSchemas. +type APIResourceSchemaReference struct { + // Name is the name of the resource to export + // +required + // +kubebuilder:validation:Required + Name string `json:"name"` + + // Type of the resource to export + // Currently only APIResourceSchema is supported + // +kubebuilder:validation:Enum=APIResourceSchema + // +required + Type string `json:"type"` +} + +// Isolation is an enum defining the different ways to isolate cluster scoped objects +// +// +kubebuilder:validation:Enum=Prefixed;Namespaced;None +type Isolation string + +const ( + // Prepends the name of the cluster namespace to an object's name. + IsolationPrefixed Isolation = "Prefixed" + + // Maps a consumer side object into a namespaced object inside the corresponding cluster namespace. + IsolationNamespaced Isolation = "Namespaced" + + // Used for the case of a dedicated provider where isolation is not necessary. + IsolationNone Isolation = "None" +) + +// APIServiceExportStatus stores status information about a APIServiceExport. It +// reflects the status of the CRD of the consumer cluster. +type APIServiceExportStatus struct { + // acceptedNames are the names that are actually being used to serve discovery. + // They may be different than the names in spec. + // +optional + AcceptedNames apiextensionsv1.CustomResourceDefinitionNames `json:"acceptedNames"` + + // storedVersions lists all versions of CustomResources that were ever persisted. Tracking these + // versions allows a migration path for stored versions in etcd. The field is mutable + // so a migration controller can finish a migration to another version (ensuring + // no old objects are left in storage), and then remove the rest of the + // versions from this list. + // Versions may not be removed from `spec.versions` while they exist in this list. + // +optional + StoredVersions []string `json:"storedVersions"` + + // conditions is a list of conditions that apply to the APIServiceExport. It is + // updated by the konnector on the consumer cluster. + Conditions conditionsapi.Conditions `json:"conditions,omitempty"` +} + +// APIServiceExportList is the objects list that represents the APIServiceExport. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type APIServiceExportList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []APIServiceExport `json:"items"` +} diff --git a/sdk/apis/kubebind/v1alpha2/apiserviceexportrequest_types.go b/sdk/apis/kubebind/v1alpha2/apiserviceexportrequest_types.go new file mode 100644 index 000000000..302dff235 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/apiserviceexportrequest_types.go @@ -0,0 +1,180 @@ +/* +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" + "k8s.io/apimachinery/pkg/runtime" + + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +const ( + // APIServiceExportRequestConditionExportsReady is set to true when the + // corresponding APIServiceExport is ready. + APIServiceExportRequestConditionExportsReady conditionsapi.ConditionType = "ExportsReady" +) + +// APIServiceExportRequest is represents a request session of kubectl-bind-apiservice. +// +// The service provider can prune these objects after some time. +// +// +crd +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status`,priority=0 +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0 +type APIServiceExportRequest struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec specifies how an API service from a service provider should be bound in the + // local consumer cluster. + // + // +required + // +kubebuilder:validation:Required + Spec APIServiceExportRequestSpec `json:"spec"` + + // status contains reconciliation information for a service binding. + // +kubebuilder:default={} + Status APIServiceExportRequestStatus `json:"status"` +} + +// APIServiceExportRequestResponse is like APIServiceExportRequest but without +// ObjectMeta, to avoid unwanted metadata fields being sent in the response. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type APIServiceExportRequestResponse struct { + metav1.TypeMeta `json:",inline"` + ObjectMeta NameObjectMeta `json:"metadata"` + + // spec specifies how an API service from a service provider should be bound in the + // local consumer cluster. + // + // +required + // +kubebuilder:validation:Required + Spec APIServiceExportRequestSpec `json:"spec"` + + // status contains reconciliation information for a service binding. + Status APIServiceExportRequestStatus `json:"status,omitempty"` +} + +type NameObjectMeta struct { + // Name is the name of the object. + Name string `json:"name,omitempty"` +} + +func (in *APIServiceExportRequest) GetConditions() conditionsapi.Conditions { + return in.Status.Conditions +} + +func (in *APIServiceExportRequest) SetConditions(conditions conditionsapi.Conditions) { + in.Status.Conditions = conditions +} + +// APIServiceExportRequestSpec is the spec of a APIServiceExportRequest. +type APIServiceExportRequestSpec struct { + // parameters holds service provider specific parameters for this binding + // request. + // + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="parameters are immutable" + Parameters *runtime.RawExtension `json:"parameters,omitempty"` + + // resources is a list of resources that should be exported. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="resources are immutable" + Resources []APIServiceExportRequestResource `json:"resources"` +} + +type APIServiceExportRequestResource struct { + GroupResource `json:",inline"` + + // versions is a list of versions that should be exported. If this is empty + // a sensible default is chosen by the service provider. + Versions []string `json:"versions,omitempty"` +} + +// GroupResource identifies a resource. +type GroupResource struct { + // group is the name of an API group. + // For core groups this is the empty string '""'. + // + // +kubebuilder:validation:Pattern=`^(|[a-z0-9]([-a-z0-9]*[a-z0-9](\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?)$` + // +kubebuilder:default="" + Group string `json:"group,omitempty"` + + // resource is the name of the resource. + // Note: it is worth noting that you can not ask for permissions for resource provided by a CRD + // not provided by an service binding export. + // + // +kubebuilder:validation:Pattern=`^[a-z][-a-z0-9]*[a-z0-9]$` + // +required + // +kubebuilder:validation:Required + Resource string `json:"resource"` +} + +// APIServiceExportRequestPhase describes the phase of a binding request. +type APIServiceExportRequestPhase string + +const ( + // APIServiceExportRequestPhasePending indicates that the service binding + // is in progress. + APIServiceExportRequestPhasePending APIServiceExportRequestPhase = "Pending" + // APIServiceExportRequestPhaseFailed indicates that the service binding + // has failed. It will not resume. + APIServiceExportRequestPhaseFailed APIServiceExportRequestPhase = "Failed" + // APIServiceExportRequestPhaseSucceeded indicates that the service binding + // has succeeded. The corresponding APIServiceExport have been created and + // are ready. + APIServiceExportRequestPhaseSucceeded APIServiceExportRequestPhase = "Succeeded" +) + +type APIServiceExportRequestStatus struct { + // phase is the current phase of the binding request. It starts in Pending + // and transitions to Succeeded or Failed. See the condition for detailed + // information. + // + // +optional + // +kubebuilder:validation:Optional + // +kubebuilder:default=Pending + // +kubebuilder:validation:Enum=Pending;Failed;Succeeded + Phase APIServiceExportRequestPhase `json:"phase,omitempty"` + + // terminalMessage is a human readable message that describes the reason + // for the current phase. + TerminalMessage string `json:"terminalMessage,omitempty"` + + // conditions is a list of conditions that apply to the ClusterBinding. It is + // updated by the konnector and the service provider. + Conditions conditionsapi.Conditions `json:"conditions,omitempty"` +} + +// APIServiceExportRequestList is the list of APIServiceExportRequest. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type APIServiceExportRequestList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []APIServiceExportRequest `json:"items"` +} diff --git a/sdk/apis/kubebind/v1alpha2/apiservicenamespace_types.go b/sdk/apis/kubebind/v1alpha2/apiservicenamespace_types.go new file mode 100644 index 000000000..9a0a48319 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/apiservicenamespace_types.go @@ -0,0 +1,70 @@ +/* +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" +) + +const ( + APIServiceNamespaceAnnotationKey = "kube-bind.io/api-service-namespace" +) + +// APIServiceNamespace defines how consumer namespaces map to service namespaces. +// These objects are created by the konnector, and a service namespace is then +// created by the service provider. +// +// The name of the APIServiceNamespace equals the namespace name in the consumer +// cluster. +// +// +crd +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Namespace",type="string",JSONPath=`.status.namespace`,priority=0 +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0 +type APIServiceNamespace struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec specifies a service namespace. + Spec APIServiceNamespaceSpec `json:"spec"` + + // status contains reconciliation information for a service namespace + Status APIServiceNamespaceStatus `json:"status,omitempty"` +} + +type APIServiceNamespaceSpec struct { +} + +type APIServiceNamespaceStatus struct { + // namespace is the service provider namespace name that will be bound to the + // consumer namespace named like this object. + Namespace string `json:"namespace,omitempty"` +} + +// APIServiceNamespaceList is the list of ServiceNamespaces. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type APIServiceNamespaceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []APIServiceNamespace `json:"items"` +} diff --git a/sdk/apis/kubebind/v1alpha2/bindingprovider_types.go b/sdk/apis/kubebind/v1alpha2/bindingprovider_types.go new file mode 100644 index 000000000..90ec32ebb --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/bindingprovider_types.go @@ -0,0 +1,82 @@ +/* +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" +) + +// BindingProvider is a non-CRUD resource that is returned by the server before +// authentication. It specifies which authentication flows the provider supports. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:storageversion +type BindingProvider struct { + metav1.TypeMeta `json:",inline"` + + // providerPrettyName is the name of the provider that is displayed to the user, e.g: + // MangoDB Inc. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + ProviderPrettyName string `json:"providerPrettyName"` + + // version is the kube-bind.io version of the provider. The kubectl bind will check + // this for compatibility. + // + // +required + // +kubebuilder:validation:Required + Version string `json:"version"` + + // authenticationMethods is a list of authentication methods supported by the + // service provider. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + AuthenticationMethods []AuthenticationMethod `json:"authenticationMethods,omitempty"` +} + +type AuthenticationMethod struct { + // method is the name of the authentication method. The follow methods are supported: + // + // - "OAuth2CodeGrant" + // + // The list is ordered by preference by the service provider. The consumer should + // try to use the first method in the list that matches the capabilities of the + // client environment (e.g. does the client support a web browser) and the + // flags provided by the user. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Enum=OAuth2CodeGrant + Method string `json:"method,omitempty"` + + // OAuth2CodeGrant is the configuration for the OAuth2 code grant flow. + OAuth2CodeGrant *OAuth2CodeGrant `json:"oauth2CodeGrant,omitempty"` +} + +type OAuth2CodeGrant struct { + // authenticatedURL is the service provider url that the service consumer will use to authenticate against + // the service provider in case of using OIDC mode made, e.g: www.mangodb.com/kubernetes/authorize. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + AuthenticatedURL string `json:"authenticatedURL"` +} diff --git a/sdk/apis/kubebind/v1alpha2/bindingresponse_types.go b/sdk/apis/kubebind/v1alpha2/bindingresponse_types.go new file mode 100644 index 000000000..f99acaac4 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/bindingresponse_types.go @@ -0,0 +1,75 @@ +/* +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" + "k8s.io/apimachinery/pkg/runtime" +) + +// BindingResponse is a non-CRUD resource that is returned by the server after +// authentication and resource selection on the service prpvider website. It returns +// a list of requests of possibly different types that kubectl bind has to +// pass to the sub-command kubect-bind-, e.g. kubectl-bind-apiservice for +// APIServiceExportRequest. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:storageversion +type BindingResponse struct { + metav1.TypeMeta `json:",inline"` + + // authentication is data specific to the authentication method that was used. + // + // +optional + // +kubebuilder:validation:Optional + Authentication BindingResponseAuthentication `json:"authentication,omitempty"` + + // kubeconfig is a kubeconfig file that can be used to access the service provider cluster. + // + // +required + // +kubebuilder:validation:Required + Kubeconfig []byte `json:"kubeconfig"` + + // requests is a list of binding requests of different types, e.g. APIServiceExportRequest. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinItems=1 + Requests []runtime.RawExtension `json:"requests"` +} + +// BindingResponseAuthentication is the authentication data specific to the +// authentication method that was used. Exactly one field must be set. +type BindingResponseAuthentication struct { + // oauth2CodeGrant is the data returned by the OAuth2 code grant flow. + // + // +optional + // +kubebuilder:validation:Optional + OAuth2CodeGrant *BindingResponseAuthenticationOAuth2CodeGrant `json:"oauth2CodeGrant,omitempty"` +} + +// BindingResponseAuthenticationOAuth2CodeGrant contains the authentication data which is passed back to +// the consumer as BindingResponse.Authentication. It is authentication method +// specific. +type BindingResponseAuthenticationOAuth2CodeGrant struct { + // sessionID is the session ID that was originally passed from the consumer to + // the service provider. It must be checked to equal the original value. + SessionID string `json:"sid"` + + // id is the ID of the authenticated user. It is for informational purposes only. + ID string `json:"id"` +} diff --git a/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go b/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go index e15e9c970..7c0e74df3 100644 --- a/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go +++ b/sdk/apis/kubebind/v1alpha2/boundapiresourceschema_types.go @@ -17,14 +17,17 @@ limitations under the License. package v1alpha2 import ( + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" ) // BoundAPIResourceSchema // +crd // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings,shortName=bas // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" type BoundAPIResourceSchema struct { @@ -47,17 +50,13 @@ type BoundAPIResourceSchemaSpec struct { 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" + BoundAPIResourceSchemaValid conditionsapi.ConditionType = "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" + BoundAPIResourceSchemaInvalid conditionsapi.ConditionType = "Invalid" ) // BoundAPIResourceSchemaConditionReason is the set of reasons for specific condition type. @@ -75,11 +74,32 @@ const ( BoundAPIResourceSchemaDriftDetected BoundAPIResourceSchemaConditionReason = "DriftDetected" ) +func (in *BoundAPIResourceSchema) GetConditions() conditionsapi.Conditions { + return in.Status.Conditions +} + +func (in *BoundAPIResourceSchema) SetConditions(conditions conditionsapi.Conditions) { + in.Status.Conditions = conditions +} + // BoundAPIResourceSchemaStatus defines the observed state of the BoundAPIResourceSchema. type BoundAPIResourceSchemaStatus struct { + // acceptedNames are the names that are actually being used to serve discovery. + // They may be different than the names in spec. + // +optional + AcceptedNames apiextensionsv1.CustomResourceDefinitionNames `json:"acceptedNames"` + + // storedVersions lists all versions of CustomResources that were ever persisted. Tracking these + // versions allows a migration path for stored versions in etcd. The field is mutable + // so a migration controller can finish a migration to another version (ensuring + // no old objects are left in storage), and then remove the rest of the + // versions from this list. + // Versions may not be removed from `spec.versions` while they exist in this list. + // +optional + StoredVersions []string `json:"storedVersions"` // Conditions represent the latest available observations of the object's state. // +optional - Conditions []metav1.Condition `json:"conditions,omitempty"` + Conditions []conditionsapi.Condition `json:"conditions,omitempty"` // Instantiations tracks the number of instances of the resource on the consumer side. // +optional diff --git a/sdk/apis/kubebind/v1alpha2/clusterbinding_types.go b/sdk/apis/kubebind/v1alpha2/clusterbinding_types.go new file mode 100644 index 000000000..fcf579999 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/clusterbinding_types.go @@ -0,0 +1,124 @@ +/* +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" + "k8s.io/apimachinery/pkg/runtime" + + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +const ( + // ClusterBindingConditionSecretValid is set when the secret is valid. + ClusterBindingConditionSecretValid = "SecretValid" + + // ClusterBindingConditionValidVersion is set when the binary version is valid. + ClusterBindingConditionValidVersion = "ValidVersion" + + // ClusterBindingConditionHealthy is set when the cluster binding is healthy. + ClusterBindingConditionHealthy = "Healthy" +) + +// ClusterBinding represents a bound consumer cluster. It lives in a service +// provider cluster and is a singleton named "cluster" per namespace. +// +// +crd +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Namespaced,categories=kube-bindings +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Konnector Version",type="string",JSONPath=`.status.konnectorVersion`,priority=0 +// +kubebuilder:printcolumn:name="Last Heartbeat",type="date",JSONPath=`.status.lastHeartbeatTime`,priority=0 +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status`,priority=0 +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`,priority=0 +// +kubebuilder:validation:XValidation:rule="self.metadata.name == \"cluster\"",message="cluster binding name should be cluster" +type ClusterBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec represents the data in the newly created ClusterBinding. + // +required + // +kubebuilder:validation:Required + Spec ClusterBindingSpec `json:"spec"` + + // status contains reconciliation information for the service binding. + Status ClusterBindingStatus `json:"status,omitempty"` +} + +func (in *ClusterBinding) GetConditions() conditionsapi.Conditions { + return in.Status.Conditions +} + +func (in *ClusterBinding) SetConditions(conditions conditionsapi.Conditions) { + in.Status.Conditions = conditions +} + +// ClusterBindingSpec represents the data in the newly created ClusterBinding. +type ClusterBindingSpec struct { + // kubeconfigSecretName is the secret ref that contains the kubeconfig of the service cluster. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="kubeconfigSecretRef is immutable" + KubeconfigSecretRef LocalSecretKeyRef `json:"kubeconfigSecretRef"` + + // providerPrettyName is the pretty name of the service provider cluster. This + // can be shared among different ServiceBindings. + // + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + ProviderPrettyName string `json:"providerPrettyName"` + + // serviceProviderSpec contains all the data and information about the service which has been bound to the service + // binding request. The service providers decide what they need and what to configure based on what then include in + // this field, such as service region, type, tiers, etc... + ServiceProviderSpec runtime.RawExtension `json:"serviceProviderSpec,omitempty"` +} + +// ClusterBindingStatus stores status information about a service binding. It is +// updated by both the konnector and the service provider. +type ClusterBindingStatus struct { + // lastHeartbeatTime is the last time the konnector updated the status. + LastHeartbeatTime metav1.Time `json:"lastHeartbeatTime,omitempty"` + + // heartbeatInterval is the maximal interval between heartbeats that the + // konnector promises to send. The service provider can assume that the + // konnector is not unhealthy if it does not receive a heartbeat within + // this time. + HeartbeatInterval metav1.Duration `json:"heartbeatInterval,omitempty"` + + // konnectorVersion is the version of the konnector that is running on the + // consumer cluster. + KonnectorVersion string `json:"konnectorVersion,omitempty"` + + // conditions is a list of conditions that apply to the ClusterBinding. It is + // updated by the konnector and the service provider. + Conditions conditionsapi.Conditions `json:"conditions,omitempty"` +} + +// ClusterBindingList is the objects list that represents the ClusterBinding. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ClusterBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []ClusterBinding `json:"items"` +} diff --git a/sdk/apis/kubebind/v1alpha2/helpers/apiresourceschema.go b/sdk/apis/kubebind/v1alpha2/helpers/apiresourceschema.go new file mode 100644 index 000000000..c66388cbc --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/helpers/apiresourceschema.go @@ -0,0 +1,188 @@ +/* +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 helpers + +import ( + "crypto/sha256" + "encoding/json" + "fmt" + "math/big" + + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// CRDToAPIResourceSchema converts a CustomResourceDefinition to an APIResourceSchema. +func CRDToAPIResourceSchema(crd *apiextensionsv1.CustomResourceDefinition, prefix string) (*kubebindv1alpha2.APIResourceSchema, error) { + name := crd.Name + if prefix != "" { + name = prefix + "." + crd.Name + } + + informerScope := kubebindv1alpha2.NamespacedScope + apiResourceSchema := &kubebindv1alpha2.APIResourceSchema{ + TypeMeta: metav1.TypeMeta{ + APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), + Kind: "APIResourceSchema", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + Spec: kubebindv1alpha2.APIResourceSchemaSpec{ + InformerScope: informerScope, + APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{ + Group: crd.Spec.Group, + Names: crd.Spec.Names, + Scope: crd.Spec.Scope, + }, + }, + } + + if len(crd.Spec.Versions) > 1 && crd.Spec.Conversion == nil { + return nil, fmt.Errorf("multiple versions specified for CRD %q but no conversion strategy", crd.Name) + } + + if crd.Spec.Conversion != nil { + crConversion := &kubebindv1alpha2.CustomResourceConversion{ + Strategy: kubebindv1alpha2.ConversionStrategyType(crd.Spec.Conversion.Strategy), + } + + if crd.Spec.Conversion.Strategy == "Webhook" { + crConversion.Webhook = &kubebindv1alpha2.WebhookConversion{ + ConversionReviewVersions: crd.Spec.Conversion.Webhook.ConversionReviewVersions, + } + + if crd.Spec.Conversion.Webhook.ClientConfig != nil { + crConversion.Webhook.ClientConfig = &kubebindv1alpha2.WebhookClientConfig{ + URL: crd.Spec.Conversion.Webhook.ClientConfig.URL, + CABundle: crd.Spec.Conversion.Webhook.ClientConfig.CABundle, + } + } + } + + apiResourceSchema.Spec.Conversion = crConversion + } + + for _, crdVersion := range crd.Spec.Versions { + apiResourceVersion := kubebindv1alpha2.APIResourceVersion{ + Name: crdVersion.Name, + Served: crdVersion.Served, + Storage: crdVersion.Storage, + Deprecated: crdVersion.Deprecated, + DeprecationWarning: crdVersion.DeprecationWarning, + AdditionalPrinterColumns: crdVersion.AdditionalPrinterColumns, + } + if crdVersion.Schema != nil && crdVersion.Schema.OpenAPIV3Schema != nil { + rawSchema, err := json.Marshal(crdVersion.Schema.OpenAPIV3Schema) + if err != nil { + return nil, fmt.Errorf("error converting schema for version %q: %w", crdVersion.Name, err) + } + apiResourceVersion.Schema = kubebindv1alpha2.CRDVersionSchema{ + OpenAPIV3Schema: runtime.RawExtension{Raw: rawSchema}, + } + } + + if crdVersion.Subresources != nil { + apiResourceVersion.Subresources = *crdVersion.Subresources + } + + apiResourceSchema.Spec.Versions = append(apiResourceSchema.Spec.Versions, apiResourceVersion) + } + + return apiResourceSchema, nil +} + +// APIResourceSchemaToCRD converts an APIResourceSchema to a CustomResourceDefinition. +func APIResourceSchemaToCRD(schema *kubebindv1alpha2.APIResourceSchema) (*apiextensionsv1.CustomResourceDefinition, error) { + crd := &apiextensionsv1.CustomResourceDefinition{ + ObjectMeta: metav1.ObjectMeta{ + Name: schema.Spec.Names.Plural + "." + schema.Spec.Group, + Annotations: map[string]string{ + "kube-bind.io/source-schema": schema.Name, + }, + }, + Spec: apiextensionsv1.CustomResourceDefinitionSpec{ + Group: schema.Spec.Group, + Names: schema.Spec.Names, + Scope: schema.Spec.Scope, + }, + } + + for _, schemaVersion := range schema.Spec.Versions { + crdVersion := apiextensionsv1.CustomResourceDefinitionVersion{ + Name: schemaVersion.Name, + Served: schemaVersion.Served, + Storage: schemaVersion.Storage, + Deprecated: schemaVersion.Deprecated, + DeprecationWarning: schemaVersion.DeprecationWarning, + AdditionalPrinterColumns: schemaVersion.AdditionalPrinterColumns, + } + + if schemaVersion.Schema.OpenAPIV3Schema.Raw != nil { + var schemaObj apiextensionsv1.JSONSchemaProps + if err := json.Unmarshal(schemaVersion.Schema.OpenAPIV3Schema.Raw, &schemaObj); err != nil { + return nil, fmt.Errorf("failed to unmarshal schema for version %s: %v", schemaVersion.Name, err) + } + crdVersion.Schema = &apiextensionsv1.CustomResourceValidation{ + OpenAPIV3Schema: &schemaObj, + } + } + + if schemaVersion.Subresources.Status != nil || schemaVersion.Subresources.Scale != nil { + crdVersion.Subresources = &apiextensionsv1.CustomResourceSubresources{} + + if schemaVersion.Subresources.Status != nil { + crdVersion.Subresources.Status = &apiextensionsv1.CustomResourceSubresourceStatus{} + } + + if schemaVersion.Subresources.Scale != nil { + crdVersion.Subresources.Scale = &apiextensionsv1.CustomResourceSubresourceScale{ + SpecReplicasPath: schemaVersion.Subresources.Scale.SpecReplicasPath, + StatusReplicasPath: schemaVersion.Subresources.Scale.StatusReplicasPath, + LabelSelectorPath: schemaVersion.Subresources.Scale.LabelSelectorPath, + } + } + } + + crd.Spec.Versions = append(crd.Spec.Versions, crdVersion) + } + + return crd, nil +} +func APIResourceSchemaCRDSpecHash(obj *kubebindv1alpha2.APIResourceSchemaCRDSpec) string { + bs, err := json.Marshal(obj) + if err != nil { + utilruntime.HandleError(err) + return "" + } + + return toSha224Base62(string(bs)) +} + +func toSha224Base62(s string) string { + return toBase62(sha256.Sum224([]byte(s))) +} + +func toBase62(hash [28]byte) string { + var i big.Int + i.SetBytes(hash[:]) + return i.Text(62) +} diff --git a/sdk/apis/kubebind/v1alpha2/helpers/apiresourceschema_test.go b/sdk/apis/kubebind/v1alpha2/helpers/apiresourceschema_test.go new file mode 100644 index 000000000..4dd624595 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/helpers/apiresourceschema_test.go @@ -0,0 +1,65 @@ +/* +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 helpers + +import ( + "testing" + + "github.com/stretchr/testify/require" + + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/utils/ptr" +) + +func TestWebhookCRDStorageVersion(t *testing.T) { + input := v1.CustomResourceDefinition{ + Spec: v1.CustomResourceDefinitionSpec{ + Versions: []v1.CustomResourceDefinitionVersion{ + { + Served: true, + Name: "v1alpha2", + Storage: false, + }, + { + Served: true, + Name: "v1", + Storage: true, + }, + }, + Conversion: &v1.CustomResourceConversion{ + Strategy: v1.WebhookConverter, + Webhook: &v1.WebhookConversion{ + ClientConfig: &v1.WebhookClientConfig{ + URL: ptr.To("https://example.com/webhook"), + CABundle: []byte("1234")}, + }, + }, + }, + } + + output, err := CRDToAPIResourceSchema(&input, "test") + + require.NoError(t, err) + + atLeastOneStorageVersion := false + for _, v := range output.Spec.Versions { + atLeastOneStorageVersion = atLeastOneStorageVersion || v.Storage + } + if !atLeastOneStorageVersion { + t.Fatal("returned ResourceExport has no storage version", output) + } +} diff --git a/sdk/apis/kubebind/v1alpha2/helpers/boundapiresourceschema.go b/sdk/apis/kubebind/v1alpha2/helpers/boundapiresourceschema.go new file mode 100644 index 000000000..01d664722 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/helpers/boundapiresourceschema.go @@ -0,0 +1,104 @@ +/* +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 helpers + +import ( + "encoding/json" + "fmt" + + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// CRDToBoundAPIResourceSchema converts a CustomResourceDefinition to an BoundAPIResourceSchema. +func CRDToBoundAPIResourceSchema(crd *apiextensionsv1.CustomResourceDefinition, prefix string) (*kubebindv1alpha2.APIResourceSchema, error) { + name := prefix + "." + crd.Name + informerScope := kubebindv1alpha2.NamespacedScope + apiResourceSchema := &kubebindv1alpha2.APIResourceSchema{ + TypeMeta: metav1.TypeMeta{ + APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(), + Kind: "APIResourceSchema", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + Spec: kubebindv1alpha2.APIResourceSchemaSpec{ + InformerScope: informerScope, + APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{ + Group: crd.Spec.Group, + Names: crd.Spec.Names, + Scope: crd.Spec.Scope, + }, + }, + } + + if len(crd.Spec.Versions) > 1 && crd.Spec.Conversion == nil { + return nil, fmt.Errorf("multiple versions specified for CRD %q but no conversion strategy", crd.Name) + } + + if crd.Spec.Conversion != nil { + crConversion := &kubebindv1alpha2.CustomResourceConversion{ + Strategy: kubebindv1alpha2.ConversionStrategyType(crd.Spec.Conversion.Strategy), + } + + if crd.Spec.Conversion.Strategy == "Webhook" { + crConversion.Webhook = &kubebindv1alpha2.WebhookConversion{ + ConversionReviewVersions: crd.Spec.Conversion.Webhook.ConversionReviewVersions, + } + + if crd.Spec.Conversion.Webhook.ClientConfig != nil { + crConversion.Webhook.ClientConfig = &kubebindv1alpha2.WebhookClientConfig{ + URL: crd.Spec.Conversion.Webhook.ClientConfig.URL, + CABundle: crd.Spec.Conversion.Webhook.ClientConfig.CABundle, + } + } + } + + apiResourceSchema.Spec.Conversion = crConversion + } + + for _, crdVersion := range crd.Spec.Versions { + apiResourceVersion := kubebindv1alpha2.APIResourceVersion{ + Name: crdVersion.Name, + Served: crdVersion.Served, + Storage: crdVersion.Storage, + Deprecated: crdVersion.Deprecated, + DeprecationWarning: crdVersion.DeprecationWarning, + AdditionalPrinterColumns: crdVersion.AdditionalPrinterColumns, + } + if crdVersion.Schema != nil && crdVersion.Schema.OpenAPIV3Schema != nil { + rawSchema, err := json.Marshal(crdVersion.Schema.OpenAPIV3Schema) + if err != nil { + return nil, fmt.Errorf("error converting schema for version %q: %w", crdVersion.Name, err) + } + apiResourceVersion.Schema = kubebindv1alpha2.CRDVersionSchema{ + OpenAPIV3Schema: runtime.RawExtension{Raw: rawSchema}, + } + } + + if crdVersion.Subresources != nil { + apiResourceVersion.Subresources = *crdVersion.Subresources + } + + apiResourceSchema.Spec.Versions = append(apiResourceSchema.Spec.Versions, apiResourceVersion) + } + + return apiResourceSchema, nil +} diff --git a/sdk/apis/kubebind/v1alpha2/helpers/crd.go b/sdk/apis/kubebind/v1alpha2/helpers/crd.go new file mode 100644 index 000000000..f4898c103 --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/helpers/crd.go @@ -0,0 +1,42 @@ +/* +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 helpers + +import ( + "strings" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + + "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +func IsOwnedByBinding(name string, uid types.UID, refs []v1.OwnerReference) bool { + for _, ref := range refs { + parts := strings.SplitN(ref.APIVersion, "/", 2) + if parts[0] != v1alpha2.SchemeGroupVersion.Group || ref.Kind != "APIServiceBinding" { + continue + } + if ref.Name != name { + continue + } + if uid == "" || ref.UID == uid { + return true + } + } + return false +} diff --git a/sdk/apis/kubebind/v1alpha2/register.go b/sdk/apis/kubebind/v1alpha2/register.go index 0225cb21b..0504c3814 100644 --- a/sdk/apis/kubebind/v1alpha2/register.go +++ b/sdk/apis/kubebind/v1alpha2/register.go @@ -50,6 +50,18 @@ func addKnownTypes(scheme *runtime.Scheme) error { &APIResourceSchemaList{}, &BoundAPIResourceSchema{}, &BoundAPIResourceSchemaList{}, + &APIServiceBinding{}, + &APIServiceBindingList{}, + &APIServiceExport{}, + &APIServiceExportList{}, + &APIServiceExportRequest{}, + &APIServiceExportRequestList{}, + &APIServiceNamespace{}, + &APIServiceNamespaceList{}, + &ClusterBinding{}, + &ClusterBindingList{}, + &BindingProvider{}, + &BindingResponse{}, ) 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 411fe5052..4e9a67533 100644 --- a/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go +++ b/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go @@ -23,8 +23,9 @@ 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" + + v1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -116,6 +117,22 @@ func (in *APIResourceSchemaList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIResourceSchemaReference) DeepCopyInto(out *APIResourceSchemaReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIResourceSchemaReference. +func (in *APIResourceSchemaReference) DeepCopy() *APIResourceSchemaReference { + if in == nil { + return nil + } + out := new(APIResourceSchemaReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *APIResourceSchemaSpec) DeepCopyInto(out *APIResourceSchemaSpec) { *out = *in @@ -162,27 +179,27 @@ func (in *APIResourceVersion) DeepCopy() *APIResourceVersion { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BoundAPIResourceSchema) DeepCopyInto(out *BoundAPIResourceSchema) { +func (in *APIServiceBinding) DeepCopyInto(out *APIServiceBinding) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) + out.Spec = in.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 { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceBinding. +func (in *APIServiceBinding) DeepCopy() *APIServiceBinding { if in == nil { return nil } - out := new(BoundAPIResourceSchema) + out := new(APIServiceBinding) 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 { +func (in *APIServiceBinding) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -190,13 +207,13 @@ func (in *BoundAPIResourceSchema) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BoundAPIResourceSchemaList) DeepCopyInto(out *BoundAPIResourceSchemaList) { +func (in *APIServiceBindingList) DeepCopyInto(out *APIServiceBindingList) { *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)) + *out = make([]APIServiceBinding, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -204,18 +221,18 @@ func (in *BoundAPIResourceSchemaList) DeepCopyInto(out *BoundAPIResourceSchemaLi return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchemaList. -func (in *BoundAPIResourceSchemaList) DeepCopy() *BoundAPIResourceSchemaList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceBindingList. +func (in *APIServiceBindingList) DeepCopy() *APIServiceBindingList { if in == nil { return nil } - out := new(BoundAPIResourceSchemaList) + out := new(APIServiceBindingList) 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 { +func (in *APIServiceBindingList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -223,62 +240,887 @@ func (in *BoundAPIResourceSchemaList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BoundAPIResourceSchemaSpec) DeepCopyInto(out *BoundAPIResourceSchemaSpec) { +func (in *APIServiceBindingSpec) DeepCopyInto(out *APIServiceBindingSpec) { *out = *in - in.APIResourceSchemaCRDSpec.DeepCopyInto(&out.APIResourceSchemaCRDSpec) + out.KubeconfigSecretRef = in.KubeconfigSecretRef return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchemaSpec. -func (in *BoundAPIResourceSchemaSpec) DeepCopy() *BoundAPIResourceSchemaSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceBindingSpec. +func (in *APIServiceBindingSpec) DeepCopy() *APIServiceBindingSpec { if in == nil { return nil } - out := new(BoundAPIResourceSchemaSpec) + out := new(APIServiceBindingSpec) 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) { +func (in *APIServiceBindingStatus) DeepCopyInto(out *APIServiceBindingStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(v1alpha1.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.BoundSchemas != nil { + in, out := &in.BoundSchemas, &out.BoundSchemas + *out = make([]BoundSchemaReference, len(*in)) + copy(*out, *in) + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundAPIResourceSchemaStatus. -func (in *BoundAPIResourceSchemaStatus) DeepCopy() *BoundAPIResourceSchemaStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceBindingStatus. +func (in *APIServiceBindingStatus) DeepCopy() *APIServiceBindingStatus { if in == nil { return nil } - out := new(BoundAPIResourceSchemaStatus) + out := new(APIServiceBindingStatus) 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) { +func (in *APIServiceExport) DeepCopyInto(out *APIServiceExport) { *out = *in - if in.Webhook != nil { - in, out := &in.Webhook, &out.Webhook - *out = new(WebhookConversion) + 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 APIServiceExport. +func (in *APIServiceExport) DeepCopy() *APIServiceExport { + if in == nil { + return nil + } + out := new(APIServiceExport) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceExport) 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 *APIServiceExportList) DeepCopyInto(out *APIServiceExportList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]APIServiceExport, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportList. +func (in *APIServiceExportList) DeepCopy() *APIServiceExportList { + if in == nil { + return nil + } + out := new(APIServiceExportList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceExportList) 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 *APIServiceExportRequest) DeepCopyInto(out *APIServiceExportRequest) { + *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 APIServiceExportRequest. +func (in *APIServiceExportRequest) DeepCopy() *APIServiceExportRequest { + if in == nil { + return nil + } + out := new(APIServiceExportRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceExportRequest) 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 *APIServiceExportRequestList) DeepCopyInto(out *APIServiceExportRequestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]APIServiceExportRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportRequestList. +func (in *APIServiceExportRequestList) DeepCopy() *APIServiceExportRequestList { + if in == nil { + return nil + } + out := new(APIServiceExportRequestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceExportRequestList) 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 *APIServiceExportRequestResource) DeepCopyInto(out *APIServiceExportRequestResource) { + *out = *in + out.GroupResource = in.GroupResource + if in.Versions != nil { + in, out := &in.Versions, &out.Versions + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportRequestResource. +func (in *APIServiceExportRequestResource) DeepCopy() *APIServiceExportRequestResource { + if in == nil { + return nil + } + out := new(APIServiceExportRequestResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceExportRequestResponse) DeepCopyInto(out *APIServiceExportRequestResponse) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ObjectMeta = in.ObjectMeta + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportRequestResponse. +func (in *APIServiceExportRequestResponse) DeepCopy() *APIServiceExportRequestResponse { + if in == nil { + return nil + } + out := new(APIServiceExportRequestResponse) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceExportRequestResponse) 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 *APIServiceExportRequestSpec) DeepCopyInto(out *APIServiceExportRequestSpec) { + *out = *in + if in.Parameters != nil { + in, out := &in.Parameters, &out.Parameters + *out = new(runtime.RawExtension) (*in).DeepCopyInto(*out) } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIServiceExportRequestResource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceConversion. -func (in *CustomResourceConversion) DeepCopy() *CustomResourceConversion { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportRequestSpec. +func (in *APIServiceExportRequestSpec) DeepCopy() *APIServiceExportRequestSpec { if in == nil { return nil } - out := new(CustomResourceConversion) + out := new(APIServiceExportRequestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceExportRequestStatus) DeepCopyInto(out *APIServiceExportRequestStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1alpha1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportRequestStatus. +func (in *APIServiceExportRequestStatus) DeepCopy() *APIServiceExportRequestStatus { + if in == nil { + return nil + } + out := new(APIServiceExportRequestStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceExportSpec) DeepCopyInto(out *APIServiceExportSpec) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceSchemaReference, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportSpec. +func (in *APIServiceExportSpec) DeepCopy() *APIServiceExportSpec { + if in == nil { + return nil + } + out := new(APIServiceExportSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceExportStatus) DeepCopyInto(out *APIServiceExportStatus) { + *out = *in + in.AcceptedNames.DeepCopyInto(&out.AcceptedNames) + if in.StoredVersions != nil { + in, out := &in.StoredVersions, &out.StoredVersions + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1alpha1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceExportStatus. +func (in *APIServiceExportStatus) DeepCopy() *APIServiceExportStatus { + if in == nil { + return nil + } + out := new(APIServiceExportStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceNamespace) DeepCopyInto(out *APIServiceNamespace) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceNamespace. +func (in *APIServiceNamespace) DeepCopy() *APIServiceNamespace { + if in == nil { + return nil + } + out := new(APIServiceNamespace) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceNamespace) 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 *APIServiceNamespaceList) DeepCopyInto(out *APIServiceNamespaceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]APIServiceNamespace, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceNamespaceList. +func (in *APIServiceNamespaceList) DeepCopy() *APIServiceNamespaceList { + if in == nil { + return nil + } + out := new(APIServiceNamespaceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIServiceNamespaceList) 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 *APIServiceNamespaceSpec) DeepCopyInto(out *APIServiceNamespaceSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceNamespaceSpec. +func (in *APIServiceNamespaceSpec) DeepCopy() *APIServiceNamespaceSpec { + if in == nil { + return nil + } + out := new(APIServiceNamespaceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceNamespaceStatus) DeepCopyInto(out *APIServiceNamespaceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceNamespaceStatus. +func (in *APIServiceNamespaceStatus) DeepCopy() *APIServiceNamespaceStatus { + if in == nil { + return nil + } + out := new(APIServiceNamespaceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AuthenticationMethod) DeepCopyInto(out *AuthenticationMethod) { + *out = *in + if in.OAuth2CodeGrant != nil { + in, out := &in.OAuth2CodeGrant, &out.OAuth2CodeGrant + *out = new(OAuth2CodeGrant) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationMethod. +func (in *AuthenticationMethod) DeepCopy() *AuthenticationMethod { + if in == nil { + return nil + } + out := new(AuthenticationMethod) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindingProvider) DeepCopyInto(out *BindingProvider) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.AuthenticationMethods != nil { + in, out := &in.AuthenticationMethods, &out.AuthenticationMethods + *out = make([]AuthenticationMethod, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingProvider. +func (in *BindingProvider) DeepCopy() *BindingProvider { + if in == nil { + return nil + } + out := new(BindingProvider) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BindingProvider) 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 *BindingResponse) DeepCopyInto(out *BindingResponse) { + *out = *in + out.TypeMeta = in.TypeMeta + in.Authentication.DeepCopyInto(&out.Authentication) + if in.Kubeconfig != nil { + in, out := &in.Kubeconfig, &out.Kubeconfig + *out = make([]byte, len(*in)) + copy(*out, *in) + } + if in.Requests != nil { + in, out := &in.Requests, &out.Requests + *out = make([]runtime.RawExtension, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingResponse. +func (in *BindingResponse) DeepCopy() *BindingResponse { + if in == nil { + return nil + } + out := new(BindingResponse) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BindingResponse) 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 *BindingResponseAuthentication) DeepCopyInto(out *BindingResponseAuthentication) { + *out = *in + if in.OAuth2CodeGrant != nil { + in, out := &in.OAuth2CodeGrant, &out.OAuth2CodeGrant + *out = new(BindingResponseAuthenticationOAuth2CodeGrant) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingResponseAuthentication. +func (in *BindingResponseAuthentication) DeepCopy() *BindingResponseAuthentication { + if in == nil { + return nil + } + out := new(BindingResponseAuthentication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindingResponseAuthenticationOAuth2CodeGrant) DeepCopyInto(out *BindingResponseAuthenticationOAuth2CodeGrant) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingResponseAuthenticationOAuth2CodeGrant. +func (in *BindingResponseAuthenticationOAuth2CodeGrant) DeepCopy() *BindingResponseAuthenticationOAuth2CodeGrant { + if in == nil { + return nil + } + out := new(BindingResponseAuthenticationOAuth2CodeGrant) + in.DeepCopyInto(out) + 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 + in.AcceptedNames.DeepCopyInto(&out.AcceptedNames) + if in.StoredVersions != nil { + in, out := &in.StoredVersions, &out.StoredVersions + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1alpha1.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 *BoundSchemaReference) DeepCopyInto(out *BoundSchemaReference) { + *out = *in + out.GroupResource = in.GroupResource + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundSchemaReference. +func (in *BoundSchemaReference) DeepCopy() *BoundSchemaReference { + if in == nil { + return nil + } + out := new(BoundSchemaReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CRDVersionSchema) DeepCopyInto(out *CRDVersionSchema) { + *out = *in + in.OpenAPIV3Schema.DeepCopyInto(&out.OpenAPIV3Schema) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDVersionSchema. +func (in *CRDVersionSchema) DeepCopy() *CRDVersionSchema { + if in == nil { + return nil + } + out := new(CRDVersionSchema) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterBinding) DeepCopyInto(out *ClusterBinding) { + *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 ClusterBinding. +func (in *ClusterBinding) DeepCopy() *ClusterBinding { + if in == nil { + return nil + } + out := new(ClusterBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterBinding) 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 *ClusterBindingList) DeepCopyInto(out *ClusterBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterBindingList. +func (in *ClusterBindingList) DeepCopy() *ClusterBindingList { + if in == nil { + return nil + } + out := new(ClusterBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterBindingList) 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 *ClusterBindingSpec) DeepCopyInto(out *ClusterBindingSpec) { + *out = *in + out.KubeconfigSecretRef = in.KubeconfigSecretRef + in.ServiceProviderSpec.DeepCopyInto(&out.ServiceProviderSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterBindingSpec. +func (in *ClusterBindingSpec) DeepCopy() *ClusterBindingSpec { + if in == nil { + return nil + } + out := new(ClusterBindingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterBindingStatus) DeepCopyInto(out *ClusterBindingStatus) { + *out = *in + in.LastHeartbeatTime.DeepCopyInto(&out.LastHeartbeatTime) + out.HeartbeatInterval = in.HeartbeatInterval + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1alpha1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterBindingStatus. +func (in *ClusterBindingStatus) DeepCopy() *ClusterBindingStatus { + if in == nil { + return nil + } + out := new(ClusterBindingStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSecretKeyRef) DeepCopyInto(out *ClusterSecretKeyRef) { + *out = *in + out.LocalSecretKeyRef = in.LocalSecretKeyRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSecretKeyRef. +func (in *ClusterSecretKeyRef) DeepCopy() *ClusterSecretKeyRef { + if in == nil { + return nil + } + out := new(ClusterSecretKeyRef) + 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 + if in.Webhook != nil { + in, out := &in.Webhook, &out.Webhook + *out = new(WebhookConversion) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceConversion. +func (in *CustomResourceConversion) DeepCopy() *CustomResourceConversion { + if in == nil { + return nil + } + out := new(CustomResourceConversion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupResource) DeepCopyInto(out *GroupResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupResource. +func (in *GroupResource) DeepCopy() *GroupResource { + if in == nil { + return nil + } + out := new(GroupResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LocalSecretKeyRef) DeepCopyInto(out *LocalSecretKeyRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalSecretKeyRef. +func (in *LocalSecretKeyRef) DeepCopy() *LocalSecretKeyRef { + if in == nil { + return nil + } + out := new(LocalSecretKeyRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NameObjectMeta) DeepCopyInto(out *NameObjectMeta) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NameObjectMeta. +func (in *NameObjectMeta) DeepCopy() *NameObjectMeta { + if in == nil { + return nil + } + out := new(NameObjectMeta) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OAuth2CodeGrant) DeepCopyInto(out *OAuth2CodeGrant) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OAuth2CodeGrant. +func (in *OAuth2CodeGrant) DeepCopy() *OAuth2CodeGrant { + if in == nil { + return nil + } + out := new(OAuth2CodeGrant) in.DeepCopyInto(out) return out } diff --git a/sdk/apis/third_party/conditions/util/conditions/getter_test.go b/sdk/apis/third_party/conditions/util/conditions/getter_test.go index a74b548b0..2785e1559 100644 --- a/sdk/apis/third_party/conditions/util/conditions/getter_test.go +++ b/sdk/apis/third_party/conditions/util/conditions/getter_test.go @@ -38,9 +38,9 @@ var ( func newConditioned(name string) *conditioned { return &conditioned{ Unstructured: &unstructured.Unstructured{ - Object: map[string]interface{}{ + Object: map[string]any{ "kind": "Foo", - "metadata": map[string]interface{}{ + "metadata": map[string]any{ "name": name, }, }, diff --git a/sdk/apis/third_party/conditions/util/conditions/matcher.go b/sdk/apis/third_party/conditions/util/conditions/matcher.go index fa7e9d718..92bc5e377 100644 --- a/sdk/apis/third_party/conditions/util/conditions/matcher.go +++ b/sdk/apis/third_party/conditions/util/conditions/matcher.go @@ -36,8 +36,8 @@ type matchConditions struct { expected conditionsapi.Conditions } -func (m matchConditions) Match(actual interface{}) (success bool, err error) { - elems := []interface{}{} +func (m matchConditions) Match(actual any) (success bool, err error) { + elems := []any{} for _, condition := range m.expected { elems = append(elems, MatchCondition(condition)) } @@ -45,11 +45,11 @@ func (m matchConditions) Match(actual interface{}) (success bool, err error) { return gomega.ConsistOf(elems).Match(actual) } -func (m matchConditions) FailureMessage(actual interface{}) (message string) { +func (m matchConditions) FailureMessage(actual any) (message string) { return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected) } -func (m matchConditions) NegatedFailureMessage(actual interface{}) (message string) { +func (m matchConditions) NegatedFailureMessage(actual any) (message string) { return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected) } @@ -64,7 +64,7 @@ type matchCondition struct { expected conditionsapi.Condition } -func (m matchCondition) Match(actual interface{}) (success bool, err error) { +func (m matchCondition) Match(actual any) (success bool, err error) { actualCondition, ok := actual.(conditionsapi.Condition) if !ok { return false, fmt.Errorf("actual should be of type Condition") @@ -94,10 +94,10 @@ func (m matchCondition) Match(actual interface{}) (success bool, err error) { return ok, err } -func (m matchCondition) FailureMessage(actual interface{}) (message string) { +func (m matchCondition) FailureMessage(actual any) (message string) { return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected) } -func (m matchCondition) NegatedFailureMessage(actual interface{}) (message string) { +func (m matchCondition) NegatedFailureMessage(actual any) (message string) { return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected) } diff --git a/sdk/apis/third_party/conditions/util/conditions/matcher_test.go b/sdk/apis/third_party/conditions/util/conditions/matcher_test.go index 0636d0f8a..0528d1709 100644 --- a/sdk/apis/third_party/conditions/util/conditions/matcher_test.go +++ b/sdk/apis/third_party/conditions/util/conditions/matcher_test.go @@ -30,7 +30,7 @@ import ( func TestMatchConditions(t *testing.T) { testCases := []struct { name string - actual interface{} + actual any expected conditionsapi.Conditions expectMatch bool }{ @@ -153,7 +153,7 @@ func TestMatchConditions(t *testing.T) { func TestMatchCondition(t *testing.T) { testCases := []struct { name string - actual interface{} + actual any expected conditionsapi.Condition expectMatch bool }{ diff --git a/sdk/apis/third_party/conditions/util/conditions/matchers.go b/sdk/apis/third_party/conditions/util/conditions/matchers.go index 4a002261e..49977a938 100644 --- a/sdk/apis/third_party/conditions/util/conditions/matchers.go +++ b/sdk/apis/third_party/conditions/util/conditions/matchers.go @@ -36,7 +36,7 @@ type conditionMatcher struct { Expected *conditionsapi.Condition } -func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err error) { +func (matcher *conditionMatcher) Match(actual any) (success bool, err error) { actualCondition, ok := actual.(*conditionsapi.Condition) if !ok { return false, errors.New("value should be a condition") @@ -45,9 +45,9 @@ func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err er return hasSameState(actualCondition, matcher.Expected), nil } -func (matcher *conditionMatcher) FailureMessage(actual interface{}) (message string) { +func (matcher *conditionMatcher) FailureMessage(actual any) (message string) { return format.Message(actual, "to have the same state of", matcher.Expected) } -func (matcher *conditionMatcher) NegatedFailureMessage(actual interface{}) (message string) { +func (matcher *conditionMatcher) NegatedFailureMessage(actual any) (message string) { return format.Message(actual, "not to have the same state of", matcher.Expected) } diff --git a/sdk/apis/third_party/conditions/util/conditions/merge_strategies_test.go b/sdk/apis/third_party/conditions/util/conditions/merge_strategies_test.go index 848a0d151..db47e782b 100644 --- a/sdk/apis/third_party/conditions/util/conditions/merge_strategies_test.go +++ b/sdk/apis/third_party/conditions/util/conditions/merge_strategies_test.go @@ -49,9 +49,9 @@ func TestLocalizeReason(t *testing.T) { getter := &conditioned{ Unstructured: &unstructured.Unstructured{ - Object: map[string]interface{}{ + Object: map[string]any{ "kind": "Foo", - "metadata": map[string]interface{}{ + "metadata": map[string]any{ "name": "test-cluster", }, }, @@ -75,9 +75,9 @@ func TestGetFirstReasonAndMessage(t *testing.T) { getter := &conditioned{ Unstructured: &unstructured.Unstructured{ - Object: map[string]interface{}{ + Object: map[string]any{ "kind": "Foo", - "metadata": map[string]interface{}{ + "metadata": map[string]any{ "name": "test-cluster", }, }, diff --git a/sdk/apis/third_party/conditions/util/conditions/patch_test.go b/sdk/apis/third_party/conditions/util/conditions/patch_test.go index 63fb2007b..492e289c9 100644 --- a/sdk/apis/third_party/conditions/util/conditions/patch_test.go +++ b/sdk/apis/third_party/conditions/util/conditions/patch_test.go @@ -264,8 +264,8 @@ func TestApplyDoesNotAlterLastTransitionTime(t *testing.T) { before := newConditioned("test") after := &conditioned{ Unstructured: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "status": map[string]interface{}{ + Object: map[string]any{ + "status": map[string]any{ "conditions": conditionsapi.Conditions{ conditionsapi.Condition{ Type: "foo", diff --git a/sdk/apis/third_party/conditions/util/conditions/setter.go b/sdk/apis/third_party/conditions/util/conditions/setter.go index 2ef953c3c..132260bdd 100644 --- a/sdk/apis/third_party/conditions/util/conditions/setter.go +++ b/sdk/apis/third_party/conditions/util/conditions/setter.go @@ -86,7 +86,7 @@ func TrueCondition(t conditionsapi.ConditionType) *conditionsapi.Condition { } // FalseCondition returns a condition with Status=False and the given type. -func FalseCondition(t conditionsapi.ConditionType, reason string, severity conditionsapi.ConditionSeverity, messageFormat string, messageArgs ...interface{}) *conditionsapi.Condition { +func FalseCondition(t conditionsapi.ConditionType, reason string, severity conditionsapi.ConditionSeverity, messageFormat string, messageArgs ...any) *conditionsapi.Condition { return &conditionsapi.Condition{ Type: t, Status: corev1.ConditionFalse, @@ -97,7 +97,7 @@ func FalseCondition(t conditionsapi.ConditionType, reason string, severity condi } // UnknownCondition returns a condition with Status=Unknown and the given type. -func UnknownCondition(t conditionsapi.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *conditionsapi.Condition { +func UnknownCondition(t conditionsapi.ConditionType, reason string, messageFormat string, messageArgs ...any) *conditionsapi.Condition { return &conditionsapi.Condition{ Type: t, Status: corev1.ConditionUnknown, @@ -112,12 +112,12 @@ func MarkTrue(to Setter, t conditionsapi.ConditionType) { } // MarkUnknown sets Status=Unknown for the condition with the given type. -func MarkUnknown(to Setter, t conditionsapi.ConditionType, reason, messageFormat string, messageArgs ...interface{}) { +func MarkUnknown(to Setter, t conditionsapi.ConditionType, reason, messageFormat string, messageArgs ...any) { Set(to, UnknownCondition(t, reason, messageFormat, messageArgs...)) } // MarkFalse sets Status=False for the condition with the given type. -func MarkFalse(to Setter, t conditionsapi.ConditionType, reason string, severity conditionsapi.ConditionSeverity, messageFormat string, messageArgs ...interface{}) { +func MarkFalse(to Setter, t conditionsapi.ConditionType, reason string, severity conditionsapi.ConditionSeverity, messageFormat string, messageArgs ...any) { Set(to, FalseCondition(t, reason, severity, messageFormat, messageArgs...)) } diff --git a/sdk/apis/third_party/conditions/util/conditions/setter_test.go b/sdk/apis/third_party/conditions/util/conditions/setter_test.go index 638739f59..1a8bbb53b 100644 --- a/sdk/apis/third_party/conditions/util/conditions/setter_test.go +++ b/sdk/apis/third_party/conditions/util/conditions/setter_test.go @@ -272,7 +272,7 @@ type ConditionsMatcher struct { Expected conditionsapi.Conditions } -func (matcher *ConditionsMatcher) Match(actual interface{}) (success bool, err error) { +func (matcher *ConditionsMatcher) Match(actual any) (success bool, err error) { actualConditions, ok := actual.(conditionsapi.Conditions) if !ok { return false, errors.New("value should be a conditions list") @@ -290,9 +290,9 @@ func (matcher *ConditionsMatcher) Match(actual interface{}) (success bool, err e return true, nil } -func (matcher *ConditionsMatcher) FailureMessage(actual interface{}) (message string) { +func (matcher *ConditionsMatcher) FailureMessage(actual any) (message string) { return format.Message(actual, "to have the same conditions of", matcher.Expected) } -func (matcher *ConditionsMatcher) NegatedFailureMessage(actual interface{}) (message string) { +func (matcher *ConditionsMatcher) NegatedFailureMessage(actual any) (message string) { return format.Message(actual, "not to have the same conditions of", matcher.Expected) } diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.go index 501a6a2d4..f5d39689d 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.go @@ -33,7 +33,7 @@ import ( // APIResourceSchemasGetter has a method to return a APIResourceSchemaInterface. // A group's client should implement this interface. type APIResourceSchemasGetter interface { - APIResourceSchemas(namespace string) APIResourceSchemaInterface + APIResourceSchemas() APIResourceSchemaInterface } // APIResourceSchemaInterface has methods to work with APIResourceSchema resources. @@ -55,13 +55,13 @@ type aPIResourceSchemas struct { } // newAPIResourceSchemas returns a APIResourceSchemas -func newAPIResourceSchemas(c *KubeBindV1alpha2Client, namespace string) *aPIResourceSchemas { +func newAPIResourceSchemas(c *KubeBindV1alpha2Client) *aPIResourceSchemas { return &aPIResourceSchemas{ gentype.NewClientWithList[*v1alpha2.APIResourceSchema, *v1alpha2.APIResourceSchemaList]( "apiresourceschemas", c.RESTClient(), scheme.ParameterCodec, - namespace, + "", func() *v1alpha2.APIResourceSchema { return &v1alpha2.APIResourceSchema{} }, func() *v1alpha2.APIResourceSchemaList { return &v1alpha2.APIResourceSchemaList{} }), } diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiservicebinding.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..620ac77a2 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiservicebinding.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" +) + +// APIServiceBindingsGetter has a method to return a APIServiceBindingInterface. +// A group's client should implement this interface. +type APIServiceBindingsGetter interface { + APIServiceBindings() APIServiceBindingInterface +} + +// APIServiceBindingInterface has methods to work with APIServiceBinding resources. +type APIServiceBindingInterface interface { + Create(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.CreateOptions) (*v1alpha2.APIServiceBinding, error) + Update(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (*v1alpha2.APIServiceBinding, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (*v1alpha2.APIServiceBinding, 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.APIServiceBinding, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceBindingList, 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.APIServiceBinding, err error) + APIServiceBindingExpansion +} + +// aPIServiceBindings implements APIServiceBindingInterface +type aPIServiceBindings struct { + *gentype.ClientWithList[*v1alpha2.APIServiceBinding, *v1alpha2.APIServiceBindingList] +} + +// newAPIServiceBindings returns a APIServiceBindings +func newAPIServiceBindings(c *KubeBindV1alpha2Client) *aPIServiceBindings { + return &aPIServiceBindings{ + gentype.NewClientWithList[*v1alpha2.APIServiceBinding, *v1alpha2.APIServiceBindingList]( + "apiservicebindings", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *v1alpha2.APIServiceBinding { return &v1alpha2.APIServiceBinding{} }, + func() *v1alpha2.APIServiceBindingList { return &v1alpha2.APIServiceBindingList{} }), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexport.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..81b40f360 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexport.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" +) + +// APIServiceExportsGetter has a method to return a APIServiceExportInterface. +// A group's client should implement this interface. +type APIServiceExportsGetter interface { + APIServiceExports(namespace string) APIServiceExportInterface +} + +// APIServiceExportInterface has methods to work with APIServiceExport resources. +type APIServiceExportInterface interface { + Create(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.CreateOptions) (*v1alpha2.APIServiceExport, error) + Update(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (*v1alpha2.APIServiceExport, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (*v1alpha2.APIServiceExport, 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.APIServiceExport, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceExportList, 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.APIServiceExport, err error) + APIServiceExportExpansion +} + +// aPIServiceExports implements APIServiceExportInterface +type aPIServiceExports struct { + *gentype.ClientWithList[*v1alpha2.APIServiceExport, *v1alpha2.APIServiceExportList] +} + +// newAPIServiceExports returns a APIServiceExports +func newAPIServiceExports(c *KubeBindV1alpha2Client, namespace string) *aPIServiceExports { + return &aPIServiceExports{ + gentype.NewClientWithList[*v1alpha2.APIServiceExport, *v1alpha2.APIServiceExportList]( + "apiserviceexports", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.APIServiceExport { return &v1alpha2.APIServiceExport{} }, + func() *v1alpha2.APIServiceExportList { return &v1alpha2.APIServiceExportList{} }), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..138ad5b57 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexportrequest.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" +) + +// APIServiceExportRequestsGetter has a method to return a APIServiceExportRequestInterface. +// A group's client should implement this interface. +type APIServiceExportRequestsGetter interface { + APIServiceExportRequests(namespace string) APIServiceExportRequestInterface +} + +// APIServiceExportRequestInterface has methods to work with APIServiceExportRequest resources. +type APIServiceExportRequestInterface interface { + Create(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.CreateOptions) (*v1alpha2.APIServiceExportRequest, error) + Update(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (*v1alpha2.APIServiceExportRequest, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (*v1alpha2.APIServiceExportRequest, 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.APIServiceExportRequest, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceExportRequestList, 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.APIServiceExportRequest, err error) + APIServiceExportRequestExpansion +} + +// aPIServiceExportRequests implements APIServiceExportRequestInterface +type aPIServiceExportRequests struct { + *gentype.ClientWithList[*v1alpha2.APIServiceExportRequest, *v1alpha2.APIServiceExportRequestList] +} + +// newAPIServiceExportRequests returns a APIServiceExportRequests +func newAPIServiceExportRequests(c *KubeBindV1alpha2Client, namespace string) *aPIServiceExportRequests { + return &aPIServiceExportRequests{ + gentype.NewClientWithList[*v1alpha2.APIServiceExportRequest, *v1alpha2.APIServiceExportRequestList]( + "apiserviceexportrequests", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.APIServiceExportRequest { return &v1alpha2.APIServiceExportRequest{} }, + func() *v1alpha2.APIServiceExportRequestList { return &v1alpha2.APIServiceExportRequestList{} }), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiservicenamespace.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..739636de6 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/apiservicenamespace.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" +) + +// APIServiceNamespacesGetter has a method to return a APIServiceNamespaceInterface. +// A group's client should implement this interface. +type APIServiceNamespacesGetter interface { + APIServiceNamespaces(namespace string) APIServiceNamespaceInterface +} + +// APIServiceNamespaceInterface has methods to work with APIServiceNamespace resources. +type APIServiceNamespaceInterface interface { + Create(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.CreateOptions) (*v1alpha2.APIServiceNamespace, error) + Update(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (*v1alpha2.APIServiceNamespace, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (*v1alpha2.APIServiceNamespace, 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.APIServiceNamespace, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceNamespaceList, 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.APIServiceNamespace, err error) + APIServiceNamespaceExpansion +} + +// aPIServiceNamespaces implements APIServiceNamespaceInterface +type aPIServiceNamespaces struct { + *gentype.ClientWithList[*v1alpha2.APIServiceNamespace, *v1alpha2.APIServiceNamespaceList] +} + +// newAPIServiceNamespaces returns a APIServiceNamespaces +func newAPIServiceNamespaces(c *KubeBindV1alpha2Client, namespace string) *aPIServiceNamespaces { + return &aPIServiceNamespaces{ + gentype.NewClientWithList[*v1alpha2.APIServiceNamespace, *v1alpha2.APIServiceNamespaceList]( + "apiservicenamespaces", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.APIServiceNamespace { return &v1alpha2.APIServiceNamespace{} }, + func() *v1alpha2.APIServiceNamespaceList { return &v1alpha2.APIServiceNamespaceList{} }), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/clusterbinding.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..717fd8064 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/clusterbinding.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" +) + +// ClusterBindingsGetter has a method to return a ClusterBindingInterface. +// A group's client should implement this interface. +type ClusterBindingsGetter interface { + ClusterBindings(namespace string) ClusterBindingInterface +} + +// ClusterBindingInterface has methods to work with ClusterBinding resources. +type ClusterBindingInterface interface { + Create(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.CreateOptions) (*v1alpha2.ClusterBinding, error) + Update(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (*v1alpha2.ClusterBinding, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (*v1alpha2.ClusterBinding, 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.ClusterBinding, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ClusterBindingList, 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.ClusterBinding, err error) + ClusterBindingExpansion +} + +// clusterBindings implements ClusterBindingInterface +type clusterBindings struct { + *gentype.ClientWithList[*v1alpha2.ClusterBinding, *v1alpha2.ClusterBindingList] +} + +// newClusterBindings returns a ClusterBindings +func newClusterBindings(c *KubeBindV1alpha2Client, namespace string) *clusterBindings { + return &clusterBindings{ + gentype.NewClientWithList[*v1alpha2.ClusterBinding, *v1alpha2.ClusterBindingList]( + "clusterbindings", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.ClusterBinding { return &v1alpha2.ClusterBinding{} }, + func() *v1alpha2.ClusterBindingList { return &v1alpha2.ClusterBindingList{} }), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go index 6ba06ccb8..f747ed636 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go @@ -33,7 +33,6 @@ import ( // FakeAPIResourceSchemas implements APIResourceSchemaInterface type FakeAPIResourceSchemas struct { Fake *FakeKubeBindV1alpha2 - ns string } var apiresourceschemasResource = v1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas") @@ -44,8 +43,7 @@ var apiresourceschemasKind = v1alpha2.SchemeGroupVersion.WithKind("APIResourceSc func (c *FakeAPIResourceSchemas) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIResourceSchema, err error) { emptyResult := &v1alpha2.APIResourceSchema{} obj, err := c.Fake. - Invokes(testing.NewGetActionWithOptions(apiresourceschemasResource, c.ns, name, options), emptyResult) - + Invokes(testing.NewRootGetActionWithOptions(apiresourceschemasResource, name, options), emptyResult) if obj == nil { return emptyResult, err } @@ -56,8 +54,7 @@ func (c *FakeAPIResourceSchemas) Get(ctx context.Context, name string, options v func (c *FakeAPIResourceSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIResourceSchemaList, err error) { emptyResult := &v1alpha2.APIResourceSchemaList{} obj, err := c.Fake. - Invokes(testing.NewListActionWithOptions(apiresourceschemasResource, apiresourceschemasKind, c.ns, opts), emptyResult) - + Invokes(testing.NewRootListActionWithOptions(apiresourceschemasResource, apiresourceschemasKind, opts), emptyResult) if obj == nil { return emptyResult, err } @@ -78,16 +75,14 @@ func (c *FakeAPIResourceSchemas) List(ctx context.Context, opts v1.ListOptions) // Watch returns a watch.Interface that watches the requested aPIResourceSchemas. func (c *FakeAPIResourceSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchActionWithOptions(apiresourceschemasResource, c.ns, opts)) - + InvokesWatch(testing.NewRootWatchActionWithOptions(apiresourceschemasResource, opts)) } // Create takes the representation of a aPIResourceSchema and creates it. Returns the server's representation of the aPIResourceSchema, and an error, if there is any. func (c *FakeAPIResourceSchemas) Create(ctx context.Context, aPIResourceSchema *v1alpha2.APIResourceSchema, opts v1.CreateOptions) (result *v1alpha2.APIResourceSchema, err error) { emptyResult := &v1alpha2.APIResourceSchema{} obj, err := c.Fake. - Invokes(testing.NewCreateActionWithOptions(apiresourceschemasResource, c.ns, aPIResourceSchema, opts), emptyResult) - + Invokes(testing.NewRootCreateActionWithOptions(apiresourceschemasResource, aPIResourceSchema, opts), emptyResult) if obj == nil { return emptyResult, err } @@ -98,8 +93,7 @@ func (c *FakeAPIResourceSchemas) Create(ctx context.Context, aPIResourceSchema * func (c *FakeAPIResourceSchemas) Update(ctx context.Context, aPIResourceSchema *v1alpha2.APIResourceSchema, opts v1.UpdateOptions) (result *v1alpha2.APIResourceSchema, err error) { emptyResult := &v1alpha2.APIResourceSchema{} obj, err := c.Fake. - Invokes(testing.NewUpdateActionWithOptions(apiresourceschemasResource, c.ns, aPIResourceSchema, opts), emptyResult) - + Invokes(testing.NewRootUpdateActionWithOptions(apiresourceschemasResource, aPIResourceSchema, opts), emptyResult) if obj == nil { return emptyResult, err } @@ -109,14 +103,13 @@ func (c *FakeAPIResourceSchemas) Update(ctx context.Context, aPIResourceSchema * // Delete takes name of the aPIResourceSchema and deletes it. Returns an error if one occurs. func (c *FakeAPIResourceSchemas) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(apiresourceschemasResource, c.ns, name, opts), &v1alpha2.APIResourceSchema{}) - + Invokes(testing.NewRootDeleteActionWithOptions(apiresourceschemasResource, name, opts), &v1alpha2.APIResourceSchema{}) return err } // DeleteCollection deletes a collection of objects. func (c *FakeAPIResourceSchemas) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionActionWithOptions(apiresourceschemasResource, c.ns, opts, listOpts) + action := testing.NewRootDeleteCollectionActionWithOptions(apiresourceschemasResource, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha2.APIResourceSchemaList{}) return err @@ -126,8 +119,7 @@ func (c *FakeAPIResourceSchemas) DeleteCollection(ctx context.Context, opts v1.D func (c *FakeAPIResourceSchemas) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIResourceSchema, err error) { emptyResult := &v1alpha2.APIResourceSchema{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceActionWithOptions(apiresourceschemasResource, c.ns, name, pt, data, opts, subresources...), emptyResult) - + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiresourceschemasResource, name, pt, data, opts, subresources...), emptyResult) if obj == nil { return emptyResult, err } diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicebinding.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicebinding.go new file mode 100644 index 000000000..f88627fdd --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicebinding.go @@ -0,0 +1,139 @@ +/* +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" +) + +// FakeAPIServiceBindings implements APIServiceBindingInterface +type FakeAPIServiceBindings struct { + Fake *FakeKubeBindV1alpha2 +} + +var apiservicebindingsResource = v1alpha2.SchemeGroupVersion.WithResource("apiservicebindings") + +var apiservicebindingsKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceBinding") + +// Get takes name of the aPIServiceBinding, and returns the corresponding aPIServiceBinding object, and an error if there is any. +func (c *FakeAPIServiceBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootGetActionWithOptions(apiservicebindingsResource, name, options), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// List takes label and field selectors, and returns the list of APIServiceBindings that match those selectors. +func (c *FakeAPIServiceBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceBindingList, err error) { + emptyResult := &v1alpha2.APIServiceBindingList{} + obj, err := c.Fake. + Invokes(testing.NewRootListActionWithOptions(apiservicebindingsResource, apiservicebindingsKind, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceBindingList{ListMeta: obj.(*v1alpha2.APIServiceBindingList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceBindingList).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 aPIServiceBindings. +func (c *FakeAPIServiceBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchActionWithOptions(apiservicebindingsResource, opts)) +} + +// Create takes the representation of a aPIServiceBinding and creates it. Returns the server's representation of the aPIServiceBinding, and an error, if there is any. +func (c *FakeAPIServiceBindings) Create(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.CreateOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootCreateActionWithOptions(apiservicebindingsResource, aPIServiceBinding, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// Update takes the representation of a aPIServiceBinding and updates it. Returns the server's representation of the aPIServiceBinding, and an error, if there is any. +func (c *FakeAPIServiceBindings) Update(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootUpdateActionWithOptions(apiservicebindingsResource, aPIServiceBinding, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), 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 *FakeAPIServiceBindings) UpdateStatus(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceActionWithOptions(apiservicebindingsResource, "status", aPIServiceBinding, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// Delete takes name of the aPIServiceBinding and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(apiservicebindingsResource, name, opts), &v1alpha2.APIServiceBinding{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionActionWithOptions(apiservicebindingsResource, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceBindingList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceBinding. +func (c *FakeAPIServiceBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiservicebindingsResource, name, pt, data, opts, subresources...), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexport.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexport.go new file mode 100644 index 000000000..88e0f068b --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexport.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" +) + +// FakeAPIServiceExports implements APIServiceExportInterface +type FakeAPIServiceExports struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var apiserviceexportsResource = v1alpha2.SchemeGroupVersion.WithResource("apiserviceexports") + +var apiserviceexportsKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceExport") + +// Get takes name of the aPIServiceExport, and returns the corresponding aPIServiceExport object, and an error if there is any. +func (c *FakeAPIServiceExports) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apiserviceexportsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// List takes label and field selectors, and returns the list of APIServiceExports that match those selectors. +func (c *FakeAPIServiceExports) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceExportList, err error) { + emptyResult := &v1alpha2.APIServiceExportList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apiserviceexportsResource, apiserviceexportsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceExportList{ListMeta: obj.(*v1alpha2.APIServiceExportList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceExportList).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 aPIServiceExports. +func (c *FakeAPIServiceExports) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apiserviceexportsResource, c.ns, opts)) + +} + +// Create takes the representation of a aPIServiceExport and creates it. Returns the server's representation of the aPIServiceExport, and an error, if there is any. +func (c *FakeAPIServiceExports) Create(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.CreateOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apiserviceexportsResource, c.ns, aPIServiceExport, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// Update takes the representation of a aPIServiceExport and updates it. Returns the server's representation of the aPIServiceExport, and an error, if there is any. +func (c *FakeAPIServiceExports) Update(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apiserviceexportsResource, c.ns, aPIServiceExport, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), 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 *FakeAPIServiceExports) UpdateStatus(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apiserviceexportsResource, "status", c.ns, aPIServiceExport, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// Delete takes name of the aPIServiceExport and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceExports) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apiserviceexportsResource, c.ns, name, opts), &v1alpha2.APIServiceExport{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceExports) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apiserviceexportsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceExportList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceExport. +func (c *FakeAPIServiceExports) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexportrequest.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexportrequest.go new file mode 100644 index 000000000..d5bb1da3f --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexportrequest.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" +) + +// FakeAPIServiceExportRequests implements APIServiceExportRequestInterface +type FakeAPIServiceExportRequests struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var apiserviceexportrequestsResource = v1alpha2.SchemeGroupVersion.WithResource("apiserviceexportrequests") + +var apiserviceexportrequestsKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportRequest") + +// Get takes name of the aPIServiceExportRequest, and returns the corresponding aPIServiceExportRequest object, and an error if there is any. +func (c *FakeAPIServiceExportRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apiserviceexportrequestsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// List takes label and field selectors, and returns the list of APIServiceExportRequests that match those selectors. +func (c *FakeAPIServiceExportRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceExportRequestList, err error) { + emptyResult := &v1alpha2.APIServiceExportRequestList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apiserviceexportrequestsResource, apiserviceexportrequestsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceExportRequestList{ListMeta: obj.(*v1alpha2.APIServiceExportRequestList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceExportRequestList).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 aPIServiceExportRequests. +func (c *FakeAPIServiceExportRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apiserviceexportrequestsResource, c.ns, opts)) + +} + +// Create takes the representation of a aPIServiceExportRequest and creates it. Returns the server's representation of the aPIServiceExportRequest, and an error, if there is any. +func (c *FakeAPIServiceExportRequests) Create(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.CreateOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apiserviceexportrequestsResource, c.ns, aPIServiceExportRequest, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// Update takes the representation of a aPIServiceExportRequest and updates it. Returns the server's representation of the aPIServiceExportRequest, and an error, if there is any. +func (c *FakeAPIServiceExportRequests) Update(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apiserviceexportrequestsResource, c.ns, aPIServiceExportRequest, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), 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 *FakeAPIServiceExportRequests) UpdateStatus(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apiserviceexportrequestsResource, "status", c.ns, aPIServiceExportRequest, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// Delete takes name of the aPIServiceExportRequest and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceExportRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apiserviceexportrequestsResource, c.ns, name, opts), &v1alpha2.APIServiceExportRequest{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceExportRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apiserviceexportrequestsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceExportRequestList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceExportRequest. +func (c *FakeAPIServiceExportRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportrequestsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicenamespace.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicenamespace.go new file mode 100644 index 000000000..56e908710 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicenamespace.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" +) + +// FakeAPIServiceNamespaces implements APIServiceNamespaceInterface +type FakeAPIServiceNamespaces struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var apiservicenamespacesResource = v1alpha2.SchemeGroupVersion.WithResource("apiservicenamespaces") + +var apiservicenamespacesKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceNamespace") + +// Get takes name of the aPIServiceNamespace, and returns the corresponding aPIServiceNamespace object, and an error if there is any. +func (c *FakeAPIServiceNamespaces) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apiservicenamespacesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// List takes label and field selectors, and returns the list of APIServiceNamespaces that match those selectors. +func (c *FakeAPIServiceNamespaces) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceNamespaceList, err error) { + emptyResult := &v1alpha2.APIServiceNamespaceList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apiservicenamespacesResource, apiservicenamespacesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceNamespaceList{ListMeta: obj.(*v1alpha2.APIServiceNamespaceList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceNamespaceList).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 aPIServiceNamespaces. +func (c *FakeAPIServiceNamespaces) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apiservicenamespacesResource, c.ns, opts)) + +} + +// Create takes the representation of a aPIServiceNamespace and creates it. Returns the server's representation of the aPIServiceNamespace, and an error, if there is any. +func (c *FakeAPIServiceNamespaces) Create(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.CreateOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apiservicenamespacesResource, c.ns, aPIServiceNamespace, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// Update takes the representation of a aPIServiceNamespace and updates it. Returns the server's representation of the aPIServiceNamespace, and an error, if there is any. +func (c *FakeAPIServiceNamespaces) Update(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apiservicenamespacesResource, c.ns, aPIServiceNamespace, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), 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 *FakeAPIServiceNamespaces) UpdateStatus(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apiservicenamespacesResource, "status", c.ns, aPIServiceNamespace, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// Delete takes name of the aPIServiceNamespace and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceNamespaces) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apiservicenamespacesResource, c.ns, name, opts), &v1alpha2.APIServiceNamespace{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceNamespaces) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apiservicenamespacesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceNamespaceList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceNamespace. +func (c *FakeAPIServiceNamespaces) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiservicenamespacesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_clusterbinding.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_clusterbinding.go new file mode 100644 index 000000000..2afc19b47 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_clusterbinding.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" +) + +// FakeClusterBindings implements ClusterBindingInterface +type FakeClusterBindings struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var clusterbindingsResource = v1alpha2.SchemeGroupVersion.WithResource("clusterbindings") + +var clusterbindingsKind = v1alpha2.SchemeGroupVersion.WithKind("ClusterBinding") + +// Get takes name of the clusterBinding, and returns the corresponding clusterBinding object, and an error if there is any. +func (c *FakeClusterBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(clusterbindingsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// List takes label and field selectors, and returns the list of ClusterBindings that match those selectors. +func (c *FakeClusterBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ClusterBindingList, err error) { + emptyResult := &v1alpha2.ClusterBindingList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(clusterbindingsResource, clusterbindingsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.ClusterBindingList{ListMeta: obj.(*v1alpha2.ClusterBindingList).ListMeta} + for _, item := range obj.(*v1alpha2.ClusterBindingList).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 clusterBindings. +func (c *FakeClusterBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(clusterbindingsResource, c.ns, opts)) + +} + +// Create takes the representation of a clusterBinding and creates it. Returns the server's representation of the clusterBinding, and an error, if there is any. +func (c *FakeClusterBindings) Create(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.CreateOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(clusterbindingsResource, c.ns, clusterBinding, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// Update takes the representation of a clusterBinding and updates it. Returns the server's representation of the clusterBinding, and an error, if there is any. +func (c *FakeClusterBindings) Update(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(clusterbindingsResource, c.ns, clusterBinding, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), 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 *FakeClusterBindings) UpdateStatus(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(clusterbindingsResource, "status", c.ns, clusterBinding, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// Delete takes name of the clusterBinding and deletes it. Returns an error if one occurs. +func (c *FakeClusterBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(clusterbindingsResource, c.ns, name, opts), &v1alpha2.ClusterBinding{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(clusterbindingsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.ClusterBindingList{}) + return err +} + +// Patch applies the patch and returns the patched clusterBinding. +func (c *FakeClusterBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(clusterbindingsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), 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 3ca3482d0..b9e504d65 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 @@ -29,14 +29,34 @@ type FakeKubeBindV1alpha2 struct { *testing.Fake } -func (c *FakeKubeBindV1alpha2) APIResourceSchemas(namespace string) v1alpha2.APIResourceSchemaInterface { - return &FakeAPIResourceSchemas{c, namespace} +func (c *FakeKubeBindV1alpha2) APIResourceSchemas() v1alpha2.APIResourceSchemaInterface { + return &FakeAPIResourceSchemas{c} +} + +func (c *FakeKubeBindV1alpha2) APIServiceBindings() v1alpha2.APIServiceBindingInterface { + return &FakeAPIServiceBindings{c} +} + +func (c *FakeKubeBindV1alpha2) APIServiceExports(namespace string) v1alpha2.APIServiceExportInterface { + return &FakeAPIServiceExports{c, namespace} +} + +func (c *FakeKubeBindV1alpha2) APIServiceExportRequests(namespace string) v1alpha2.APIServiceExportRequestInterface { + return &FakeAPIServiceExportRequests{c, namespace} +} + +func (c *FakeKubeBindV1alpha2) APIServiceNamespaces(namespace string) v1alpha2.APIServiceNamespaceInterface { + return &FakeAPIServiceNamespaces{c, namespace} } func (c *FakeKubeBindV1alpha2) BoundAPIResourceSchemas(namespace string) v1alpha2.BoundAPIResourceSchemaInterface { return &FakeBoundAPIResourceSchemas{c, namespace} } +func (c *FakeKubeBindV1alpha2) ClusterBindings(namespace string) v1alpha2.ClusterBindingInterface { + return &FakeClusterBindings{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 12bb2639e..5c2fd1ed5 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go @@ -20,4 +20,14 @@ package v1alpha2 type APIResourceSchemaExpansion interface{} +type APIServiceBindingExpansion interface{} + +type APIServiceExportExpansion interface{} + +type APIServiceExportRequestExpansion interface{} + +type APIServiceNamespaceExpansion interface{} + type BoundAPIResourceSchemaExpansion interface{} + +type ClusterBindingExpansion 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 22b850465..e47702f72 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go @@ -30,7 +30,12 @@ import ( type KubeBindV1alpha2Interface interface { RESTClient() rest.Interface APIResourceSchemasGetter + APIServiceBindingsGetter + APIServiceExportsGetter + APIServiceExportRequestsGetter + APIServiceNamespacesGetter BoundAPIResourceSchemasGetter + ClusterBindingsGetter } // KubeBindV1alpha2Client is used to interact with features provided by the kube-bind.io group. @@ -38,14 +43,34 @@ type KubeBindV1alpha2Client struct { restClient rest.Interface } -func (c *KubeBindV1alpha2Client) APIResourceSchemas(namespace string) APIResourceSchemaInterface { - return newAPIResourceSchemas(c, namespace) +func (c *KubeBindV1alpha2Client) APIResourceSchemas() APIResourceSchemaInterface { + return newAPIResourceSchemas(c) +} + +func (c *KubeBindV1alpha2Client) APIServiceBindings() APIServiceBindingInterface { + return newAPIServiceBindings(c) +} + +func (c *KubeBindV1alpha2Client) APIServiceExports(namespace string) APIServiceExportInterface { + return newAPIServiceExports(c, namespace) +} + +func (c *KubeBindV1alpha2Client) APIServiceExportRequests(namespace string) APIServiceExportRequestInterface { + return newAPIServiceExportRequests(c, namespace) +} + +func (c *KubeBindV1alpha2Client) APIServiceNamespaces(namespace string) APIServiceNamespaceInterface { + return newAPIServiceNamespaces(c, namespace) } func (c *KubeBindV1alpha2Client) BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaInterface { return newBoundAPIResourceSchemas(c, namespace) } +func (c *KubeBindV1alpha2Client) ClusterBindings(namespace string) ClusterBindingInterface { + return newClusterBindings(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 c1257c790..ba505b1cc 100644 --- a/sdk/client/informers/externalversions/generic.go +++ b/sdk/client/informers/externalversions/generic.go @@ -69,8 +69,18 @@ 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("apiservicebindings"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceBindings().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("apiserviceexports"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceExports().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("apiserviceexportrequests"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceExportRequests().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("apiservicenamespaces"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceNamespaces().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas"): return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().BoundAPIResourceSchemas().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("clusterbindings"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().ClusterBindings().Informer()}, nil } diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go index dd8e23ef0..48a248c3d 100644 --- a/sdk/client/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go @@ -43,33 +43,32 @@ type APIResourceSchemaInformer interface { type aPIResourceSchemaInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string } // NewAPIResourceSchemaInformer constructs a new informer for APIResourceSchema 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 NewAPIResourceSchemaInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredAPIResourceSchemaInformer(client, namespace, resyncPeriod, indexers, nil) +func NewAPIResourceSchemaInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIResourceSchemaInformer(client, resyncPeriod, indexers, nil) } // NewFilteredAPIResourceSchemaInformer constructs a new informer for APIResourceSchema 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 NewFilteredAPIResourceSchemaInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredAPIResourceSchemaInformer(client versioned.Interface, 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().APIResourceSchemas(namespace).List(context.TODO(), options) + return client.KubeBindV1alpha2().APIResourceSchemas().List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.KubeBindV1alpha2().APIResourceSchemas(namespace).Watch(context.TODO(), options) + return client.KubeBindV1alpha2().APIResourceSchemas().Watch(context.TODO(), options) }, }, &kubebindv1alpha2.APIResourceSchema{}, @@ -79,7 +78,7 @@ func NewFilteredAPIResourceSchemaInformer(client versioned.Interface, namespace } func (f *aPIResourceSchemaInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredAPIResourceSchemaInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) + return NewFilteredAPIResourceSchemaInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } func (f *aPIResourceSchemaInformer) Informer() cache.SharedIndexInformer { diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/apiservicebinding.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..3fcffbae8 --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,90 @@ +/* +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" +) + +// APIServiceBindingInformer provides access to a shared informer and lister for +// APIServiceBindings. +type APIServiceBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.APIServiceBindingLister +} + +type aPIServiceBindingInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewAPIServiceBindingInformer constructs a new informer for APIServiceBinding 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 NewAPIServiceBindingInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceBindingInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceBindingInformer constructs a new informer for APIServiceBinding 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 NewFilteredAPIServiceBindingInformer(client versioned.Interface, 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().APIServiceBindings().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceBindings().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceBindingInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *aPIServiceBindingInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceBinding{}, f.defaultInformer) +} + +func (f *aPIServiceBindingInformer) Lister() v1alpha2.APIServiceBindingLister { + return v1alpha2.NewAPIServiceBindingLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/apiserviceexport.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..e1075d5b4 --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiserviceexport.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" +) + +// APIServiceExportInformer provides access to a shared informer and lister for +// APIServiceExports. +type APIServiceExportInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.APIServiceExportLister +} + +type aPIServiceExportInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewAPIServiceExportInformer constructs a new informer for APIServiceExport 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 NewAPIServiceExportInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceExportInformer constructs a new informer for APIServiceExport 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 NewFilteredAPIServiceExportInformer(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().APIServiceExports(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceExports(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceExport{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceExportInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *aPIServiceExportInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceExport{}, f.defaultInformer) +} + +func (f *aPIServiceExportInformer) Lister() v1alpha2.APIServiceExportLister { + return v1alpha2.NewAPIServiceExportLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..e8bc50c1f --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiserviceexportrequest.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" +) + +// APIServiceExportRequestInformer provides access to a shared informer and lister for +// APIServiceExportRequests. +type APIServiceExportRequestInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.APIServiceExportRequestLister +} + +type aPIServiceExportRequestInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewAPIServiceExportRequestInformer constructs a new informer for APIServiceExportRequest 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 NewAPIServiceExportRequestInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportRequestInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceExportRequestInformer constructs a new informer for APIServiceExportRequest 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 NewFilteredAPIServiceExportRequestInformer(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().APIServiceExportRequests(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceExportRequests(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceExportRequest{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceExportRequestInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportRequestInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *aPIServiceExportRequestInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceExportRequest{}, f.defaultInformer) +} + +func (f *aPIServiceExportRequestInformer) Lister() v1alpha2.APIServiceExportRequestLister { + return v1alpha2.NewAPIServiceExportRequestLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/apiservicenamespace.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..d293dfc05 --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/apiservicenamespace.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" +) + +// APIServiceNamespaceInformer provides access to a shared informer and lister for +// APIServiceNamespaces. +type APIServiceNamespaceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.APIServiceNamespaceLister +} + +type aPIServiceNamespaceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewAPIServiceNamespaceInformer constructs a new informer for APIServiceNamespace 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 NewAPIServiceNamespaceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceNamespaceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceNamespaceInformer constructs a new informer for APIServiceNamespace 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 NewFilteredAPIServiceNamespaceInformer(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().APIServiceNamespaces(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceNamespaces(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceNamespace{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceNamespaceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceNamespaceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *aPIServiceNamespaceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceNamespace{}, f.defaultInformer) +} + +func (f *aPIServiceNamespaceInformer) Lister() v1alpha2.APIServiceNamespaceLister { + return v1alpha2.NewAPIServiceNamespaceLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/clusterbinding.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..a204f4cf6 --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/clusterbinding.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" +) + +// ClusterBindingInformer provides access to a shared informer and lister for +// ClusterBindings. +type ClusterBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.ClusterBindingLister +} + +type clusterBindingInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewClusterBindingInformer constructs a new informer for ClusterBinding 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 NewClusterBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterBindingInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterBindingInformer constructs a new informer for ClusterBinding 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 NewFilteredClusterBindingInformer(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().ClusterBindings(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().ClusterBindings(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.ClusterBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterBindingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterBindingInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.ClusterBinding{}, f.defaultInformer) +} + +func (f *clusterBindingInformer) Lister() v1alpha2.ClusterBindingLister { + return v1alpha2.NewClusterBindingLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go index 1ee726c9e..68bf0f176 100644 --- a/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go @@ -26,8 +26,18 @@ import ( type Interface interface { // APIResourceSchemas returns a APIResourceSchemaInformer. APIResourceSchemas() APIResourceSchemaInformer + // APIServiceBindings returns a APIServiceBindingInformer. + APIServiceBindings() APIServiceBindingInformer + // APIServiceExports returns a APIServiceExportInformer. + APIServiceExports() APIServiceExportInformer + // APIServiceExportRequests returns a APIServiceExportRequestInformer. + APIServiceExportRequests() APIServiceExportRequestInformer + // APIServiceNamespaces returns a APIServiceNamespaceInformer. + APIServiceNamespaces() APIServiceNamespaceInformer // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaInformer. BoundAPIResourceSchemas() BoundAPIResourceSchemaInformer + // ClusterBindings returns a ClusterBindingInformer. + ClusterBindings() ClusterBindingInformer } type version struct { @@ -43,10 +53,35 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList // APIResourceSchemas returns a APIResourceSchemaInformer. func (v *version) APIResourceSchemas() APIResourceSchemaInformer { - return &aPIResourceSchemaInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} + return &aPIResourceSchemaInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceBindings returns a APIServiceBindingInformer. +func (v *version) APIServiceBindings() APIServiceBindingInformer { + return &aPIServiceBindingInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceExports returns a APIServiceExportInformer. +func (v *version) APIServiceExports() APIServiceExportInformer { + return &aPIServiceExportInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// APIServiceExportRequests returns a APIServiceExportRequestInformer. +func (v *version) APIServiceExportRequests() APIServiceExportRequestInformer { + return &aPIServiceExportRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// APIServiceNamespaces returns a APIServiceNamespaceInformer. +func (v *version) APIServiceNamespaces() APIServiceNamespaceInformer { + return &aPIServiceNamespaceInformer{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} } + +// ClusterBindings returns a ClusterBindingInformer. +func (v *version) ClusterBindings() ClusterBindingInformer { + return &clusterBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/sdk/client/listers/kubebind/v1alpha2/apiresourceschema.go b/sdk/client/listers/kubebind/v1alpha2/apiresourceschema.go index f3cdcdac1..f85a54dd9 100644 --- a/sdk/client/listers/kubebind/v1alpha2/apiresourceschema.go +++ b/sdk/client/listers/kubebind/v1alpha2/apiresourceschema.go @@ -32,8 +32,9 @@ type APIResourceSchemaLister interface { // List lists all APIResourceSchemas in the indexer. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1alpha2.APIResourceSchema, err error) - // APIResourceSchemas returns an object that can list and get APIResourceSchemas. - APIResourceSchemas(namespace string) APIResourceSchemaNamespaceLister + // Get retrieves the APIResourceSchema from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.APIResourceSchema, error) APIResourceSchemaListerExpansion } @@ -46,26 +47,3 @@ type aPIResourceSchemaLister struct { func NewAPIResourceSchemaLister(indexer cache.Indexer) APIResourceSchemaLister { return &aPIResourceSchemaLister{listers.New[*v1alpha2.APIResourceSchema](indexer, v1alpha2.Resource("apiresourceschema"))} } - -// APIResourceSchemas returns an object that can list and get APIResourceSchemas. -func (s *aPIResourceSchemaLister) APIResourceSchemas(namespace string) APIResourceSchemaNamespaceLister { - return aPIResourceSchemaNamespaceLister{listers.NewNamespaced[*v1alpha2.APIResourceSchema](s.ResourceIndexer, namespace)} -} - -// APIResourceSchemaNamespaceLister helps list and get APIResourceSchemas. -// All objects returned here must be treated as read-only. -type APIResourceSchemaNamespaceLister interface { - // List lists all APIResourceSchemas in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha2.APIResourceSchema, err error) - // Get retrieves the APIResourceSchema from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha2.APIResourceSchema, error) - APIResourceSchemaNamespaceListerExpansion -} - -// aPIResourceSchemaNamespaceLister implements the APIResourceSchemaNamespaceLister -// interface. -type aPIResourceSchemaNamespaceLister struct { - listers.ResourceIndexer[*v1alpha2.APIResourceSchema] -} diff --git a/sdk/client/listers/kubebind/v1alpha2/apiservicebinding.go b/sdk/client/listers/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..04daf494b --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,49 @@ +/* +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" +) + +// APIServiceBindingLister helps list APIServiceBindings. +// All objects returned here must be treated as read-only. +type APIServiceBindingLister interface { + // List lists all APIServiceBindings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceBinding, err error) + // Get retrieves the APIServiceBinding from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.APIServiceBinding, error) + APIServiceBindingListerExpansion +} + +// aPIServiceBindingLister implements the APIServiceBindingLister interface. +type aPIServiceBindingLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceBinding] +} + +// NewAPIServiceBindingLister returns a new APIServiceBindingLister. +func NewAPIServiceBindingLister(indexer cache.Indexer) APIServiceBindingLister { + return &aPIServiceBindingLister{listers.New[*v1alpha2.APIServiceBinding](indexer, v1alpha2.Resource("apiservicebinding"))} +} diff --git a/sdk/client/listers/kubebind/v1alpha2/apiserviceexport.go b/sdk/client/listers/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..9496a5eff --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/apiserviceexport.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" +) + +// APIServiceExportLister helps list APIServiceExports. +// All objects returned here must be treated as read-only. +type APIServiceExportLister interface { + // List lists all APIServiceExports in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceExport, err error) + // APIServiceExports returns an object that can list and get APIServiceExports. + APIServiceExports(namespace string) APIServiceExportNamespaceLister + APIServiceExportListerExpansion +} + +// aPIServiceExportLister implements the APIServiceExportLister interface. +type aPIServiceExportLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceExport] +} + +// NewAPIServiceExportLister returns a new APIServiceExportLister. +func NewAPIServiceExportLister(indexer cache.Indexer) APIServiceExportLister { + return &aPIServiceExportLister{listers.New[*v1alpha2.APIServiceExport](indexer, v1alpha2.Resource("apiserviceexport"))} +} + +// APIServiceExports returns an object that can list and get APIServiceExports. +func (s *aPIServiceExportLister) APIServiceExports(namespace string) APIServiceExportNamespaceLister { + return aPIServiceExportNamespaceLister{listers.NewNamespaced[*v1alpha2.APIServiceExport](s.ResourceIndexer, namespace)} +} + +// APIServiceExportNamespaceLister helps list and get APIServiceExports. +// All objects returned here must be treated as read-only. +type APIServiceExportNamespaceLister interface { + // List lists all APIServiceExports in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceExport, err error) + // Get retrieves the APIServiceExport from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.APIServiceExport, error) + APIServiceExportNamespaceListerExpansion +} + +// aPIServiceExportNamespaceLister implements the APIServiceExportNamespaceLister +// interface. +type aPIServiceExportNamespaceLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceExport] +} diff --git a/sdk/client/listers/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/client/listers/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..10c93b545 --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/apiserviceexportrequest.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" +) + +// APIServiceExportRequestLister helps list APIServiceExportRequests. +// All objects returned here must be treated as read-only. +type APIServiceExportRequestLister interface { + // List lists all APIServiceExportRequests in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceExportRequest, err error) + // APIServiceExportRequests returns an object that can list and get APIServiceExportRequests. + APIServiceExportRequests(namespace string) APIServiceExportRequestNamespaceLister + APIServiceExportRequestListerExpansion +} + +// aPIServiceExportRequestLister implements the APIServiceExportRequestLister interface. +type aPIServiceExportRequestLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceExportRequest] +} + +// NewAPIServiceExportRequestLister returns a new APIServiceExportRequestLister. +func NewAPIServiceExportRequestLister(indexer cache.Indexer) APIServiceExportRequestLister { + return &aPIServiceExportRequestLister{listers.New[*v1alpha2.APIServiceExportRequest](indexer, v1alpha2.Resource("apiserviceexportrequest"))} +} + +// APIServiceExportRequests returns an object that can list and get APIServiceExportRequests. +func (s *aPIServiceExportRequestLister) APIServiceExportRequests(namespace string) APIServiceExportRequestNamespaceLister { + return aPIServiceExportRequestNamespaceLister{listers.NewNamespaced[*v1alpha2.APIServiceExportRequest](s.ResourceIndexer, namespace)} +} + +// APIServiceExportRequestNamespaceLister helps list and get APIServiceExportRequests. +// All objects returned here must be treated as read-only. +type APIServiceExportRequestNamespaceLister interface { + // List lists all APIServiceExportRequests in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceExportRequest, err error) + // Get retrieves the APIServiceExportRequest from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.APIServiceExportRequest, error) + APIServiceExportRequestNamespaceListerExpansion +} + +// aPIServiceExportRequestNamespaceLister implements the APIServiceExportRequestNamespaceLister +// interface. +type aPIServiceExportRequestNamespaceLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceExportRequest] +} diff --git a/sdk/client/listers/kubebind/v1alpha2/apiservicenamespace.go b/sdk/client/listers/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..4dfdaa3a7 --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/apiservicenamespace.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" +) + +// APIServiceNamespaceLister helps list APIServiceNamespaces. +// All objects returned here must be treated as read-only. +type APIServiceNamespaceLister interface { + // List lists all APIServiceNamespaces in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceNamespace, err error) + // APIServiceNamespaces returns an object that can list and get APIServiceNamespaces. + APIServiceNamespaces(namespace string) APIServiceNamespaceNamespaceLister + APIServiceNamespaceListerExpansion +} + +// aPIServiceNamespaceLister implements the APIServiceNamespaceLister interface. +type aPIServiceNamespaceLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceNamespace] +} + +// NewAPIServiceNamespaceLister returns a new APIServiceNamespaceLister. +func NewAPIServiceNamespaceLister(indexer cache.Indexer) APIServiceNamespaceLister { + return &aPIServiceNamespaceLister{listers.New[*v1alpha2.APIServiceNamespace](indexer, v1alpha2.Resource("apiservicenamespace"))} +} + +// APIServiceNamespaces returns an object that can list and get APIServiceNamespaces. +func (s *aPIServiceNamespaceLister) APIServiceNamespaces(namespace string) APIServiceNamespaceNamespaceLister { + return aPIServiceNamespaceNamespaceLister{listers.NewNamespaced[*v1alpha2.APIServiceNamespace](s.ResourceIndexer, namespace)} +} + +// APIServiceNamespaceNamespaceLister helps list and get APIServiceNamespaces. +// All objects returned here must be treated as read-only. +type APIServiceNamespaceNamespaceLister interface { + // List lists all APIServiceNamespaces in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.APIServiceNamespace, err error) + // Get retrieves the APIServiceNamespace from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.APIServiceNamespace, error) + APIServiceNamespaceNamespaceListerExpansion +} + +// aPIServiceNamespaceNamespaceLister implements the APIServiceNamespaceNamespaceLister +// interface. +type aPIServiceNamespaceNamespaceLister struct { + listers.ResourceIndexer[*v1alpha2.APIServiceNamespace] +} diff --git a/sdk/client/listers/kubebind/v1alpha2/clusterbinding.go b/sdk/client/listers/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..211872ab4 --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/clusterbinding.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" +) + +// ClusterBindingLister helps list ClusterBindings. +// All objects returned here must be treated as read-only. +type ClusterBindingLister interface { + // List lists all ClusterBindings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.ClusterBinding, err error) + // ClusterBindings returns an object that can list and get ClusterBindings. + ClusterBindings(namespace string) ClusterBindingNamespaceLister + ClusterBindingListerExpansion +} + +// clusterBindingLister implements the ClusterBindingLister interface. +type clusterBindingLister struct { + listers.ResourceIndexer[*v1alpha2.ClusterBinding] +} + +// NewClusterBindingLister returns a new ClusterBindingLister. +func NewClusterBindingLister(indexer cache.Indexer) ClusterBindingLister { + return &clusterBindingLister{listers.New[*v1alpha2.ClusterBinding](indexer, v1alpha2.Resource("clusterbinding"))} +} + +// ClusterBindings returns an object that can list and get ClusterBindings. +func (s *clusterBindingLister) ClusterBindings(namespace string) ClusterBindingNamespaceLister { + return clusterBindingNamespaceLister{listers.NewNamespaced[*v1alpha2.ClusterBinding](s.ResourceIndexer, namespace)} +} + +// ClusterBindingNamespaceLister helps list and get ClusterBindings. +// All objects returned here must be treated as read-only. +type ClusterBindingNamespaceLister interface { + // List lists all ClusterBindings in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.ClusterBinding, err error) + // Get retrieves the ClusterBinding from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.ClusterBinding, error) + ClusterBindingNamespaceListerExpansion +} + +// clusterBindingNamespaceLister implements the ClusterBindingNamespaceLister +// interface. +type clusterBindingNamespaceLister struct { + listers.ResourceIndexer[*v1alpha2.ClusterBinding] +} diff --git a/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go b/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go index 96d5c4aca..a8959ba58 100644 --- a/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go +++ b/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go @@ -22,9 +22,33 @@ package v1alpha2 // APIResourceSchemaLister. type APIResourceSchemaListerExpansion interface{} -// APIResourceSchemaNamespaceListerExpansion allows custom methods to be added to -// APIResourceSchemaNamespaceLister. -type APIResourceSchemaNamespaceListerExpansion interface{} +// APIServiceBindingListerExpansion allows custom methods to be added to +// APIServiceBindingLister. +type APIServiceBindingListerExpansion interface{} + +// APIServiceExportListerExpansion allows custom methods to be added to +// APIServiceExportLister. +type APIServiceExportListerExpansion interface{} + +// APIServiceExportNamespaceListerExpansion allows custom methods to be added to +// APIServiceExportNamespaceLister. +type APIServiceExportNamespaceListerExpansion interface{} + +// APIServiceExportRequestListerExpansion allows custom methods to be added to +// APIServiceExportRequestLister. +type APIServiceExportRequestListerExpansion interface{} + +// APIServiceExportRequestNamespaceListerExpansion allows custom methods to be added to +// APIServiceExportRequestNamespaceLister. +type APIServiceExportRequestNamespaceListerExpansion interface{} + +// APIServiceNamespaceListerExpansion allows custom methods to be added to +// APIServiceNamespaceLister. +type APIServiceNamespaceListerExpansion interface{} + +// APIServiceNamespaceNamespaceListerExpansion allows custom methods to be added to +// APIServiceNamespaceNamespaceLister. +type APIServiceNamespaceNamespaceListerExpansion interface{} // BoundAPIResourceSchemaListerExpansion allows custom methods to be added to // BoundAPIResourceSchemaLister. @@ -33,3 +57,11 @@ type BoundAPIResourceSchemaListerExpansion interface{} // BoundAPIResourceSchemaNamespaceListerExpansion allows custom methods to be added to // BoundAPIResourceSchemaNamespaceLister. type BoundAPIResourceSchemaNamespaceListerExpansion interface{} + +// ClusterBindingListerExpansion allows custom methods to be added to +// ClusterBindingLister. +type ClusterBindingListerExpansion interface{} + +// ClusterBindingNamespaceListerExpansion allows custom methods to be added to +// ClusterBindingNamespaceLister. +type ClusterBindingNamespaceListerExpansion interface{} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschema.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschema.go new file mode 100644 index 000000000..132d5bfa2 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschema.go @@ -0,0 +1,216 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// APIResourceSchemaApplyConfiguration represents a declarative configuration of the APIResourceSchema type for use +// with apply. +type APIResourceSchemaApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *APIResourceSchemaSpecApplyConfiguration `json:"spec,omitempty"` +} + +// APIResourceSchema constructs a declarative configuration of the APIResourceSchema type for use with +// apply. +func APIResourceSchema(name string) *APIResourceSchemaApplyConfiguration { + b := &APIResourceSchemaApplyConfiguration{} + b.WithName(name) + b.WithKind("APIResourceSchema") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithKind(value string) *APIResourceSchemaApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithAPIVersion(value string) *APIResourceSchemaApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithName(value string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithGenerateName(value string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithNamespace(value string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithUID(value types.UID) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithResourceVersion(value string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithGeneration(value int64) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithCreationTimestamp(value metav1.Time) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *APIResourceSchemaApplyConfiguration) WithLabels(entries map[string]string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *APIResourceSchemaApplyConfiguration) WithAnnotations(entries map[string]string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *APIResourceSchemaApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *APIResourceSchemaApplyConfiguration) WithFinalizers(values ...string) *APIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *APIResourceSchemaApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *APIResourceSchemaApplyConfiguration) WithSpec(value *APIResourceSchemaSpecApplyConfiguration) *APIResourceSchemaApplyConfiguration { + b.Spec = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIResourceSchemaApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemacrdspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemacrdspec.go new file mode 100644 index 000000000..e907293ec --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemacrdspec.go @@ -0,0 +1,84 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" +) + +// APIResourceSchemaCRDSpecApplyConfiguration represents a declarative configuration of the APIResourceSchemaCRDSpec type for use +// with apply. +type APIResourceSchemaCRDSpecApplyConfiguration struct { + Group *string `json:"group,omitempty"` + Names *v1.CustomResourceDefinitionNames `json:"names,omitempty"` + Scope *v1.ResourceScope `json:"scope,omitempty"` + Versions []APIResourceVersionApplyConfiguration `json:"versions,omitempty"` + Conversion *CustomResourceConversionApplyConfiguration `json:"conversion,omitempty"` +} + +// APIResourceSchemaCRDSpecApplyConfiguration constructs a declarative configuration of the APIResourceSchemaCRDSpec type for use with +// apply. +func APIResourceSchemaCRDSpec() *APIResourceSchemaCRDSpecApplyConfiguration { + return &APIResourceSchemaCRDSpecApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *APIResourceSchemaCRDSpecApplyConfiguration) WithGroup(value string) *APIResourceSchemaCRDSpecApplyConfiguration { + b.Group = &value + return b +} + +// WithNames sets the Names field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Names field is set to the value of the last call. +func (b *APIResourceSchemaCRDSpecApplyConfiguration) WithNames(value v1.CustomResourceDefinitionNames) *APIResourceSchemaCRDSpecApplyConfiguration { + b.Names = &value + return b +} + +// WithScope sets the Scope field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Scope field is set to the value of the last call. +func (b *APIResourceSchemaCRDSpecApplyConfiguration) WithScope(value v1.ResourceScope) *APIResourceSchemaCRDSpecApplyConfiguration { + b.Scope = &value + return b +} + +// WithVersions adds the given value to the Versions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Versions field. +func (b *APIResourceSchemaCRDSpecApplyConfiguration) WithVersions(values ...*APIResourceVersionApplyConfiguration) *APIResourceSchemaCRDSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithVersions") + } + b.Versions = append(b.Versions, *values[i]) + } + return b +} + +// WithConversion sets the Conversion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conversion field is set to the value of the last call. +func (b *APIResourceSchemaCRDSpecApplyConfiguration) WithConversion(value *CustomResourceConversionApplyConfiguration) *APIResourceSchemaCRDSpecApplyConfiguration { + b.Conversion = value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemareference.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemareference.go new file mode 100644 index 000000000..aeae9b5cd --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemareference.go @@ -0,0 +1,48 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// APIResourceSchemaReferenceApplyConfiguration represents a declarative configuration of the APIResourceSchemaReference type for use +// with apply. +type APIResourceSchemaReferenceApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// APIResourceSchemaReferenceApplyConfiguration constructs a declarative configuration of the APIResourceSchemaReference type for use with +// apply. +func APIResourceSchemaReference() *APIResourceSchemaReferenceApplyConfiguration { + return &APIResourceSchemaReferenceApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIResourceSchemaReferenceApplyConfiguration) WithName(value string) *APIResourceSchemaReferenceApplyConfiguration { + b.Name = &value + return b +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *APIResourceSchemaReferenceApplyConfiguration) WithType(value string) *APIResourceSchemaReferenceApplyConfiguration { + b.Type = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemaspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemaspec.go new file mode 100644 index 000000000..ee09cd317 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceschemaspec.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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// APIResourceSchemaSpecApplyConfiguration represents a declarative configuration of the APIResourceSchemaSpec type for use +// with apply. +type APIResourceSchemaSpecApplyConfiguration struct { + InformerScope *v1alpha2.InformerScope `json:"informerScope,omitempty"` + APIResourceSchemaCRDSpecApplyConfiguration `json:",inline"` +} + +// APIResourceSchemaSpecApplyConfiguration constructs a declarative configuration of the APIResourceSchemaSpec type for use with +// apply. +func APIResourceSchemaSpec() *APIResourceSchemaSpecApplyConfiguration { + return &APIResourceSchemaSpecApplyConfiguration{} +} + +// WithInformerScope sets the InformerScope field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InformerScope field is set to the value of the last call. +func (b *APIResourceSchemaSpecApplyConfiguration) WithInformerScope(value v1alpha2.InformerScope) *APIResourceSchemaSpecApplyConfiguration { + b.InformerScope = &value + return b +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *APIResourceSchemaSpecApplyConfiguration) WithGroup(value string) *APIResourceSchemaSpecApplyConfiguration { + b.Group = &value + return b +} + +// WithNames sets the Names field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Names field is set to the value of the last call. +func (b *APIResourceSchemaSpecApplyConfiguration) WithNames(value v1.CustomResourceDefinitionNames) *APIResourceSchemaSpecApplyConfiguration { + b.Names = &value + return b +} + +// WithScope sets the Scope field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Scope field is set to the value of the last call. +func (b *APIResourceSchemaSpecApplyConfiguration) WithScope(value v1.ResourceScope) *APIResourceSchemaSpecApplyConfiguration { + b.Scope = &value + return b +} + +// WithVersions adds the given value to the Versions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Versions field. +func (b *APIResourceSchemaSpecApplyConfiguration) WithVersions(values ...*APIResourceVersionApplyConfiguration) *APIResourceSchemaSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithVersions") + } + b.Versions = append(b.Versions, *values[i]) + } + return b +} + +// WithConversion sets the Conversion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conversion field is set to the value of the last call. +func (b *APIResourceSchemaSpecApplyConfiguration) WithConversion(value *CustomResourceConversionApplyConfiguration) *APIResourceSchemaSpecApplyConfiguration { + b.Conversion = value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceversion.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceversion.go new file mode 100644 index 000000000..9a48c1081 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiresourceversion.go @@ -0,0 +1,108 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" +) + +// APIResourceVersionApplyConfiguration represents a declarative configuration of the APIResourceVersion type for use +// with apply. +type APIResourceVersionApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Served *bool `json:"served,omitempty"` + Storage *bool `json:"storage,omitempty"` + Deprecated *bool `json:"deprecated,omitempty"` + DeprecationWarning *string `json:"deprecationWarning,omitempty"` + Schema *CRDVersionSchemaApplyConfiguration `json:"schema,omitempty"` + Subresources *v1.CustomResourceSubresources `json:"subresources,omitempty"` + AdditionalPrinterColumns []v1.CustomResourceColumnDefinition `json:"additionalPrinterColumns,omitempty"` +} + +// APIResourceVersionApplyConfiguration constructs a declarative configuration of the APIResourceVersion type for use with +// apply. +func APIResourceVersion() *APIResourceVersionApplyConfiguration { + return &APIResourceVersionApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithName(value string) *APIResourceVersionApplyConfiguration { + b.Name = &value + return b +} + +// WithServed sets the Served field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Served field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithServed(value bool) *APIResourceVersionApplyConfiguration { + b.Served = &value + return b +} + +// WithStorage sets the Storage field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Storage field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithStorage(value bool) *APIResourceVersionApplyConfiguration { + b.Storage = &value + return b +} + +// WithDeprecated sets the Deprecated field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Deprecated field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithDeprecated(value bool) *APIResourceVersionApplyConfiguration { + b.Deprecated = &value + return b +} + +// WithDeprecationWarning sets the DeprecationWarning field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeprecationWarning field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithDeprecationWarning(value string) *APIResourceVersionApplyConfiguration { + b.DeprecationWarning = &value + return b +} + +// WithSchema sets the Schema field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Schema field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithSchema(value *CRDVersionSchemaApplyConfiguration) *APIResourceVersionApplyConfiguration { + b.Schema = value + return b +} + +// WithSubresources sets the Subresources field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Subresources field is set to the value of the last call. +func (b *APIResourceVersionApplyConfiguration) WithSubresources(value v1.CustomResourceSubresources) *APIResourceVersionApplyConfiguration { + b.Subresources = &value + return b +} + +// WithAdditionalPrinterColumns adds the given value to the AdditionalPrinterColumns field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the AdditionalPrinterColumns field. +func (b *APIResourceVersionApplyConfiguration) WithAdditionalPrinterColumns(values ...v1.CustomResourceColumnDefinition) *APIResourceVersionApplyConfiguration { + for i := range values { + b.AdditionalPrinterColumns = append(b.AdditionalPrinterColumns, values[i]) + } + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebinding.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..75f0e2380 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,225 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// APIServiceBindingApplyConfiguration represents a declarative configuration of the APIServiceBinding type for use +// with apply. +type APIServiceBindingApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *APIServiceBindingSpecApplyConfiguration `json:"spec,omitempty"` + Status *APIServiceBindingStatusApplyConfiguration `json:"status,omitempty"` +} + +// APIServiceBinding constructs a declarative configuration of the APIServiceBinding type for use with +// apply. +func APIServiceBinding(name string) *APIServiceBindingApplyConfiguration { + b := &APIServiceBindingApplyConfiguration{} + b.WithName(name) + b.WithKind("APIServiceBinding") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithKind(value string) *APIServiceBindingApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithAPIVersion(value string) *APIServiceBindingApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithName(value string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithGenerateName(value string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithNamespace(value string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithUID(value types.UID) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithResourceVersion(value string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithGeneration(value int64) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithCreationTimestamp(value metav1.Time) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *APIServiceBindingApplyConfiguration) WithLabels(entries map[string]string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *APIServiceBindingApplyConfiguration) WithAnnotations(entries map[string]string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *APIServiceBindingApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *APIServiceBindingApplyConfiguration) WithFinalizers(values ...string) *APIServiceBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *APIServiceBindingApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithSpec(value *APIServiceBindingSpecApplyConfiguration) *APIServiceBindingApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *APIServiceBindingApplyConfiguration) WithStatus(value *APIServiceBindingStatusApplyConfiguration) *APIServiceBindingApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIServiceBindingApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebindingspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebindingspec.go new file mode 100644 index 000000000..e891c06da --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebindingspec.go @@ -0,0 +1,39 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// APIServiceBindingSpecApplyConfiguration represents a declarative configuration of the APIServiceBindingSpec type for use +// with apply. +type APIServiceBindingSpecApplyConfiguration struct { + KubeconfigSecretRef *ClusterSecretKeyRefApplyConfiguration `json:"kubeconfigSecretRef,omitempty"` +} + +// APIServiceBindingSpecApplyConfiguration constructs a declarative configuration of the APIServiceBindingSpec type for use with +// apply. +func APIServiceBindingSpec() *APIServiceBindingSpecApplyConfiguration { + return &APIServiceBindingSpecApplyConfiguration{} +} + +// WithKubeconfigSecretRef sets the KubeconfigSecretRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the KubeconfigSecretRef field is set to the value of the last call. +func (b *APIServiceBindingSpecApplyConfiguration) WithKubeconfigSecretRef(value *ClusterSecretKeyRefApplyConfiguration) *APIServiceBindingSpecApplyConfiguration { + b.KubeconfigSecretRef = value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebindingstatus.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebindingstatus.go new file mode 100644 index 000000000..08203b34d --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicebindingstatus.go @@ -0,0 +1,66 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +// APIServiceBindingStatusApplyConfiguration represents a declarative configuration of the APIServiceBindingStatus type for use +// with apply. +type APIServiceBindingStatusApplyConfiguration struct { + ProviderPrettyName *string `json:"providerPrettyName,omitempty"` + Conditions *v1alpha1.Conditions `json:"conditions,omitempty"` + BoundSchemas []BoundSchemaReferenceApplyConfiguration `json:"boundSchemas,omitempty"` +} + +// APIServiceBindingStatusApplyConfiguration constructs a declarative configuration of the APIServiceBindingStatus type for use with +// apply. +func APIServiceBindingStatus() *APIServiceBindingStatusApplyConfiguration { + return &APIServiceBindingStatusApplyConfiguration{} +} + +// WithProviderPrettyName sets the ProviderPrettyName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderPrettyName field is set to the value of the last call. +func (b *APIServiceBindingStatusApplyConfiguration) WithProviderPrettyName(value string) *APIServiceBindingStatusApplyConfiguration { + b.ProviderPrettyName = &value + return b +} + +// WithConditions sets the Conditions field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conditions field is set to the value of the last call. +func (b *APIServiceBindingStatusApplyConfiguration) WithConditions(value v1alpha1.Conditions) *APIServiceBindingStatusApplyConfiguration { + b.Conditions = &value + return b +} + +// WithBoundSchemas adds the given value to the BoundSchemas field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the BoundSchemas field. +func (b *APIServiceBindingStatusApplyConfiguration) WithBoundSchemas(values ...*BoundSchemaReferenceApplyConfiguration) *APIServiceBindingStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithBoundSchemas") + } + b.BoundSchemas = append(b.BoundSchemas, *values[i]) + } + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexport.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..94206e744 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexport.go @@ -0,0 +1,226 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// APIServiceExportApplyConfiguration represents a declarative configuration of the APIServiceExport type for use +// with apply. +type APIServiceExportApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *APIServiceExportSpecApplyConfiguration `json:"spec,omitempty"` + Status *APIServiceExportStatusApplyConfiguration `json:"status,omitempty"` +} + +// APIServiceExport constructs a declarative configuration of the APIServiceExport type for use with +// apply. +func APIServiceExport(name, namespace string) *APIServiceExportApplyConfiguration { + b := &APIServiceExportApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("APIServiceExport") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithKind(value string) *APIServiceExportApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithAPIVersion(value string) *APIServiceExportApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithName(value string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithGenerateName(value string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithNamespace(value string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithUID(value types.UID) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithResourceVersion(value string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithGeneration(value int64) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithCreationTimestamp(value metav1.Time) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *APIServiceExportApplyConfiguration) WithLabels(entries map[string]string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *APIServiceExportApplyConfiguration) WithAnnotations(entries map[string]string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *APIServiceExportApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *APIServiceExportApplyConfiguration) WithFinalizers(values ...string) *APIServiceExportApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *APIServiceExportApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithSpec(value *APIServiceExportSpecApplyConfiguration) *APIServiceExportApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *APIServiceExportApplyConfiguration) WithStatus(value *APIServiceExportStatusApplyConfiguration) *APIServiceExportApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIServiceExportApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..172e648b0 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequest.go @@ -0,0 +1,226 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// APIServiceExportRequestApplyConfiguration represents a declarative configuration of the APIServiceExportRequest type for use +// with apply. +type APIServiceExportRequestApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *APIServiceExportRequestSpecApplyConfiguration `json:"spec,omitempty"` + Status *APIServiceExportRequestStatusApplyConfiguration `json:"status,omitempty"` +} + +// APIServiceExportRequest constructs a declarative configuration of the APIServiceExportRequest type for use with +// apply. +func APIServiceExportRequest(name, namespace string) *APIServiceExportRequestApplyConfiguration { + b := &APIServiceExportRequestApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("APIServiceExportRequest") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithKind(value string) *APIServiceExportRequestApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithAPIVersion(value string) *APIServiceExportRequestApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithName(value string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithGenerateName(value string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithNamespace(value string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithUID(value types.UID) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithResourceVersion(value string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithGeneration(value int64) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithCreationTimestamp(value metav1.Time) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *APIServiceExportRequestApplyConfiguration) WithLabels(entries map[string]string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *APIServiceExportRequestApplyConfiguration) WithAnnotations(entries map[string]string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *APIServiceExportRequestApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *APIServiceExportRequestApplyConfiguration) WithFinalizers(values ...string) *APIServiceExportRequestApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *APIServiceExportRequestApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithSpec(value *APIServiceExportRequestSpecApplyConfiguration) *APIServiceExportRequestApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *APIServiceExportRequestApplyConfiguration) WithStatus(value *APIServiceExportRequestStatusApplyConfiguration) *APIServiceExportRequestApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIServiceExportRequestApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequestresource.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequestresource.go new file mode 100644 index 000000000..389261e45 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequestresource.go @@ -0,0 +1,58 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// APIServiceExportRequestResourceApplyConfiguration represents a declarative configuration of the APIServiceExportRequestResource type for use +// with apply. +type APIServiceExportRequestResourceApplyConfiguration struct { + GroupResourceApplyConfiguration `json:",inline"` + Versions []string `json:"versions,omitempty"` +} + +// APIServiceExportRequestResourceApplyConfiguration constructs a declarative configuration of the APIServiceExportRequestResource type for use with +// apply. +func APIServiceExportRequestResource() *APIServiceExportRequestResourceApplyConfiguration { + return &APIServiceExportRequestResourceApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *APIServiceExportRequestResourceApplyConfiguration) WithGroup(value string) *APIServiceExportRequestResourceApplyConfiguration { + b.Group = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *APIServiceExportRequestResourceApplyConfiguration) WithResource(value string) *APIServiceExportRequestResourceApplyConfiguration { + b.Resource = &value + return b +} + +// WithVersions adds the given value to the Versions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Versions field. +func (b *APIServiceExportRequestResourceApplyConfiguration) WithVersions(values ...string) *APIServiceExportRequestResourceApplyConfiguration { + for i := range values { + b.Versions = append(b.Versions, values[i]) + } + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequestspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequestspec.go new file mode 100644 index 000000000..10c61fbd1 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequestspec.go @@ -0,0 +1,57 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// APIServiceExportRequestSpecApplyConfiguration represents a declarative configuration of the APIServiceExportRequestSpec type for use +// with apply. +type APIServiceExportRequestSpecApplyConfiguration struct { + Parameters *runtime.RawExtension `json:"parameters,omitempty"` + Resources []APIServiceExportRequestResourceApplyConfiguration `json:"resources,omitempty"` +} + +// APIServiceExportRequestSpecApplyConfiguration constructs a declarative configuration of the APIServiceExportRequestSpec type for use with +// apply. +func APIServiceExportRequestSpec() *APIServiceExportRequestSpecApplyConfiguration { + return &APIServiceExportRequestSpecApplyConfiguration{} +} + +// WithParameters sets the Parameters field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Parameters field is set to the value of the last call. +func (b *APIServiceExportRequestSpecApplyConfiguration) WithParameters(value runtime.RawExtension) *APIServiceExportRequestSpecApplyConfiguration { + b.Parameters = &value + return b +} + +// WithResources adds the given value to the Resources field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Resources field. +func (b *APIServiceExportRequestSpecApplyConfiguration) WithResources(values ...*APIServiceExportRequestResourceApplyConfiguration) *APIServiceExportRequestSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithResources") + } + b.Resources = append(b.Resources, *values[i]) + } + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequeststatus.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequeststatus.go new file mode 100644 index 000000000..494fa0a21 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportrequeststatus.go @@ -0,0 +1,62 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + v1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +// APIServiceExportRequestStatusApplyConfiguration represents a declarative configuration of the APIServiceExportRequestStatus type for use +// with apply. +type APIServiceExportRequestStatusApplyConfiguration struct { + Phase *v1alpha2.APIServiceExportRequestPhase `json:"phase,omitempty"` + TerminalMessage *string `json:"terminalMessage,omitempty"` + Conditions *v1alpha1.Conditions `json:"conditions,omitempty"` +} + +// APIServiceExportRequestStatusApplyConfiguration constructs a declarative configuration of the APIServiceExportRequestStatus type for use with +// apply. +func APIServiceExportRequestStatus() *APIServiceExportRequestStatusApplyConfiguration { + return &APIServiceExportRequestStatusApplyConfiguration{} +} + +// WithPhase sets the Phase field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Phase field is set to the value of the last call. +func (b *APIServiceExportRequestStatusApplyConfiguration) WithPhase(value v1alpha2.APIServiceExportRequestPhase) *APIServiceExportRequestStatusApplyConfiguration { + b.Phase = &value + return b +} + +// WithTerminalMessage sets the TerminalMessage field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the TerminalMessage field is set to the value of the last call. +func (b *APIServiceExportRequestStatusApplyConfiguration) WithTerminalMessage(value string) *APIServiceExportRequestStatusApplyConfiguration { + b.TerminalMessage = &value + return b +} + +// WithConditions sets the Conditions field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conditions field is set to the value of the last call. +func (b *APIServiceExportRequestStatusApplyConfiguration) WithConditions(value v1alpha1.Conditions) *APIServiceExportRequestStatusApplyConfiguration { + b.Conditions = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportspec.go new file mode 100644 index 000000000..8426dfdf6 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportspec.go @@ -0,0 +1,66 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// APIServiceExportSpecApplyConfiguration represents a declarative configuration of the APIServiceExportSpec type for use +// with apply. +type APIServiceExportSpecApplyConfiguration struct { + Resources []APIResourceSchemaReferenceApplyConfiguration `json:"resources,omitempty"` + InformerScope *kubebindv1alpha2.InformerScope `json:"informerScope,omitempty"` + ClusterScopedIsolation *kubebindv1alpha2.Isolation `json:"clusterScopedIsolation,omitempty"` +} + +// APIServiceExportSpecApplyConfiguration constructs a declarative configuration of the APIServiceExportSpec type for use with +// apply. +func APIServiceExportSpec() *APIServiceExportSpecApplyConfiguration { + return &APIServiceExportSpecApplyConfiguration{} +} + +// WithResources adds the given value to the Resources field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Resources field. +func (b *APIServiceExportSpecApplyConfiguration) WithResources(values ...*APIResourceSchemaReferenceApplyConfiguration) *APIServiceExportSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithResources") + } + b.Resources = append(b.Resources, *values[i]) + } + return b +} + +// WithInformerScope sets the InformerScope field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InformerScope field is set to the value of the last call. +func (b *APIServiceExportSpecApplyConfiguration) WithInformerScope(value kubebindv1alpha2.InformerScope) *APIServiceExportSpecApplyConfiguration { + b.InformerScope = &value + return b +} + +// WithClusterScopedIsolation sets the ClusterScopedIsolation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ClusterScopedIsolation field is set to the value of the last call. +func (b *APIServiceExportSpecApplyConfiguration) WithClusterScopedIsolation(value kubebindv1alpha2.Isolation) *APIServiceExportSpecApplyConfiguration { + b.ClusterScopedIsolation = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportstatus.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportstatus.go new file mode 100644 index 000000000..43a6f74bb --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiserviceexportstatus.go @@ -0,0 +1,65 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + v1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +// APIServiceExportStatusApplyConfiguration represents a declarative configuration of the APIServiceExportStatus type for use +// with apply. +type APIServiceExportStatusApplyConfiguration struct { + AcceptedNames *v1.CustomResourceDefinitionNames `json:"acceptedNames,omitempty"` + StoredVersions []string `json:"storedVersions,omitempty"` + Conditions *v1alpha1.Conditions `json:"conditions,omitempty"` +} + +// APIServiceExportStatusApplyConfiguration constructs a declarative configuration of the APIServiceExportStatus type for use with +// apply. +func APIServiceExportStatus() *APIServiceExportStatusApplyConfiguration { + return &APIServiceExportStatusApplyConfiguration{} +} + +// WithAcceptedNames sets the AcceptedNames field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AcceptedNames field is set to the value of the last call. +func (b *APIServiceExportStatusApplyConfiguration) WithAcceptedNames(value v1.CustomResourceDefinitionNames) *APIServiceExportStatusApplyConfiguration { + b.AcceptedNames = &value + return b +} + +// WithStoredVersions adds the given value to the StoredVersions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the StoredVersions field. +func (b *APIServiceExportStatusApplyConfiguration) WithStoredVersions(values ...string) *APIServiceExportStatusApplyConfiguration { + for i := range values { + b.StoredVersions = append(b.StoredVersions, values[i]) + } + return b +} + +// WithConditions sets the Conditions field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conditions field is set to the value of the last call. +func (b *APIServiceExportStatusApplyConfiguration) WithConditions(value v1alpha1.Conditions) *APIServiceExportStatusApplyConfiguration { + b.Conditions = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicenamespace.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..cbffe9509 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicenamespace.go @@ -0,0 +1,227 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// APIServiceNamespaceApplyConfiguration represents a declarative configuration of the APIServiceNamespace type for use +// with apply. +type APIServiceNamespaceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *v1alpha2.APIServiceNamespaceSpec `json:"spec,omitempty"` + Status *APIServiceNamespaceStatusApplyConfiguration `json:"status,omitempty"` +} + +// APIServiceNamespace constructs a declarative configuration of the APIServiceNamespace type for use with +// apply. +func APIServiceNamespace(name, namespace string) *APIServiceNamespaceApplyConfiguration { + b := &APIServiceNamespaceApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("APIServiceNamespace") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithKind(value string) *APIServiceNamespaceApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithAPIVersion(value string) *APIServiceNamespaceApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithName(value string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithGenerateName(value string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithNamespace(value string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithUID(value types.UID) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithResourceVersion(value string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithGeneration(value int64) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *APIServiceNamespaceApplyConfiguration) WithLabels(entries map[string]string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *APIServiceNamespaceApplyConfiguration) WithAnnotations(entries map[string]string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *APIServiceNamespaceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *APIServiceNamespaceApplyConfiguration) WithFinalizers(values ...string) *APIServiceNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *APIServiceNamespaceApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithSpec(value v1alpha2.APIServiceNamespaceSpec) *APIServiceNamespaceApplyConfiguration { + b.Spec = &value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *APIServiceNamespaceApplyConfiguration) WithStatus(value *APIServiceNamespaceStatusApplyConfiguration) *APIServiceNamespaceApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIServiceNamespaceApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicenamespacestatus.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicenamespacestatus.go new file mode 100644 index 000000000..22349c966 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/apiservicenamespacestatus.go @@ -0,0 +1,39 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// APIServiceNamespaceStatusApplyConfiguration represents a declarative configuration of the APIServiceNamespaceStatus type for use +// with apply. +type APIServiceNamespaceStatusApplyConfiguration struct { + Namespace *string `json:"namespace,omitempty"` +} + +// APIServiceNamespaceStatusApplyConfiguration constructs a declarative configuration of the APIServiceNamespaceStatus type for use with +// apply. +func APIServiceNamespaceStatus() *APIServiceNamespaceStatusApplyConfiguration { + return &APIServiceNamespaceStatusApplyConfiguration{} +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *APIServiceNamespaceStatusApplyConfiguration) WithNamespace(value string) *APIServiceNamespaceStatusApplyConfiguration { + b.Namespace = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..f2dbc7cd9 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,226 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// BoundAPIResourceSchemaApplyConfiguration represents a declarative configuration of the BoundAPIResourceSchema type for use +// with apply. +type BoundAPIResourceSchemaApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *BoundAPIResourceSchemaSpecApplyConfiguration `json:"spec,omitempty"` + Status *BoundAPIResourceSchemaStatusApplyConfiguration `json:"status,omitempty"` +} + +// BoundAPIResourceSchema constructs a declarative configuration of the BoundAPIResourceSchema type for use with +// apply. +func BoundAPIResourceSchema(name, namespace string) *BoundAPIResourceSchemaApplyConfiguration { + b := &BoundAPIResourceSchemaApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("BoundAPIResourceSchema") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithKind(value string) *BoundAPIResourceSchemaApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithAPIVersion(value string) *BoundAPIResourceSchemaApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithName(value string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithGenerateName(value string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithNamespace(value string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithUID(value types.UID) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithResourceVersion(value string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithGeneration(value int64) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithCreationTimestamp(value metav1.Time) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithLabels(entries map[string]string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithAnnotations(entries map[string]string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithFinalizers(values ...string) *BoundAPIResourceSchemaApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *BoundAPIResourceSchemaApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithSpec(value *BoundAPIResourceSchemaSpecApplyConfiguration) *BoundAPIResourceSchemaApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *BoundAPIResourceSchemaApplyConfiguration) WithStatus(value *BoundAPIResourceSchemaStatusApplyConfiguration) *BoundAPIResourceSchemaApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *BoundAPIResourceSchemaApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschemaspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschemaspec.go new file mode 100644 index 000000000..7ec12df33 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschemaspec.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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// BoundAPIResourceSchemaSpecApplyConfiguration represents a declarative configuration of the BoundAPIResourceSchemaSpec type for use +// with apply. +type BoundAPIResourceSchemaSpecApplyConfiguration struct { + InformerScope *v1alpha2.InformerScope `json:"informerScope,omitempty"` + APIResourceSchemaCRDSpecApplyConfiguration `json:",inline"` +} + +// BoundAPIResourceSchemaSpecApplyConfiguration constructs a declarative configuration of the BoundAPIResourceSchemaSpec type for use with +// apply. +func BoundAPIResourceSchemaSpec() *BoundAPIResourceSchemaSpecApplyConfiguration { + return &BoundAPIResourceSchemaSpecApplyConfiguration{} +} + +// WithInformerScope sets the InformerScope field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InformerScope field is set to the value of the last call. +func (b *BoundAPIResourceSchemaSpecApplyConfiguration) WithInformerScope(value v1alpha2.InformerScope) *BoundAPIResourceSchemaSpecApplyConfiguration { + b.InformerScope = &value + return b +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *BoundAPIResourceSchemaSpecApplyConfiguration) WithGroup(value string) *BoundAPIResourceSchemaSpecApplyConfiguration { + b.Group = &value + return b +} + +// WithNames sets the Names field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Names field is set to the value of the last call. +func (b *BoundAPIResourceSchemaSpecApplyConfiguration) WithNames(value v1.CustomResourceDefinitionNames) *BoundAPIResourceSchemaSpecApplyConfiguration { + b.Names = &value + return b +} + +// WithScope sets the Scope field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Scope field is set to the value of the last call. +func (b *BoundAPIResourceSchemaSpecApplyConfiguration) WithScope(value v1.ResourceScope) *BoundAPIResourceSchemaSpecApplyConfiguration { + b.Scope = &value + return b +} + +// WithVersions adds the given value to the Versions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Versions field. +func (b *BoundAPIResourceSchemaSpecApplyConfiguration) WithVersions(values ...*APIResourceVersionApplyConfiguration) *BoundAPIResourceSchemaSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithVersions") + } + b.Versions = append(b.Versions, *values[i]) + } + return b +} + +// WithConversion sets the Conversion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conversion field is set to the value of the last call. +func (b *BoundAPIResourceSchemaSpecApplyConfiguration) WithConversion(value *CustomResourceConversionApplyConfiguration) *BoundAPIResourceSchemaSpecApplyConfiguration { + b.Conversion = value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschemastatus.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschemastatus.go new file mode 100644 index 000000000..928d95dd8 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundapiresourceschemastatus.go @@ -0,0 +1,79 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + v1alpha1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/conditions/v1alpha1" +) + +// BoundAPIResourceSchemaStatusApplyConfiguration represents a declarative configuration of the BoundAPIResourceSchemaStatus type for use +// with apply. +type BoundAPIResourceSchemaStatusApplyConfiguration struct { + AcceptedNames *v1.CustomResourceDefinitionNames `json:"acceptedNames,omitempty"` + StoredVersions []string `json:"storedVersions,omitempty"` + Conditions []v1alpha1.ConditionApplyConfiguration `json:"conditions,omitempty"` + Instantiations *int `json:"instantiations,omitempty"` +} + +// BoundAPIResourceSchemaStatusApplyConfiguration constructs a declarative configuration of the BoundAPIResourceSchemaStatus type for use with +// apply. +func BoundAPIResourceSchemaStatus() *BoundAPIResourceSchemaStatusApplyConfiguration { + return &BoundAPIResourceSchemaStatusApplyConfiguration{} +} + +// WithAcceptedNames sets the AcceptedNames field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AcceptedNames field is set to the value of the last call. +func (b *BoundAPIResourceSchemaStatusApplyConfiguration) WithAcceptedNames(value v1.CustomResourceDefinitionNames) *BoundAPIResourceSchemaStatusApplyConfiguration { + b.AcceptedNames = &value + return b +} + +// WithStoredVersions adds the given value to the StoredVersions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the StoredVersions field. +func (b *BoundAPIResourceSchemaStatusApplyConfiguration) WithStoredVersions(values ...string) *BoundAPIResourceSchemaStatusApplyConfiguration { + for i := range values { + b.StoredVersions = append(b.StoredVersions, values[i]) + } + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *BoundAPIResourceSchemaStatusApplyConfiguration) WithConditions(values ...*v1alpha1.ConditionApplyConfiguration) *BoundAPIResourceSchemaStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} + +// WithInstantiations sets the Instantiations field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Instantiations field is set to the value of the last call. +func (b *BoundAPIResourceSchemaStatusApplyConfiguration) WithInstantiations(value int) *BoundAPIResourceSchemaStatusApplyConfiguration { + b.Instantiations = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundresourcereference.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundresourcereference.go new file mode 100644 index 000000000..bdfc77732 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundresourcereference.go @@ -0,0 +1,48 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// BoundResourceReferenceApplyConfiguration represents a declarative configuration of the BoundResourceReference type for use +// with apply. +type BoundResourceReferenceApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` +} + +// BoundResourceReferenceApplyConfiguration constructs a declarative configuration of the BoundResourceReference type for use with +// apply. +func BoundResourceReference() *BoundResourceReferenceApplyConfiguration { + return &BoundResourceReferenceApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *BoundResourceReferenceApplyConfiguration) WithName(value string) *BoundResourceReferenceApplyConfiguration { + b.Name = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *BoundResourceReferenceApplyConfiguration) WithNamespace(value string) *BoundResourceReferenceApplyConfiguration { + b.Namespace = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundschemareference.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundschemareference.go new file mode 100644 index 000000000..7b5933ba6 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/boundschemareference.go @@ -0,0 +1,47 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// BoundSchemaReferenceApplyConfiguration represents a declarative configuration of the BoundSchemaReference type for use +// with apply. +type BoundSchemaReferenceApplyConfiguration struct { + GroupResourceApplyConfiguration `json:",inline"` +} + +// BoundSchemaReferenceApplyConfiguration constructs a declarative configuration of the BoundSchemaReference type for use with +// apply. +func BoundSchemaReference() *BoundSchemaReferenceApplyConfiguration { + return &BoundSchemaReferenceApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *BoundSchemaReferenceApplyConfiguration) WithGroup(value string) *BoundSchemaReferenceApplyConfiguration { + b.Group = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *BoundSchemaReferenceApplyConfiguration) WithResource(value string) *BoundSchemaReferenceApplyConfiguration { + b.Resource = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbinding.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..0aa1e8799 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbinding.go @@ -0,0 +1,226 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + + v1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" +) + +// ClusterBindingApplyConfiguration represents a declarative configuration of the ClusterBinding type for use +// with apply. +type ClusterBindingApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ClusterBindingSpecApplyConfiguration `json:"spec,omitempty"` + Status *ClusterBindingStatusApplyConfiguration `json:"status,omitempty"` +} + +// ClusterBinding constructs a declarative configuration of the ClusterBinding type for use with +// apply. +func ClusterBinding(name, namespace string) *ClusterBindingApplyConfiguration { + b := &ClusterBindingApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("ClusterBinding") + b.WithAPIVersion("kube-bind.io/v1alpha2") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithKind(value string) *ClusterBindingApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithAPIVersion(value string) *ClusterBindingApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithName(value string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithGenerateName(value string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithNamespace(value string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithUID(value types.UID) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithResourceVersion(value string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithGeneration(value int64) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *ClusterBindingApplyConfiguration) WithLabels(entries map[string]string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *ClusterBindingApplyConfiguration) WithAnnotations(entries map[string]string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *ClusterBindingApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *ClusterBindingApplyConfiguration) WithFinalizers(values ...string) *ClusterBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *ClusterBindingApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithSpec(value *ClusterBindingSpecApplyConfiguration) *ClusterBindingApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ClusterBindingApplyConfiguration) WithStatus(value *ClusterBindingStatusApplyConfiguration) *ClusterBindingApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *ClusterBindingApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbindingspec.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbindingspec.go new file mode 100644 index 000000000..195df0480 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbindingspec.go @@ -0,0 +1,61 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// ClusterBindingSpecApplyConfiguration represents a declarative configuration of the ClusterBindingSpec type for use +// with apply. +type ClusterBindingSpecApplyConfiguration struct { + KubeconfigSecretRef *LocalSecretKeyRefApplyConfiguration `json:"kubeconfigSecretRef,omitempty"` + ProviderPrettyName *string `json:"providerPrettyName,omitempty"` + ServiceProviderSpec *runtime.RawExtension `json:"serviceProviderSpec,omitempty"` +} + +// ClusterBindingSpecApplyConfiguration constructs a declarative configuration of the ClusterBindingSpec type for use with +// apply. +func ClusterBindingSpec() *ClusterBindingSpecApplyConfiguration { + return &ClusterBindingSpecApplyConfiguration{} +} + +// WithKubeconfigSecretRef sets the KubeconfigSecretRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the KubeconfigSecretRef field is set to the value of the last call. +func (b *ClusterBindingSpecApplyConfiguration) WithKubeconfigSecretRef(value *LocalSecretKeyRefApplyConfiguration) *ClusterBindingSpecApplyConfiguration { + b.KubeconfigSecretRef = value + return b +} + +// WithProviderPrettyName sets the ProviderPrettyName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderPrettyName field is set to the value of the last call. +func (b *ClusterBindingSpecApplyConfiguration) WithProviderPrettyName(value string) *ClusterBindingSpecApplyConfiguration { + b.ProviderPrettyName = &value + return b +} + +// WithServiceProviderSpec sets the ServiceProviderSpec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ServiceProviderSpec field is set to the value of the last call. +func (b *ClusterBindingSpecApplyConfiguration) WithServiceProviderSpec(value runtime.RawExtension) *ClusterBindingSpecApplyConfiguration { + b.ServiceProviderSpec = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbindingstatus.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbindingstatus.go new file mode 100644 index 000000000..47a4efbd8 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clusterbindingstatus.go @@ -0,0 +1,72 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +// ClusterBindingStatusApplyConfiguration represents a declarative configuration of the ClusterBindingStatus type for use +// with apply. +type ClusterBindingStatusApplyConfiguration struct { + LastHeartbeatTime *v1.Time `json:"lastHeartbeatTime,omitempty"` + HeartbeatInterval *v1.Duration `json:"heartbeatInterval,omitempty"` + KonnectorVersion *string `json:"konnectorVersion,omitempty"` + Conditions *v1alpha1.Conditions `json:"conditions,omitempty"` +} + +// ClusterBindingStatusApplyConfiguration constructs a declarative configuration of the ClusterBindingStatus type for use with +// apply. +func ClusterBindingStatus() *ClusterBindingStatusApplyConfiguration { + return &ClusterBindingStatusApplyConfiguration{} +} + +// WithLastHeartbeatTime sets the LastHeartbeatTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastHeartbeatTime field is set to the value of the last call. +func (b *ClusterBindingStatusApplyConfiguration) WithLastHeartbeatTime(value v1.Time) *ClusterBindingStatusApplyConfiguration { + b.LastHeartbeatTime = &value + return b +} + +// WithHeartbeatInterval sets the HeartbeatInterval field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the HeartbeatInterval field is set to the value of the last call. +func (b *ClusterBindingStatusApplyConfiguration) WithHeartbeatInterval(value v1.Duration) *ClusterBindingStatusApplyConfiguration { + b.HeartbeatInterval = &value + return b +} + +// WithKonnectorVersion sets the KonnectorVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the KonnectorVersion field is set to the value of the last call. +func (b *ClusterBindingStatusApplyConfiguration) WithKonnectorVersion(value string) *ClusterBindingStatusApplyConfiguration { + b.KonnectorVersion = &value + return b +} + +// WithConditions sets the Conditions field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Conditions field is set to the value of the last call. +func (b *ClusterBindingStatusApplyConfiguration) WithConditions(value v1alpha1.Conditions) *ClusterBindingStatusApplyConfiguration { + b.Conditions = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clustersecretkeyref.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clustersecretkeyref.go new file mode 100644 index 000000000..68757065d --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/clustersecretkeyref.go @@ -0,0 +1,56 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// ClusterSecretKeyRefApplyConfiguration represents a declarative configuration of the ClusterSecretKeyRef type for use +// with apply. +type ClusterSecretKeyRefApplyConfiguration struct { + LocalSecretKeyRefApplyConfiguration `json:",inline"` + Namespace *string `json:"namespace,omitempty"` +} + +// ClusterSecretKeyRefApplyConfiguration constructs a declarative configuration of the ClusterSecretKeyRef type for use with +// apply. +func ClusterSecretKeyRef() *ClusterSecretKeyRefApplyConfiguration { + return &ClusterSecretKeyRefApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ClusterSecretKeyRefApplyConfiguration) WithName(value string) *ClusterSecretKeyRefApplyConfiguration { + b.Name = &value + return b +} + +// WithKey sets the Key field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Key field is set to the value of the last call. +func (b *ClusterSecretKeyRefApplyConfiguration) WithKey(value string) *ClusterSecretKeyRefApplyConfiguration { + b.Key = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ClusterSecretKeyRefApplyConfiguration) WithNamespace(value string) *ClusterSecretKeyRefApplyConfiguration { + b.Namespace = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/crdversionschema.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/crdversionschema.go new file mode 100644 index 000000000..3256f962e --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/crdversionschema.go @@ -0,0 +1,43 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// CRDVersionSchemaApplyConfiguration represents a declarative configuration of the CRDVersionSchema type for use +// with apply. +type CRDVersionSchemaApplyConfiguration struct { + OpenAPIV3Schema *runtime.RawExtension `json:"openAPIV3Schema,omitempty"` +} + +// CRDVersionSchemaApplyConfiguration constructs a declarative configuration of the CRDVersionSchema type for use with +// apply. +func CRDVersionSchema() *CRDVersionSchemaApplyConfiguration { + return &CRDVersionSchemaApplyConfiguration{} +} + +// WithOpenAPIV3Schema sets the OpenAPIV3Schema field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the OpenAPIV3Schema field is set to the value of the last call. +func (b *CRDVersionSchemaApplyConfiguration) WithOpenAPIV3Schema(value runtime.RawExtension) *CRDVersionSchemaApplyConfiguration { + b.OpenAPIV3Schema = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/customresourceconversion.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/customresourceconversion.go new file mode 100644 index 000000000..e2fc570bd --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/customresourceconversion.go @@ -0,0 +1,52 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +// CustomResourceConversionApplyConfiguration represents a declarative configuration of the CustomResourceConversion type for use +// with apply. +type CustomResourceConversionApplyConfiguration struct { + Strategy *v1alpha2.ConversionStrategyType `json:"strategy,omitempty"` + Webhook *WebhookConversionApplyConfiguration `json:"webhook,omitempty"` +} + +// CustomResourceConversionApplyConfiguration constructs a declarative configuration of the CustomResourceConversion type for use with +// apply. +func CustomResourceConversion() *CustomResourceConversionApplyConfiguration { + return &CustomResourceConversionApplyConfiguration{} +} + +// WithStrategy sets the Strategy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Strategy field is set to the value of the last call. +func (b *CustomResourceConversionApplyConfiguration) WithStrategy(value v1alpha2.ConversionStrategyType) *CustomResourceConversionApplyConfiguration { + b.Strategy = &value + return b +} + +// WithWebhook sets the Webhook field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Webhook field is set to the value of the last call. +func (b *CustomResourceConversionApplyConfiguration) WithWebhook(value *WebhookConversionApplyConfiguration) *CustomResourceConversionApplyConfiguration { + b.Webhook = value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/groupresource.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/groupresource.go new file mode 100644 index 000000000..1012bfd4b --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/groupresource.go @@ -0,0 +1,48 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// GroupResourceApplyConfiguration represents a declarative configuration of the GroupResource type for use +// with apply. +type GroupResourceApplyConfiguration struct { + Group *string `json:"group,omitempty"` + Resource *string `json:"resource,omitempty"` +} + +// GroupResourceApplyConfiguration constructs a declarative configuration of the GroupResource type for use with +// apply. +func GroupResource() *GroupResourceApplyConfiguration { + return &GroupResourceApplyConfiguration{} +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *GroupResourceApplyConfiguration) WithGroup(value string) *GroupResourceApplyConfiguration { + b.Group = &value + return b +} + +// WithResource sets the Resource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resource field is set to the value of the last call. +func (b *GroupResourceApplyConfiguration) WithResource(value string) *GroupResourceApplyConfiguration { + b.Resource = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/localsecretkeyref.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/localsecretkeyref.go new file mode 100644 index 000000000..66d00c2c5 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/localsecretkeyref.go @@ -0,0 +1,48 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// LocalSecretKeyRefApplyConfiguration represents a declarative configuration of the LocalSecretKeyRef type for use +// with apply. +type LocalSecretKeyRefApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Key *string `json:"key,omitempty"` +} + +// LocalSecretKeyRefApplyConfiguration constructs a declarative configuration of the LocalSecretKeyRef type for use with +// apply. +func LocalSecretKeyRef() *LocalSecretKeyRefApplyConfiguration { + return &LocalSecretKeyRefApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *LocalSecretKeyRefApplyConfiguration) WithName(value string) *LocalSecretKeyRefApplyConfiguration { + b.Name = &value + return b +} + +// WithKey sets the Key field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Key field is set to the value of the last call. +func (b *LocalSecretKeyRefApplyConfiguration) WithKey(value string) *LocalSecretKeyRefApplyConfiguration { + b.Key = &value + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/webhookclientconfig.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/webhookclientconfig.go new file mode 100644 index 000000000..e401759ef --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/webhookclientconfig.go @@ -0,0 +1,50 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// WebhookClientConfigApplyConfiguration represents a declarative configuration of the WebhookClientConfig type for use +// with apply. +type WebhookClientConfigApplyConfiguration struct { + URL *string `json:"url,omitempty"` + CABundle []byte `json:"caBundle,omitempty"` +} + +// WebhookClientConfigApplyConfiguration constructs a declarative configuration of the WebhookClientConfig type for use with +// apply. +func WebhookClientConfig() *WebhookClientConfigApplyConfiguration { + return &WebhookClientConfigApplyConfiguration{} +} + +// WithURL sets the URL field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the URL field is set to the value of the last call. +func (b *WebhookClientConfigApplyConfiguration) WithURL(value string) *WebhookClientConfigApplyConfiguration { + b.URL = &value + return b +} + +// WithCABundle adds the given value to the CABundle field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the CABundle field. +func (b *WebhookClientConfigApplyConfiguration) WithCABundle(values ...byte) *WebhookClientConfigApplyConfiguration { + for i := range values { + b.CABundle = append(b.CABundle, values[i]) + } + return b +} diff --git a/sdk/kcp/applyconfiguration/kubebind/v1alpha2/webhookconversion.go b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/webhookconversion.go new file mode 100644 index 000000000..94cb4c0b5 --- /dev/null +++ b/sdk/kcp/applyconfiguration/kubebind/v1alpha2/webhookconversion.go @@ -0,0 +1,50 @@ +/* +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 applyconfiguration-gen-v0.31. DO NOT EDIT. + +package v1alpha2 + +// WebhookConversionApplyConfiguration represents a declarative configuration of the WebhookConversion type for use +// with apply. +type WebhookConversionApplyConfiguration struct { + ClientConfig *WebhookClientConfigApplyConfiguration `json:"clientConfig,omitempty"` + ConversionReviewVersions []string `json:"conversionReviewVersions,omitempty"` +} + +// WebhookConversionApplyConfiguration constructs a declarative configuration of the WebhookConversion type for use with +// apply. +func WebhookConversion() *WebhookConversionApplyConfiguration { + return &WebhookConversionApplyConfiguration{} +} + +// WithClientConfig sets the ClientConfig field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ClientConfig field is set to the value of the last call. +func (b *WebhookConversionApplyConfiguration) WithClientConfig(value *WebhookClientConfigApplyConfiguration) *WebhookConversionApplyConfiguration { + b.ClientConfig = value + return b +} + +// WithConversionReviewVersions adds the given value to the ConversionReviewVersions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the ConversionReviewVersions field. +func (b *WebhookConversionApplyConfiguration) WithConversionReviewVersions(values ...string) *WebhookConversionApplyConfiguration { + for i := range values { + b.ConversionReviewVersions = append(b.ConversionReviewVersions, values[i]) + } + return b +} diff --git a/sdk/kcp/applyconfiguration/utils.go b/sdk/kcp/applyconfiguration/utils.go index 310d56d15..7f058402f 100644 --- a/sdk/kcp/applyconfiguration/utils.go +++ b/sdk/kcp/applyconfiguration/utils.go @@ -26,10 +26,12 @@ import ( testing "k8s.io/client-go/testing" kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" v1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" conditionsv1alpha1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/conditions/v1alpha1" internal "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/internal" applyconfigurationkubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" applyconfigurationmetav1 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/meta/v1" ) @@ -85,6 +87,70 @@ func ForKind(kind schema.GroupVersionKind) interface{} { case kubebindv1alpha1.SchemeGroupVersion.WithKind("LocalSecretKeyRef"): return &applyconfigurationkubebindv1alpha1.LocalSecretKeyRefApplyConfiguration{} + // Group=kube-bind.io, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithKind("APIResourceSchema"): + return &kubebindv1alpha2.APIResourceSchemaApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIResourceSchemaCRDSpec"): + return &kubebindv1alpha2.APIResourceSchemaCRDSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIResourceSchemaReference"): + return &kubebindv1alpha2.APIResourceSchemaReferenceApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIResourceSchemaSpec"): + return &kubebindv1alpha2.APIResourceSchemaSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIResourceVersion"): + return &kubebindv1alpha2.APIResourceVersionApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceBinding"): + return &kubebindv1alpha2.APIServiceBindingApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceBindingSpec"): + return &kubebindv1alpha2.APIServiceBindingSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceBindingStatus"): + return &kubebindv1alpha2.APIServiceBindingStatusApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExport"): + return &kubebindv1alpha2.APIServiceExportApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportRequest"): + return &kubebindv1alpha2.APIServiceExportRequestApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportRequestResource"): + return &kubebindv1alpha2.APIServiceExportRequestResourceApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportRequestSpec"): + return &kubebindv1alpha2.APIServiceExportRequestSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportRequestStatus"): + return &kubebindv1alpha2.APIServiceExportRequestStatusApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportSpec"): + return &kubebindv1alpha2.APIServiceExportSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportStatus"): + return &kubebindv1alpha2.APIServiceExportStatusApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceNamespace"): + return &kubebindv1alpha2.APIServiceNamespaceApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("APIServiceNamespaceStatus"): + return &kubebindv1alpha2.APIServiceNamespaceStatusApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("BoundAPIResourceSchema"): + return &kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("BoundAPIResourceSchemaSpec"): + return &kubebindv1alpha2.BoundAPIResourceSchemaSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("BoundAPIResourceSchemaStatus"): + return &kubebindv1alpha2.BoundAPIResourceSchemaStatusApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("BoundSchemaReference"): + return &kubebindv1alpha2.BoundSchemaReferenceApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("ClusterBinding"): + return &kubebindv1alpha2.ClusterBindingApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("ClusterBindingSpec"): + return &kubebindv1alpha2.ClusterBindingSpecApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("ClusterBindingStatus"): + return &kubebindv1alpha2.ClusterBindingStatusApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("ClusterSecretKeyRef"): + return &kubebindv1alpha2.ClusterSecretKeyRefApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("CRDVersionSchema"): + return &kubebindv1alpha2.CRDVersionSchemaApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("CustomResourceConversion"): + return &kubebindv1alpha2.CustomResourceConversionApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("GroupResource"): + return &kubebindv1alpha2.GroupResourceApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("LocalSecretKeyRef"): + return &kubebindv1alpha2.LocalSecretKeyRefApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("WebhookClientConfig"): + return &kubebindv1alpha2.WebhookClientConfigApplyConfiguration{} + case v1alpha2.SchemeGroupVersion.WithKind("WebhookConversion"): + return &kubebindv1alpha2.WebhookConversionApplyConfiguration{} + // Group=meta.k8s.io, Version=v1 case v1.SchemeGroupVersion.WithKind("Condition"): return &metav1.ConditionApplyConfiguration{} diff --git a/sdk/kcp/clientset/versioned/clientset.go b/sdk/kcp/clientset/versioned/clientset.go index 6d3a15209..3e8b7d056 100644 --- a/sdk/kcp/clientset/versioned/clientset.go +++ b/sdk/kcp/clientset/versioned/clientset.go @@ -27,17 +27,20 @@ import ( flowcontrol "k8s.io/client-go/util/flowcontrol" kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2" ) type Interface interface { Discovery() discovery.DiscoveryInterface KubeBindV1alpha1() kubebindv1alpha1.KubeBindV1alpha1Interface + KubeBindV1alpha2() kubebindv1alpha2.KubeBindV1alpha2Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient kubeBindV1alpha1 *kubebindv1alpha1.KubeBindV1alpha1Client + kubeBindV1alpha2 *kubebindv1alpha2.KubeBindV1alpha2Client } // KubeBindV1alpha1 retrieves the KubeBindV1alpha1Client @@ -45,6 +48,11 @@ func (c *Clientset) KubeBindV1alpha1() kubebindv1alpha1.KubeBindV1alpha1Interfac return c.kubeBindV1alpha1 } +// KubeBindV1alpha2 retrieves the KubeBindV1alpha2Client +func (c *Clientset) KubeBindV1alpha2() kubebindv1alpha2.KubeBindV1alpha2Interface { + return c.kubeBindV1alpha2 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -93,6 +101,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.kubeBindV1alpha2, err = kubebindv1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -115,6 +127,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.kubeBindV1alpha1 = kubebindv1alpha1.New(c) + cs.kubeBindV1alpha2 = kubebindv1alpha2.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiresourceschema.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiresourceschema.go index 3672294f8..953c45950 100644 --- a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiresourceschema.go +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiresourceschema.go @@ -41,9 +41,9 @@ type APIResourceSchemasClusterGetter interface { } // APIResourceSchemaClusterInterface can operate on APIResourceSchemas across all clusters, -// or scope down to one cluster and return a APIResourceSchemasNamespacer. +// or scope down to one cluster and return a kubebindv1alpha2client.APIResourceSchemaInterface. type APIResourceSchemaClusterInterface interface { - Cluster(logicalcluster.Path) APIResourceSchemasNamespacer + Cluster(logicalcluster.Path) kubebindv1alpha2client.APIResourceSchemaInterface List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIResourceSchemaList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) } @@ -53,34 +53,20 @@ type aPIResourceSchemasClusterInterface struct { } // Cluster scopes the client down to a particular cluster. -func (c *aPIResourceSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) APIResourceSchemasNamespacer { +func (c *aPIResourceSchemasClusterInterface) Cluster(clusterPath logicalcluster.Path) kubebindv1alpha2client.APIResourceSchemaInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } - return &aPIResourceSchemasNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} + return c.clientCache.ClusterOrDie(clusterPath).APIResourceSchemas() } // List returns the entire collection of all APIResourceSchemas across all clusters. func (c *aPIResourceSchemasClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIResourceSchemaList, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIResourceSchemas(metav1.NamespaceAll).List(ctx, opts) + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIResourceSchemas().List(ctx, opts) } // Watch begins to watch all APIResourceSchemas across all clusters. func (c *aPIResourceSchemasClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIResourceSchemas(metav1.NamespaceAll).Watch(ctx, opts) -} - -// APIResourceSchemasNamespacer can scope to objects within a namespace, returning a kubebindv1alpha2client.APIResourceSchemaInterface. -type APIResourceSchemasNamespacer interface { - Namespace(string) kubebindv1alpha2client.APIResourceSchemaInterface -} - -type aPIResourceSchemasNamespacer struct { - clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] - clusterPath logicalcluster.Path -} - -func (n *aPIResourceSchemasNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIResourceSchemaInterface { - return n.clientCache.ClusterOrDie(n.clusterPath).APIResourceSchemas(namespace) + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIResourceSchemas().Watch(ctx, opts) } diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiservicebinding.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..843b2c6c8 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,72 @@ +//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" +) + +// APIServiceBindingsClusterGetter has a method to return a APIServiceBindingClusterInterface. +// A group's cluster client should implement this interface. +type APIServiceBindingsClusterGetter interface { + APIServiceBindings() APIServiceBindingClusterInterface +} + +// APIServiceBindingClusterInterface can operate on APIServiceBindings across all clusters, +// or scope down to one cluster and return a kubebindv1alpha2client.APIServiceBindingInterface. +type APIServiceBindingClusterInterface interface { + Cluster(logicalcluster.Path) kubebindv1alpha2client.APIServiceBindingInterface + List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceBindingList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) +} + +type aPIServiceBindingsClusterInterface struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) kubebindv1alpha2client.APIServiceBindingInterface { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return c.clientCache.ClusterOrDie(clusterPath).APIServiceBindings() +} + +// List returns the entire collection of all APIServiceBindings across all clusters. +func (c *aPIServiceBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceBindingList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceBindings().List(ctx, opts) +} + +// Watch begins to watch all APIServiceBindings across all clusters. +func (c *aPIServiceBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceBindings().Watch(ctx, opts) +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiserviceexport.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..f95cd04a8 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiserviceexport.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" +) + +// APIServiceExportsClusterGetter has a method to return a APIServiceExportClusterInterface. +// A group's cluster client should implement this interface. +type APIServiceExportsClusterGetter interface { + APIServiceExports() APIServiceExportClusterInterface +} + +// APIServiceExportClusterInterface can operate on APIServiceExports across all clusters, +// or scope down to one cluster and return a APIServiceExportsNamespacer. +type APIServiceExportClusterInterface interface { + Cluster(logicalcluster.Path) APIServiceExportsNamespacer + List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) +} + +type aPIServiceExportsClusterInterface struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceExportsClusterInterface) Cluster(clusterPath logicalcluster.Path) APIServiceExportsNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceExportsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} +} + +// List returns the entire collection of all APIServiceExports across all clusters. +func (c *aPIServiceExportsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceExports(metav1.NamespaceAll).List(ctx, opts) +} + +// Watch begins to watch all APIServiceExports across all clusters. +func (c *aPIServiceExportsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceExports(metav1.NamespaceAll).Watch(ctx, opts) +} + +// APIServiceExportsNamespacer can scope to objects within a namespace, returning a kubebindv1alpha2client.APIServiceExportInterface. +type APIServiceExportsNamespacer interface { + Namespace(string) kubebindv1alpha2client.APIServiceExportInterface +} + +type aPIServiceExportsNamespacer struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] + clusterPath logicalcluster.Path +} + +func (n *aPIServiceExportsNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIServiceExportInterface { + return n.clientCache.ClusterOrDie(n.clusterPath).APIServiceExports(namespace) +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..ee6487c70 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiserviceexportrequest.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" +) + +// APIServiceExportRequestsClusterGetter has a method to return a APIServiceExportRequestClusterInterface. +// A group's cluster client should implement this interface. +type APIServiceExportRequestsClusterGetter interface { + APIServiceExportRequests() APIServiceExportRequestClusterInterface +} + +// APIServiceExportRequestClusterInterface can operate on APIServiceExportRequests across all clusters, +// or scope down to one cluster and return a APIServiceExportRequestsNamespacer. +type APIServiceExportRequestClusterInterface interface { + Cluster(logicalcluster.Path) APIServiceExportRequestsNamespacer + List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportRequestList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) +} + +type aPIServiceExportRequestsClusterInterface struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceExportRequestsClusterInterface) Cluster(clusterPath logicalcluster.Path) APIServiceExportRequestsNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceExportRequestsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} +} + +// List returns the entire collection of all APIServiceExportRequests across all clusters. +func (c *aPIServiceExportRequestsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportRequestList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceExportRequests(metav1.NamespaceAll).List(ctx, opts) +} + +// Watch begins to watch all APIServiceExportRequests across all clusters. +func (c *aPIServiceExportRequestsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceExportRequests(metav1.NamespaceAll).Watch(ctx, opts) +} + +// APIServiceExportRequestsNamespacer can scope to objects within a namespace, returning a kubebindv1alpha2client.APIServiceExportRequestInterface. +type APIServiceExportRequestsNamespacer interface { + Namespace(string) kubebindv1alpha2client.APIServiceExportRequestInterface +} + +type aPIServiceExportRequestsNamespacer struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] + clusterPath logicalcluster.Path +} + +func (n *aPIServiceExportRequestsNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIServiceExportRequestInterface { + return n.clientCache.ClusterOrDie(n.clusterPath).APIServiceExportRequests(namespace) +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiservicenamespace.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..dcace1e8b --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/apiservicenamespace.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" +) + +// APIServiceNamespacesClusterGetter has a method to return a APIServiceNamespaceClusterInterface. +// A group's cluster client should implement this interface. +type APIServiceNamespacesClusterGetter interface { + APIServiceNamespaces() APIServiceNamespaceClusterInterface +} + +// APIServiceNamespaceClusterInterface can operate on APIServiceNamespaces across all clusters, +// or scope down to one cluster and return a APIServiceNamespacesNamespacer. +type APIServiceNamespaceClusterInterface interface { + Cluster(logicalcluster.Path) APIServiceNamespacesNamespacer + List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceNamespaceList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) +} + +type aPIServiceNamespacesClusterInterface struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceNamespacesClusterInterface) Cluster(clusterPath logicalcluster.Path) APIServiceNamespacesNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceNamespacesNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} +} + +// List returns the entire collection of all APIServiceNamespaces across all clusters. +func (c *aPIServiceNamespacesClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceNamespaceList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceNamespaces(metav1.NamespaceAll).List(ctx, opts) +} + +// Watch begins to watch all APIServiceNamespaces across all clusters. +func (c *aPIServiceNamespacesClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).APIServiceNamespaces(metav1.NamespaceAll).Watch(ctx, opts) +} + +// APIServiceNamespacesNamespacer can scope to objects within a namespace, returning a kubebindv1alpha2client.APIServiceNamespaceInterface. +type APIServiceNamespacesNamespacer interface { + Namespace(string) kubebindv1alpha2client.APIServiceNamespaceInterface +} + +type aPIServiceNamespacesNamespacer struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] + clusterPath logicalcluster.Path +} + +func (n *aPIServiceNamespacesNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIServiceNamespaceInterface { + return n.clientCache.ClusterOrDie(n.clusterPath).APIServiceNamespaces(namespace) +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/clusterbinding.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..cebabf20c --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/clusterbinding.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" +) + +// ClusterBindingsClusterGetter has a method to return a ClusterBindingClusterInterface. +// A group's cluster client should implement this interface. +type ClusterBindingsClusterGetter interface { + ClusterBindings() ClusterBindingClusterInterface +} + +// ClusterBindingClusterInterface can operate on ClusterBindings across all clusters, +// or scope down to one cluster and return a ClusterBindingsNamespacer. +type ClusterBindingClusterInterface interface { + Cluster(logicalcluster.Path) ClusterBindingsNamespacer + List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.ClusterBindingList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) +} + +type clusterBindingsClusterInterface struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] +} + +// Cluster scopes the client down to a particular cluster. +func (c *clusterBindingsClusterInterface) Cluster(clusterPath logicalcluster.Path) ClusterBindingsNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &clusterBindingsNamespacer{clientCache: c.clientCache, clusterPath: clusterPath} +} + +// List returns the entire collection of all ClusterBindings across all clusters. +func (c *clusterBindingsClusterInterface) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.ClusterBindingList, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterBindings(metav1.NamespaceAll).List(ctx, opts) +} + +// Watch begins to watch all ClusterBindings across all clusters. +func (c *clusterBindingsClusterInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.clientCache.ClusterOrDie(logicalcluster.Wildcard).ClusterBindings(metav1.NamespaceAll).Watch(ctx, opts) +} + +// ClusterBindingsNamespacer can scope to objects within a namespace, returning a kubebindv1alpha2client.ClusterBindingInterface. +type ClusterBindingsNamespacer interface { + Namespace(string) kubebindv1alpha2client.ClusterBindingInterface +} + +type clusterBindingsNamespacer struct { + clientCache kcpclient.Cache[*kubebindv1alpha2client.KubeBindV1alpha2Client] + clusterPath logicalcluster.Path +} + +func (n *clusterBindingsNamespacer) Namespace(namespace string) kubebindv1alpha2client.ClusterBindingInterface { + return n.clientCache.ClusterOrDie(n.clusterPath).ClusterBindings(namespace) +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiresourceschema.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiresourceschema.go index 7bc22b869..726235f59 100644 --- a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiresourceschema.go +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiresourceschema.go @@ -38,7 +38,6 @@ import ( 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" ) @@ -50,17 +49,17 @@ type aPIResourceSchemasClusterClient struct { } // Cluster scopes the client down to a particular cluster. -func (c *aPIResourceSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) kcpkubebindv1alpha2.APIResourceSchemasNamespacer { +func (c *aPIResourceSchemasClusterClient) Cluster(clusterPath logicalcluster.Path) kubebindv1alpha2client.APIResourceSchemaInterface { if clusterPath == logicalcluster.Wildcard { panic("A specific cluster must be provided when scoping, not the wildcard.") } - return &aPIResourceSchemasNamespacer{Fake: c.Fake, ClusterPath: clusterPath} + return &aPIResourceSchemasClient{Fake: c.Fake, ClusterPath: clusterPath} } // List takes label and field selectors, and returns the list of APIResourceSchemas that match those selectors across all clusters. func (c *aPIResourceSchemasClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIResourceSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIResourceSchemasResource, aPIResourceSchemasKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &kubebindv1alpha2.APIResourceSchemaList{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(aPIResourceSchemasResource, aPIResourceSchemasKind, logicalcluster.Wildcard, opts), &kubebindv1alpha2.APIResourceSchemaList{}) if obj == nil { return nil, err } @@ -80,26 +79,16 @@ func (c *aPIResourceSchemasClusterClient) List(ctx context.Context, opts metav1. // Watch returns a watch.Interface that watches the requested APIResourceSchemas across all clusters. func (c *aPIResourceSchemasClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIResourceSchemasResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) -} - -type aPIResourceSchemasNamespacer struct { - *kcptesting.Fake - ClusterPath logicalcluster.Path -} - -func (n *aPIResourceSchemasNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIResourceSchemaInterface { - return &aPIResourceSchemasClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} + return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(aPIResourceSchemasResource, logicalcluster.Wildcard, opts)) } type aPIResourceSchemasClient struct { *kcptesting.Fake ClusterPath logicalcluster.Path - Namespace string } func (c *aPIResourceSchemasClient) Create(ctx context.Context, aPIResourceSchema *kubebindv1alpha2.APIResourceSchema, opts metav1.CreateOptions) (*kubebindv1alpha2.APIResourceSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, aPIResourceSchema), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(aPIResourceSchemasResource, c.ClusterPath, aPIResourceSchema), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } @@ -107,7 +96,7 @@ func (c *aPIResourceSchemasClient) Create(ctx context.Context, aPIResourceSchema } func (c *aPIResourceSchemasClient) Update(ctx context.Context, aPIResourceSchema *kubebindv1alpha2.APIResourceSchema, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIResourceSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, aPIResourceSchema), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(aPIResourceSchemasResource, c.ClusterPath, aPIResourceSchema), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } @@ -115,7 +104,7 @@ func (c *aPIResourceSchemasClient) Update(ctx context.Context, aPIResourceSchema } func (c *aPIResourceSchemasClient) UpdateStatus(ctx context.Context, aPIResourceSchema *kubebindv1alpha2.APIResourceSchema, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIResourceSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, "status", c.Namespace, aPIResourceSchema), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, "status", aPIResourceSchema), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } @@ -123,19 +112,19 @@ func (c *aPIResourceSchemasClient) UpdateStatus(ctx context.Context, aPIResource } func (c *aPIResourceSchemasClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, name, opts), &kubebindv1alpha2.APIResourceSchema{}) + _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(aPIResourceSchemasResource, c.ClusterPath, name, opts), &kubebindv1alpha2.APIResourceSchema{}) return err } func (c *aPIResourceSchemasClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := kcptesting.NewDeleteCollectionAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, listOpts) + action := kcptesting.NewRootDeleteCollectionAction(aPIResourceSchemasResource, c.ClusterPath, listOpts) _, err := c.Fake.Invokes(action, &kubebindv1alpha2.APIResourceSchemaList{}) return err } func (c *aPIResourceSchemasClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.APIResourceSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewGetAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, name), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(aPIResourceSchemasResource, c.ClusterPath, name), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } @@ -144,7 +133,7 @@ func (c *aPIResourceSchemasClient) Get(ctx context.Context, name string, options // List takes label and field selectors, and returns the list of APIResourceSchemas that match those selectors. func (c *aPIResourceSchemasClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIResourceSchemaList, error) { - obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIResourceSchemasResource, aPIResourceSchemasKind, c.ClusterPath, c.Namespace, opts), &kubebindv1alpha2.APIResourceSchemaList{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(aPIResourceSchemasResource, aPIResourceSchemasKind, c.ClusterPath, opts), &kubebindv1alpha2.APIResourceSchemaList{}) if obj == nil { return nil, err } @@ -163,11 +152,11 @@ func (c *aPIResourceSchemasClient) List(ctx context.Context, opts metav1.ListOpt } func (c *aPIResourceSchemasClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, opts)) + return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(aPIResourceSchemasResource, c.ClusterPath, opts)) } func (c *aPIResourceSchemasClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.APIResourceSchema, error) { - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, name, pt, data, subresources...), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } @@ -186,7 +175,7 @@ func (c *aPIResourceSchemasClient) Apply(ctx context.Context, applyConfiguration if name == nil { return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } @@ -205,7 +194,7 @@ func (c *aPIResourceSchemasClient) ApplyStatus(ctx context.Context, applyConfigu if name == nil { return nil, fmt.Errorf("applyConfiguration.Name must be provided to Apply") } - obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.APIResourceSchema{}) + obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(aPIResourceSchemasResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.APIResourceSchema{}) if obj == nil { return nil, err } diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiservicebinding.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiservicebinding.go new file mode 100644 index 000000000..8b71c6729 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiservicebinding.go @@ -0,0 +1,202 @@ +//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" + kubebindv1alpha2client "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2" +) + +var aPIServiceBindingsResource = schema.GroupVersionResource{Group: "kube-bind.io", Version: "v1alpha2", Resource: "apiservicebindings"} +var aPIServiceBindingsKind = schema.GroupVersionKind{Group: "kube-bind.io", Version: "v1alpha2", Kind: "APIServiceBinding"} + +type aPIServiceBindingsClusterClient struct { + *kcptesting.Fake +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) kubebindv1alpha2client.APIServiceBindingInterface { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceBindingsClient{Fake: c.Fake, ClusterPath: clusterPath} +} + +// List takes label and field selectors, and returns the list of APIServiceBindings that match those selectors across all clusters. +func (c *aPIServiceBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceBindingList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(aPIServiceBindingsResource, aPIServiceBindingsKind, logicalcluster.Wildcard, opts), &kubebindv1alpha2.APIServiceBindingList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceBindingList{ListMeta: obj.(*kubebindv1alpha2.APIServiceBindingList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceBindingList).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 APIServiceBindings across all clusters. +func (c *aPIServiceBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(aPIServiceBindingsResource, logicalcluster.Wildcard, opts)) +} + +type aPIServiceBindingsClient struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path +} + +func (c *aPIServiceBindingsClient) Create(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBinding, opts metav1.CreateOptions) (*kubebindv1alpha2.APIServiceBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootCreateAction(aPIServiceBindingsResource, c.ClusterPath, aPIServiceBinding), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} + +func (c *aPIServiceBindingsClient) Update(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBinding, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateAction(aPIServiceBindingsResource, c.ClusterPath, aPIServiceBinding), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} + +func (c *aPIServiceBindingsClient) UpdateStatus(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBinding, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootUpdateSubresourceAction(aPIServiceBindingsResource, c.ClusterPath, "status", aPIServiceBinding), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} + +func (c *aPIServiceBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake.Invokes(kcptesting.NewRootDeleteActionWithOptions(aPIServiceBindingsResource, c.ClusterPath, name, opts), &kubebindv1alpha2.APIServiceBinding{}) + return err +} + +func (c *aPIServiceBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := kcptesting.NewRootDeleteCollectionAction(aPIServiceBindingsResource, c.ClusterPath, listOpts) + + _, err := c.Fake.Invokes(action, &kubebindv1alpha2.APIServiceBindingList{}) + return err +} + +func (c *aPIServiceBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.APIServiceBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootGetAction(aPIServiceBindingsResource, c.ClusterPath, name), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} + +// List takes label and field selectors, and returns the list of APIServiceBindings that match those selectors. +func (c *aPIServiceBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceBindingList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootListAction(aPIServiceBindingsResource, aPIServiceBindingsKind, c.ClusterPath, opts), &kubebindv1alpha2.APIServiceBindingList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceBindingList{ListMeta: obj.(*kubebindv1alpha2.APIServiceBindingList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +func (c *aPIServiceBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewRootWatchAction(aPIServiceBindingsResource, c.ClusterPath, opts)) +} + +func (c *aPIServiceBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.APIServiceBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewRootPatchSubresourceAction(aPIServiceBindingsResource, c.ClusterPath, name, pt, data, subresources...), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} + +func (c *aPIServiceBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceBindingApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceBinding, 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.NewRootPatchSubresourceAction(aPIServiceBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} + +func (c *aPIServiceBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceBindingApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceBinding, 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.NewRootPatchSubresourceAction(aPIServiceBindingsResource, c.ClusterPath, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.APIServiceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceBinding), err +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiserviceexport.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiserviceexport.go new file mode 100644 index 000000000..471863ef8 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiserviceexport.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 aPIServiceExportsResource = schema.GroupVersionResource{Group: "kube-bind.io", Version: "v1alpha2", Resource: "apiserviceexports"} +var aPIServiceExportsKind = schema.GroupVersionKind{Group: "kube-bind.io", Version: "v1alpha2", Kind: "APIServiceExport"} + +type aPIServiceExportsClusterClient struct { + *kcptesting.Fake +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceExportsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpkubebindv1alpha2.APIServiceExportsNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceExportsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +} + +// List takes label and field selectors, and returns the list of APIServiceExports that match those selectors across all clusters. +func (c *aPIServiceExportsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIServiceExportsResource, aPIServiceExportsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &kubebindv1alpha2.APIServiceExportList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceExportList{ListMeta: obj.(*kubebindv1alpha2.APIServiceExportList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceExportList).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 APIServiceExports across all clusters. +func (c *aPIServiceExportsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIServiceExportsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +} + +type aPIServiceExportsNamespacer struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path +} + +func (n *aPIServiceExportsNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIServiceExportInterface { + return &aPIServiceExportsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +} + +type aPIServiceExportsClient struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path + Namespace string +} + +func (c *aPIServiceExportsClient) Create(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExport, opts metav1.CreateOptions) (*kubebindv1alpha2.APIServiceExport, error) { + obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(aPIServiceExportsResource, c.ClusterPath, c.Namespace, aPIServiceExport), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} + +func (c *aPIServiceExportsClient) Update(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExport, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceExport, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(aPIServiceExportsResource, c.ClusterPath, c.Namespace, aPIServiceExport), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} + +func (c *aPIServiceExportsClient) UpdateStatus(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExport, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceExport, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(aPIServiceExportsResource, c.ClusterPath, "status", c.Namespace, aPIServiceExport), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} + +func (c *aPIServiceExportsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(aPIServiceExportsResource, c.ClusterPath, c.Namespace, name, opts), &kubebindv1alpha2.APIServiceExport{}) + return err +} + +func (c *aPIServiceExportsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := kcptesting.NewDeleteCollectionAction(aPIServiceExportsResource, c.ClusterPath, c.Namespace, listOpts) + + _, err := c.Fake.Invokes(action, &kubebindv1alpha2.APIServiceExportList{}) + return err +} + +func (c *aPIServiceExportsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.APIServiceExport, error) { + obj, err := c.Fake.Invokes(kcptesting.NewGetAction(aPIServiceExportsResource, c.ClusterPath, c.Namespace, name), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} + +// List takes label and field selectors, and returns the list of APIServiceExports that match those selectors. +func (c *aPIServiceExportsClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIServiceExportsResource, aPIServiceExportsKind, c.ClusterPath, c.Namespace, opts), &kubebindv1alpha2.APIServiceExportList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceExportList{ListMeta: obj.(*kubebindv1alpha2.APIServiceExportList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceExportList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +func (c *aPIServiceExportsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIServiceExportsResource, c.ClusterPath, c.Namespace, opts)) +} + +func (c *aPIServiceExportsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.APIServiceExport, error) { + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(aPIServiceExportsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} + +func (c *aPIServiceExportsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceExportApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceExport, 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(aPIServiceExportsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} + +func (c *aPIServiceExportsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceExportApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceExport, 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(aPIServiceExportsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.APIServiceExport{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExport), err +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiserviceexportrequest.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiserviceexportrequest.go new file mode 100644 index 000000000..d37825d1d --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiserviceexportrequest.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 aPIServiceExportRequestsResource = schema.GroupVersionResource{Group: "kube-bind.io", Version: "v1alpha2", Resource: "apiserviceexportrequests"} +var aPIServiceExportRequestsKind = schema.GroupVersionKind{Group: "kube-bind.io", Version: "v1alpha2", Kind: "APIServiceExportRequest"} + +type aPIServiceExportRequestsClusterClient struct { + *kcptesting.Fake +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceExportRequestsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpkubebindv1alpha2.APIServiceExportRequestsNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceExportRequestsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +} + +// List takes label and field selectors, and returns the list of APIServiceExportRequests that match those selectors across all clusters. +func (c *aPIServiceExportRequestsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportRequestList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIServiceExportRequestsResource, aPIServiceExportRequestsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &kubebindv1alpha2.APIServiceExportRequestList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceExportRequestList{ListMeta: obj.(*kubebindv1alpha2.APIServiceExportRequestList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceExportRequestList).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 APIServiceExportRequests across all clusters. +func (c *aPIServiceExportRequestsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIServiceExportRequestsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +} + +type aPIServiceExportRequestsNamespacer struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path +} + +func (n *aPIServiceExportRequestsNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIServiceExportRequestInterface { + return &aPIServiceExportRequestsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +} + +type aPIServiceExportRequestsClient struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path + Namespace string +} + +func (c *aPIServiceExportRequestsClient) Create(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequest, opts metav1.CreateOptions) (*kubebindv1alpha2.APIServiceExportRequest, error) { + obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, aPIServiceExportRequest), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} + +func (c *aPIServiceExportRequestsClient) Update(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequest, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceExportRequest, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, aPIServiceExportRequest), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} + +func (c *aPIServiceExportRequestsClient) UpdateStatus(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequest, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceExportRequest, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(aPIServiceExportRequestsResource, c.ClusterPath, "status", c.Namespace, aPIServiceExportRequest), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} + +func (c *aPIServiceExportRequestsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, name, opts), &kubebindv1alpha2.APIServiceExportRequest{}) + return err +} + +func (c *aPIServiceExportRequestsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := kcptesting.NewDeleteCollectionAction(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, listOpts) + + _, err := c.Fake.Invokes(action, &kubebindv1alpha2.APIServiceExportRequestList{}) + return err +} + +func (c *aPIServiceExportRequestsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.APIServiceExportRequest, error) { + obj, err := c.Fake.Invokes(kcptesting.NewGetAction(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, name), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} + +// List takes label and field selectors, and returns the list of APIServiceExportRequests that match those selectors. +func (c *aPIServiceExportRequestsClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceExportRequestList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIServiceExportRequestsResource, aPIServiceExportRequestsKind, c.ClusterPath, c.Namespace, opts), &kubebindv1alpha2.APIServiceExportRequestList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceExportRequestList{ListMeta: obj.(*kubebindv1alpha2.APIServiceExportRequestList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceExportRequestList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +func (c *aPIServiceExportRequestsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, opts)) +} + +func (c *aPIServiceExportRequestsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.APIServiceExportRequest, error) { + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} + +func (c *aPIServiceExportRequestsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceExportRequestApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceExportRequest, 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(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} + +func (c *aPIServiceExportRequestsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceExportRequestApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceExportRequest, 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(aPIServiceExportRequestsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.APIServiceExportRequest{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), err +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiservicenamespace.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiservicenamespace.go new file mode 100644 index 000000000..c6f7f83a6 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/apiservicenamespace.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 aPIServiceNamespacesResource = schema.GroupVersionResource{Group: "kube-bind.io", Version: "v1alpha2", Resource: "apiservicenamespaces"} +var aPIServiceNamespacesKind = schema.GroupVersionKind{Group: "kube-bind.io", Version: "v1alpha2", Kind: "APIServiceNamespace"} + +type aPIServiceNamespacesClusterClient struct { + *kcptesting.Fake +} + +// Cluster scopes the client down to a particular cluster. +func (c *aPIServiceNamespacesClusterClient) Cluster(clusterPath logicalcluster.Path) kcpkubebindv1alpha2.APIServiceNamespacesNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &aPIServiceNamespacesNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +} + +// List takes label and field selectors, and returns the list of APIServiceNamespaces that match those selectors across all clusters. +func (c *aPIServiceNamespacesClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceNamespaceList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIServiceNamespacesResource, aPIServiceNamespacesKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &kubebindv1alpha2.APIServiceNamespaceList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceNamespaceList{ListMeta: obj.(*kubebindv1alpha2.APIServiceNamespaceList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceNamespaceList).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 APIServiceNamespaces across all clusters. +func (c *aPIServiceNamespacesClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIServiceNamespacesResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +} + +type aPIServiceNamespacesNamespacer struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path +} + +func (n *aPIServiceNamespacesNamespacer) Namespace(namespace string) kubebindv1alpha2client.APIServiceNamespaceInterface { + return &aPIServiceNamespacesClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +} + +type aPIServiceNamespacesClient struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path + Namespace string +} + +func (c *aPIServiceNamespacesClient) Create(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespace, opts metav1.CreateOptions) (*kubebindv1alpha2.APIServiceNamespace, error) { + obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, aPIServiceNamespace), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} + +func (c *aPIServiceNamespacesClient) Update(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespace, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceNamespace, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, aPIServiceNamespace), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} + +func (c *aPIServiceNamespacesClient) UpdateStatus(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespace, opts metav1.UpdateOptions) (*kubebindv1alpha2.APIServiceNamespace, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(aPIServiceNamespacesResource, c.ClusterPath, "status", c.Namespace, aPIServiceNamespace), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} + +func (c *aPIServiceNamespacesClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, name, opts), &kubebindv1alpha2.APIServiceNamespace{}) + return err +} + +func (c *aPIServiceNamespacesClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := kcptesting.NewDeleteCollectionAction(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, listOpts) + + _, err := c.Fake.Invokes(action, &kubebindv1alpha2.APIServiceNamespaceList{}) + return err +} + +func (c *aPIServiceNamespacesClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.APIServiceNamespace, error) { + obj, err := c.Fake.Invokes(kcptesting.NewGetAction(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, name), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} + +// List takes label and field selectors, and returns the list of APIServiceNamespaces that match those selectors. +func (c *aPIServiceNamespacesClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.APIServiceNamespaceList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(aPIServiceNamespacesResource, aPIServiceNamespacesKind, c.ClusterPath, c.Namespace, opts), &kubebindv1alpha2.APIServiceNamespaceList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.APIServiceNamespaceList{ListMeta: obj.(*kubebindv1alpha2.APIServiceNamespaceList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.APIServiceNamespaceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +func (c *aPIServiceNamespacesClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, opts)) +} + +func (c *aPIServiceNamespacesClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.APIServiceNamespace, error) { + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} + +func (c *aPIServiceNamespacesClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceNamespaceApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceNamespace, 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(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} + +func (c *aPIServiceNamespacesClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.APIServiceNamespaceApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.APIServiceNamespace, 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(aPIServiceNamespacesResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.APIServiceNamespace{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), err +} diff --git a/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/clusterbinding.go b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/clusterbinding.go new file mode 100644 index 000000000..4e0305bd6 --- /dev/null +++ b/sdk/kcp/clientset/versioned/cluster/typed/kubebind/v1alpha2/fake/clusterbinding.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 clusterBindingsResource = schema.GroupVersionResource{Group: "kube-bind.io", Version: "v1alpha2", Resource: "clusterbindings"} +var clusterBindingsKind = schema.GroupVersionKind{Group: "kube-bind.io", Version: "v1alpha2", Kind: "ClusterBinding"} + +type clusterBindingsClusterClient struct { + *kcptesting.Fake +} + +// Cluster scopes the client down to a particular cluster. +func (c *clusterBindingsClusterClient) Cluster(clusterPath logicalcluster.Path) kcpkubebindv1alpha2.ClusterBindingsNamespacer { + if clusterPath == logicalcluster.Wildcard { + panic("A specific cluster must be provided when scoping, not the wildcard.") + } + + return &clusterBindingsNamespacer{Fake: c.Fake, ClusterPath: clusterPath} +} + +// List takes label and field selectors, and returns the list of ClusterBindings that match those selectors across all clusters. +func (c *clusterBindingsClusterClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.ClusterBindingList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(clusterBindingsResource, clusterBindingsKind, logicalcluster.Wildcard, metav1.NamespaceAll, opts), &kubebindv1alpha2.ClusterBindingList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.ClusterBindingList{ListMeta: obj.(*kubebindv1alpha2.ClusterBindingList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.ClusterBindingList).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 ClusterBindings across all clusters. +func (c *clusterBindingsClusterClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(clusterBindingsResource, logicalcluster.Wildcard, metav1.NamespaceAll, opts)) +} + +type clusterBindingsNamespacer struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path +} + +func (n *clusterBindingsNamespacer) Namespace(namespace string) kubebindv1alpha2client.ClusterBindingInterface { + return &clusterBindingsClient{Fake: n.Fake, ClusterPath: n.ClusterPath, Namespace: namespace} +} + +type clusterBindingsClient struct { + *kcptesting.Fake + ClusterPath logicalcluster.Path + Namespace string +} + +func (c *clusterBindingsClient) Create(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding, opts metav1.CreateOptions) (*kubebindv1alpha2.ClusterBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewCreateAction(clusterBindingsResource, c.ClusterPath, c.Namespace, clusterBinding), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), err +} + +func (c *clusterBindingsClient) Update(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding, opts metav1.UpdateOptions) (*kubebindv1alpha2.ClusterBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateAction(clusterBindingsResource, c.ClusterPath, c.Namespace, clusterBinding), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), err +} + +func (c *clusterBindingsClient) UpdateStatus(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBinding, opts metav1.UpdateOptions) (*kubebindv1alpha2.ClusterBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewUpdateSubresourceAction(clusterBindingsResource, c.ClusterPath, "status", c.Namespace, clusterBinding), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), err +} + +func (c *clusterBindingsClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + _, err := c.Fake.Invokes(kcptesting.NewDeleteActionWithOptions(clusterBindingsResource, c.ClusterPath, c.Namespace, name, opts), &kubebindv1alpha2.ClusterBinding{}) + return err +} + +func (c *clusterBindingsClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + action := kcptesting.NewDeleteCollectionAction(clusterBindingsResource, c.ClusterPath, c.Namespace, listOpts) + + _, err := c.Fake.Invokes(action, &kubebindv1alpha2.ClusterBindingList{}) + return err +} + +func (c *clusterBindingsClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*kubebindv1alpha2.ClusterBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewGetAction(clusterBindingsResource, c.ClusterPath, c.Namespace, name), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), err +} + +// List takes label and field selectors, and returns the list of ClusterBindings that match those selectors. +func (c *clusterBindingsClient) List(ctx context.Context, opts metav1.ListOptions) (*kubebindv1alpha2.ClusterBindingList, error) { + obj, err := c.Fake.Invokes(kcptesting.NewListAction(clusterBindingsResource, clusterBindingsKind, c.ClusterPath, c.Namespace, opts), &kubebindv1alpha2.ClusterBindingList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &kubebindv1alpha2.ClusterBindingList{ListMeta: obj.(*kubebindv1alpha2.ClusterBindingList).ListMeta} + for _, item := range obj.(*kubebindv1alpha2.ClusterBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +func (c *clusterBindingsClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return c.Fake.InvokesWatch(kcptesting.NewWatchAction(clusterBindingsResource, c.ClusterPath, c.Namespace, opts)) +} + +func (c *clusterBindingsClient) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kubebindv1alpha2.ClusterBinding, error) { + obj, err := c.Fake.Invokes(kcptesting.NewPatchSubresourceAction(clusterBindingsResource, c.ClusterPath, c.Namespace, name, pt, data, subresources...), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), err +} + +func (c *clusterBindingsClient) Apply(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.ClusterBindingApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.ClusterBinding, 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(clusterBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), err +} + +func (c *clusterBindingsClient) ApplyStatus(ctx context.Context, applyConfiguration *applyconfigurationskubebindv1alpha2.ClusterBindingApplyConfiguration, opts metav1.ApplyOptions) (*kubebindv1alpha2.ClusterBinding, 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(clusterBindingsResource, c.ClusterPath, c.Namespace, *name, types.ApplyPatchType, data, "status"), &kubebindv1alpha2.ClusterBinding{}) + if obj == nil { + return nil, err + } + return obj.(*kubebindv1alpha2.ClusterBinding), 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 c65e1fbda..022e80d23 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,10 +48,30 @@ func (c *KubeBindV1alpha2ClusterClient) APIResourceSchemas() kcpkubebindv1alpha2 return &aPIResourceSchemasClusterClient{Fake: c.Fake} } +func (c *KubeBindV1alpha2ClusterClient) APIServiceBindings() kcpkubebindv1alpha2.APIServiceBindingClusterInterface { + return &aPIServiceBindingsClusterClient{Fake: c.Fake} +} + +func (c *KubeBindV1alpha2ClusterClient) APIServiceExports() kcpkubebindv1alpha2.APIServiceExportClusterInterface { + return &aPIServiceExportsClusterClient{Fake: c.Fake} +} + +func (c *KubeBindV1alpha2ClusterClient) APIServiceExportRequests() kcpkubebindv1alpha2.APIServiceExportRequestClusterInterface { + return &aPIServiceExportRequestsClusterClient{Fake: c.Fake} +} + +func (c *KubeBindV1alpha2ClusterClient) APIServiceNamespaces() kcpkubebindv1alpha2.APIServiceNamespaceClusterInterface { + return &aPIServiceNamespacesClusterClient{Fake: c.Fake} +} + func (c *KubeBindV1alpha2ClusterClient) BoundAPIResourceSchemas() kcpkubebindv1alpha2.BoundAPIResourceSchemaClusterInterface { return &boundAPIResourceSchemasClusterClient{Fake: c.Fake} } +func (c *KubeBindV1alpha2ClusterClient) ClusterBindings() kcpkubebindv1alpha2.ClusterBindingClusterInterface { + return &clusterBindingsClusterClient{Fake: c.Fake} +} + var _ kubebindv1alpha2.KubeBindV1alpha2Interface = (*KubeBindV1alpha2Client)(nil) type KubeBindV1alpha2Client struct { @@ -64,10 +84,30 @@ func (c *KubeBindV1alpha2Client) RESTClient() rest.Interface { return ret } -func (c *KubeBindV1alpha2Client) APIResourceSchemas(namespace string) kubebindv1alpha2.APIResourceSchemaInterface { - return &aPIResourceSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +func (c *KubeBindV1alpha2Client) APIResourceSchemas() kubebindv1alpha2.APIResourceSchemaInterface { + return &aPIResourceSchemasClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +} + +func (c *KubeBindV1alpha2Client) APIServiceBindings() kubebindv1alpha2.APIServiceBindingInterface { + return &aPIServiceBindingsClient{Fake: c.Fake, ClusterPath: c.ClusterPath} +} + +func (c *KubeBindV1alpha2Client) APIServiceExports(namespace string) kubebindv1alpha2.APIServiceExportInterface { + return &aPIServiceExportsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +} + +func (c *KubeBindV1alpha2Client) APIServiceExportRequests(namespace string) kubebindv1alpha2.APIServiceExportRequestInterface { + return &aPIServiceExportRequestsClient{Fake: c.Fake, ClusterPath: c.ClusterPath, Namespace: namespace} +} + +func (c *KubeBindV1alpha2Client) APIServiceNamespaces(namespace string) kubebindv1alpha2.APIServiceNamespaceInterface { + return &aPIServiceNamespacesClient{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} } + +func (c *KubeBindV1alpha2Client) ClusterBindings(namespace string) kubebindv1alpha2.ClusterBindingInterface { + return &clusterBindingsClient{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 916341162..91297a0f2 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,7 +35,12 @@ import ( type KubeBindV1alpha2ClusterInterface interface { KubeBindV1alpha2ClusterScoper APIResourceSchemasClusterGetter + APIServiceBindingsClusterGetter + APIServiceExportsClusterGetter + APIServiceExportRequestsClusterGetter + APIServiceNamespacesClusterGetter BoundAPIResourceSchemasClusterGetter + ClusterBindingsClusterGetter } type KubeBindV1alpha2ClusterScoper interface { @@ -57,10 +62,30 @@ func (c *KubeBindV1alpha2ClusterClient) APIResourceSchemas() APIResourceSchemaCl return &aPIResourceSchemasClusterInterface{clientCache: c.clientCache} } +func (c *KubeBindV1alpha2ClusterClient) APIServiceBindings() APIServiceBindingClusterInterface { + return &aPIServiceBindingsClusterInterface{clientCache: c.clientCache} +} + +func (c *KubeBindV1alpha2ClusterClient) APIServiceExports() APIServiceExportClusterInterface { + return &aPIServiceExportsClusterInterface{clientCache: c.clientCache} +} + +func (c *KubeBindV1alpha2ClusterClient) APIServiceExportRequests() APIServiceExportRequestClusterInterface { + return &aPIServiceExportRequestsClusterInterface{clientCache: c.clientCache} +} + +func (c *KubeBindV1alpha2ClusterClient) APIServiceNamespaces() APIServiceNamespaceClusterInterface { + return &aPIServiceNamespacesClusterInterface{clientCache: c.clientCache} +} + func (c *KubeBindV1alpha2ClusterClient) BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInterface { return &boundAPIResourceSchemasClusterInterface{clientCache: c.clientCache} } +func (c *KubeBindV1alpha2ClusterClient) ClusterBindings() ClusterBindingClusterInterface { + return &clusterBindingsClusterInterface{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/clientset/versioned/fake/clientset_generated.go b/sdk/kcp/clientset/versioned/fake/clientset_generated.go index 552c21297..2c333ee06 100644 --- a/sdk/kcp/clientset/versioned/fake/clientset_generated.go +++ b/sdk/kcp/clientset/versioned/fake/clientset_generated.go @@ -29,6 +29,8 @@ import ( clientset "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned" kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha1" fakekubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha1/fake" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2" + fakekubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -121,3 +123,8 @@ var ( func (c *Clientset) KubeBindV1alpha1() kubebindv1alpha1.KubeBindV1alpha1Interface { return &fakekubebindv1alpha1.FakeKubeBindV1alpha1{Fake: &c.Fake} } + +// KubeBindV1alpha2 retrieves the KubeBindV1alpha2Client +func (c *Clientset) KubeBindV1alpha2() kubebindv1alpha2.KubeBindV1alpha2Interface { + return &fakekubebindv1alpha2.FakeKubeBindV1alpha2{Fake: &c.Fake} +} diff --git a/sdk/kcp/clientset/versioned/fake/register.go b/sdk/kcp/clientset/versioned/fake/register.go index aa66902d2..8b9cd94fc 100644 --- a/sdk/kcp/clientset/versioned/fake/register.go +++ b/sdk/kcp/clientset/versioned/fake/register.go @@ -26,6 +26,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) var scheme = runtime.NewScheme() @@ -33,6 +34,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ kubebindv1alpha1.AddToScheme, + kubebindv1alpha2.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/sdk/kcp/clientset/versioned/scheme/register.go b/sdk/kcp/clientset/versioned/scheme/register.go index 0f13a578f..842408bf9 100644 --- a/sdk/kcp/clientset/versioned/scheme/register.go +++ b/sdk/kcp/clientset/versioned/scheme/register.go @@ -26,6 +26,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) var Scheme = runtime.NewScheme() @@ -33,6 +34,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ kubebindv1alpha1.AddToScheme, + kubebindv1alpha2.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.go new file mode 100644 index 000000000..3a86eb418 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiresourceschema.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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +// APIResourceSchemasGetter has a method to return a APIResourceSchemaInterface. +// A group's client should implement this interface. +type APIResourceSchemasGetter interface { + APIResourceSchemas() APIResourceSchemaInterface +} + +// APIResourceSchemaInterface has methods to work with APIResourceSchema resources. +type APIResourceSchemaInterface interface { + Create(ctx context.Context, aPIResourceSchema *v1alpha2.APIResourceSchema, opts v1.CreateOptions) (*v1alpha2.APIResourceSchema, error) + Update(ctx context.Context, aPIResourceSchema *v1alpha2.APIResourceSchema, opts v1.UpdateOptions) (*v1alpha2.APIResourceSchema, 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.APIResourceSchema, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIResourceSchemaList, 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.APIResourceSchema, err error) + Apply(ctx context.Context, aPIResourceSchema *kubebindv1alpha2.APIResourceSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIResourceSchema, err error) + APIResourceSchemaExpansion +} + +// aPIResourceSchemas implements APIResourceSchemaInterface +type aPIResourceSchemas struct { + *gentype.ClientWithListAndApply[*v1alpha2.APIResourceSchema, *v1alpha2.APIResourceSchemaList, *kubebindv1alpha2.APIResourceSchemaApplyConfiguration] +} + +// newAPIResourceSchemas returns a APIResourceSchemas +func newAPIResourceSchemas(c *KubeBindV1alpha2Client) *aPIResourceSchemas { + return &aPIResourceSchemas{ + gentype.NewClientWithListAndApply[*v1alpha2.APIResourceSchema, *v1alpha2.APIResourceSchemaList, *kubebindv1alpha2.APIResourceSchemaApplyConfiguration]( + "apiresourceschemas", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *v1alpha2.APIResourceSchema { return &v1alpha2.APIResourceSchema{} }, + func() *v1alpha2.APIResourceSchemaList { return &v1alpha2.APIResourceSchemaList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiservicebinding.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..76406a276 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,74 @@ +/* +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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +// APIServiceBindingsGetter has a method to return a APIServiceBindingInterface. +// A group's client should implement this interface. +type APIServiceBindingsGetter interface { + APIServiceBindings() APIServiceBindingInterface +} + +// APIServiceBindingInterface has methods to work with APIServiceBinding resources. +type APIServiceBindingInterface interface { + Create(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.CreateOptions) (*v1alpha2.APIServiceBinding, error) + Update(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (*v1alpha2.APIServiceBinding, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (*v1alpha2.APIServiceBinding, 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.APIServiceBinding, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceBindingList, 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.APIServiceBinding, err error) + Apply(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceBinding, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceBinding, err error) + APIServiceBindingExpansion +} + +// aPIServiceBindings implements APIServiceBindingInterface +type aPIServiceBindings struct { + *gentype.ClientWithListAndApply[*v1alpha2.APIServiceBinding, *v1alpha2.APIServiceBindingList, *kubebindv1alpha2.APIServiceBindingApplyConfiguration] +} + +// newAPIServiceBindings returns a APIServiceBindings +func newAPIServiceBindings(c *KubeBindV1alpha2Client) *aPIServiceBindings { + return &aPIServiceBindings{ + gentype.NewClientWithListAndApply[*v1alpha2.APIServiceBinding, *v1alpha2.APIServiceBindingList, *kubebindv1alpha2.APIServiceBindingApplyConfiguration]( + "apiservicebindings", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *v1alpha2.APIServiceBinding { return &v1alpha2.APIServiceBinding{} }, + func() *v1alpha2.APIServiceBindingList { return &v1alpha2.APIServiceBindingList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexport.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..6f7f995ab --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexport.go @@ -0,0 +1,74 @@ +/* +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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +// APIServiceExportsGetter has a method to return a APIServiceExportInterface. +// A group's client should implement this interface. +type APIServiceExportsGetter interface { + APIServiceExports(namespace string) APIServiceExportInterface +} + +// APIServiceExportInterface has methods to work with APIServiceExport resources. +type APIServiceExportInterface interface { + Create(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.CreateOptions) (*v1alpha2.APIServiceExport, error) + Update(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (*v1alpha2.APIServiceExport, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (*v1alpha2.APIServiceExport, 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.APIServiceExport, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceExportList, 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.APIServiceExport, err error) + Apply(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExportApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExport, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExportApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExport, err error) + APIServiceExportExpansion +} + +// aPIServiceExports implements APIServiceExportInterface +type aPIServiceExports struct { + *gentype.ClientWithListAndApply[*v1alpha2.APIServiceExport, *v1alpha2.APIServiceExportList, *kubebindv1alpha2.APIServiceExportApplyConfiguration] +} + +// newAPIServiceExports returns a APIServiceExports +func newAPIServiceExports(c *KubeBindV1alpha2Client, namespace string) *aPIServiceExports { + return &aPIServiceExports{ + gentype.NewClientWithListAndApply[*v1alpha2.APIServiceExport, *v1alpha2.APIServiceExportList, *kubebindv1alpha2.APIServiceExportApplyConfiguration]( + "apiserviceexports", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.APIServiceExport { return &v1alpha2.APIServiceExport{} }, + func() *v1alpha2.APIServiceExportList { return &v1alpha2.APIServiceExportList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..bc8286791 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiserviceexportrequest.go @@ -0,0 +1,74 @@ +/* +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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +// APIServiceExportRequestsGetter has a method to return a APIServiceExportRequestInterface. +// A group's client should implement this interface. +type APIServiceExportRequestsGetter interface { + APIServiceExportRequests(namespace string) APIServiceExportRequestInterface +} + +// APIServiceExportRequestInterface has methods to work with APIServiceExportRequest resources. +type APIServiceExportRequestInterface interface { + Create(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.CreateOptions) (*v1alpha2.APIServiceExportRequest, error) + Update(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (*v1alpha2.APIServiceExportRequest, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (*v1alpha2.APIServiceExportRequest, 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.APIServiceExportRequest, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceExportRequestList, 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.APIServiceExportRequest, err error) + Apply(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequestApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExportRequest, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequestApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExportRequest, err error) + APIServiceExportRequestExpansion +} + +// aPIServiceExportRequests implements APIServiceExportRequestInterface +type aPIServiceExportRequests struct { + *gentype.ClientWithListAndApply[*v1alpha2.APIServiceExportRequest, *v1alpha2.APIServiceExportRequestList, *kubebindv1alpha2.APIServiceExportRequestApplyConfiguration] +} + +// newAPIServiceExportRequests returns a APIServiceExportRequests +func newAPIServiceExportRequests(c *KubeBindV1alpha2Client, namespace string) *aPIServiceExportRequests { + return &aPIServiceExportRequests{ + gentype.NewClientWithListAndApply[*v1alpha2.APIServiceExportRequest, *v1alpha2.APIServiceExportRequestList, *kubebindv1alpha2.APIServiceExportRequestApplyConfiguration]( + "apiserviceexportrequests", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.APIServiceExportRequest { return &v1alpha2.APIServiceExportRequest{} }, + func() *v1alpha2.APIServiceExportRequestList { return &v1alpha2.APIServiceExportRequestList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiservicenamespace.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..2d904b0fa --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/apiservicenamespace.go @@ -0,0 +1,74 @@ +/* +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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +// APIServiceNamespacesGetter has a method to return a APIServiceNamespaceInterface. +// A group's client should implement this interface. +type APIServiceNamespacesGetter interface { + APIServiceNamespaces(namespace string) APIServiceNamespaceInterface +} + +// APIServiceNamespaceInterface has methods to work with APIServiceNamespace resources. +type APIServiceNamespaceInterface interface { + Create(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.CreateOptions) (*v1alpha2.APIServiceNamespace, error) + Update(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (*v1alpha2.APIServiceNamespace, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (*v1alpha2.APIServiceNamespace, 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.APIServiceNamespace, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.APIServiceNamespaceList, 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.APIServiceNamespace, err error) + Apply(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceNamespace, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceNamespace, err error) + APIServiceNamespaceExpansion +} + +// aPIServiceNamespaces implements APIServiceNamespaceInterface +type aPIServiceNamespaces struct { + *gentype.ClientWithListAndApply[*v1alpha2.APIServiceNamespace, *v1alpha2.APIServiceNamespaceList, *kubebindv1alpha2.APIServiceNamespaceApplyConfiguration] +} + +// newAPIServiceNamespaces returns a APIServiceNamespaces +func newAPIServiceNamespaces(c *KubeBindV1alpha2Client, namespace string) *aPIServiceNamespaces { + return &aPIServiceNamespaces{ + gentype.NewClientWithListAndApply[*v1alpha2.APIServiceNamespace, *v1alpha2.APIServiceNamespaceList, *kubebindv1alpha2.APIServiceNamespaceApplyConfiguration]( + "apiservicenamespaces", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.APIServiceNamespace { return &v1alpha2.APIServiceNamespace{} }, + func() *v1alpha2.APIServiceNamespaceList { return &v1alpha2.APIServiceNamespaceList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/boundapiresourceschema.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/boundapiresourceschema.go new file mode 100644 index 000000000..0ac962be1 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/boundapiresourceschema.go @@ -0,0 +1,74 @@ +/* +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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/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) + Apply(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) + BoundAPIResourceSchemaExpansion +} + +// boundAPIResourceSchemas implements BoundAPIResourceSchemaInterface +type boundAPIResourceSchemas struct { + *gentype.ClientWithListAndApply[*v1alpha2.BoundAPIResourceSchema, *v1alpha2.BoundAPIResourceSchemaList, *kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration] +} + +// newBoundAPIResourceSchemas returns a BoundAPIResourceSchemas +func newBoundAPIResourceSchemas(c *KubeBindV1alpha2Client, namespace string) *boundAPIResourceSchemas { + return &boundAPIResourceSchemas{ + gentype.NewClientWithListAndApply[*v1alpha2.BoundAPIResourceSchema, *v1alpha2.BoundAPIResourceSchemaList, *kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration]( + "boundapiresourceschemas", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.BoundAPIResourceSchema { return &v1alpha2.BoundAPIResourceSchema{} }, + func() *v1alpha2.BoundAPIResourceSchemaList { return &v1alpha2.BoundAPIResourceSchemaList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/clusterbinding.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..5035bba26 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/clusterbinding.go @@ -0,0 +1,74 @@ +/* +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-v0.31. 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +// ClusterBindingsGetter has a method to return a ClusterBindingInterface. +// A group's client should implement this interface. +type ClusterBindingsGetter interface { + ClusterBindings(namespace string) ClusterBindingInterface +} + +// ClusterBindingInterface has methods to work with ClusterBinding resources. +type ClusterBindingInterface interface { + Create(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.CreateOptions) (*v1alpha2.ClusterBinding, error) + Update(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (*v1alpha2.ClusterBinding, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (*v1alpha2.ClusterBinding, 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.ClusterBinding, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ClusterBindingList, 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.ClusterBinding, err error) + Apply(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ClusterBinding, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ClusterBinding, err error) + ClusterBindingExpansion +} + +// clusterBindings implements ClusterBindingInterface +type clusterBindings struct { + *gentype.ClientWithListAndApply[*v1alpha2.ClusterBinding, *v1alpha2.ClusterBindingList, *kubebindv1alpha2.ClusterBindingApplyConfiguration] +} + +// newClusterBindings returns a ClusterBindings +func newClusterBindings(c *KubeBindV1alpha2Client, namespace string) *clusterBindings { + return &clusterBindings{ + gentype.NewClientWithListAndApply[*v1alpha2.ClusterBinding, *v1alpha2.ClusterBindingList, *kubebindv1alpha2.ClusterBindingApplyConfiguration]( + "clusterbindings", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.ClusterBinding { return &v1alpha2.ClusterBinding{} }, + func() *v1alpha2.ClusterBindingList { return &v1alpha2.ClusterBindingList{} }), + } +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/doc.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/doc.go new file mode 100644 index 000000000..b63a5d789 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/doc.go @@ -0,0 +1,20 @@ +/* +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-v0.31. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha2 diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/doc.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/doc.go new file mode 100644 index 000000000..973c8cb9b --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/doc.go @@ -0,0 +1,20 @@ +/* +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-v0.31. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go new file mode 100644 index 000000000..9cef40875 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiresourceschema.go @@ -0,0 +1,152 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" +) + +// FakeAPIResourceSchemas implements APIResourceSchemaInterface +type FakeAPIResourceSchemas struct { + Fake *FakeKubeBindV1alpha2 +} + +var apiresourceschemasResource = v1alpha2.SchemeGroupVersion.WithResource("apiresourceschemas") + +var apiresourceschemasKind = v1alpha2.SchemeGroupVersion.WithKind("APIResourceSchema") + +// Get takes name of the aPIResourceSchema, and returns the corresponding aPIResourceSchema object, and an error if there is any. +func (c *FakeAPIResourceSchemas) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIResourceSchema, err error) { + emptyResult := &v1alpha2.APIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewRootGetActionWithOptions(apiresourceschemasResource, name, options), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIResourceSchema), err +} + +// List takes label and field selectors, and returns the list of APIResourceSchemas that match those selectors. +func (c *FakeAPIResourceSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIResourceSchemaList, err error) { + emptyResult := &v1alpha2.APIResourceSchemaList{} + obj, err := c.Fake. + Invokes(testing.NewRootListActionWithOptions(apiresourceschemasResource, apiresourceschemasKind, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIResourceSchemaList{ListMeta: obj.(*v1alpha2.APIResourceSchemaList).ListMeta} + for _, item := range obj.(*v1alpha2.APIResourceSchemaList).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 aPIResourceSchemas. +func (c *FakeAPIResourceSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchActionWithOptions(apiresourceschemasResource, opts)) +} + +// Create takes the representation of a aPIResourceSchema and creates it. Returns the server's representation of the aPIResourceSchema, and an error, if there is any. +func (c *FakeAPIResourceSchemas) Create(ctx context.Context, aPIResourceSchema *v1alpha2.APIResourceSchema, opts v1.CreateOptions) (result *v1alpha2.APIResourceSchema, err error) { + emptyResult := &v1alpha2.APIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewRootCreateActionWithOptions(apiresourceschemasResource, aPIResourceSchema, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIResourceSchema), err +} + +// Update takes the representation of a aPIResourceSchema and updates it. Returns the server's representation of the aPIResourceSchema, and an error, if there is any. +func (c *FakeAPIResourceSchemas) Update(ctx context.Context, aPIResourceSchema *v1alpha2.APIResourceSchema, opts v1.UpdateOptions) (result *v1alpha2.APIResourceSchema, err error) { + emptyResult := &v1alpha2.APIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewRootUpdateActionWithOptions(apiresourceschemasResource, aPIResourceSchema, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIResourceSchema), err +} + +// Delete takes name of the aPIResourceSchema and deletes it. Returns an error if one occurs. +func (c *FakeAPIResourceSchemas) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(apiresourceschemasResource, name, opts), &v1alpha2.APIResourceSchema{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIResourceSchemas) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionActionWithOptions(apiresourceschemasResource, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIResourceSchemaList{}) + return err +} + +// Patch applies the patch and returns the patched aPIResourceSchema. +func (c *FakeAPIResourceSchemas) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIResourceSchema, err error) { + emptyResult := &v1alpha2.APIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiresourceschemasResource, name, pt, data, opts, subresources...), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIResourceSchema), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied aPIResourceSchema. +func (c *FakeAPIResourceSchemas) Apply(ctx context.Context, aPIResourceSchema *kubebindv1alpha2.APIResourceSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIResourceSchema, err error) { + if aPIResourceSchema == nil { + return nil, fmt.Errorf("aPIResourceSchema provided to Apply must not be nil") + } + data, err := json.Marshal(aPIResourceSchema) + if err != nil { + return nil, err + } + name := aPIResourceSchema.Name + if name == nil { + return nil, fmt.Errorf("aPIResourceSchema.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiresourceschemasResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIResourceSchema), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicebinding.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicebinding.go new file mode 100644 index 000000000..4d937a412 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicebinding.go @@ -0,0 +1,187 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" +) + +// FakeAPIServiceBindings implements APIServiceBindingInterface +type FakeAPIServiceBindings struct { + Fake *FakeKubeBindV1alpha2 +} + +var apiservicebindingsResource = v1alpha2.SchemeGroupVersion.WithResource("apiservicebindings") + +var apiservicebindingsKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceBinding") + +// Get takes name of the aPIServiceBinding, and returns the corresponding aPIServiceBinding object, and an error if there is any. +func (c *FakeAPIServiceBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootGetActionWithOptions(apiservicebindingsResource, name, options), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// List takes label and field selectors, and returns the list of APIServiceBindings that match those selectors. +func (c *FakeAPIServiceBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceBindingList, err error) { + emptyResult := &v1alpha2.APIServiceBindingList{} + obj, err := c.Fake. + Invokes(testing.NewRootListActionWithOptions(apiservicebindingsResource, apiservicebindingsKind, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceBindingList{ListMeta: obj.(*v1alpha2.APIServiceBindingList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceBindingList).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 aPIServiceBindings. +func (c *FakeAPIServiceBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchActionWithOptions(apiservicebindingsResource, opts)) +} + +// Create takes the representation of a aPIServiceBinding and creates it. Returns the server's representation of the aPIServiceBinding, and an error, if there is any. +func (c *FakeAPIServiceBindings) Create(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.CreateOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootCreateActionWithOptions(apiservicebindingsResource, aPIServiceBinding, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// Update takes the representation of a aPIServiceBinding and updates it. Returns the server's representation of the aPIServiceBinding, and an error, if there is any. +func (c *FakeAPIServiceBindings) Update(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootUpdateActionWithOptions(apiservicebindingsResource, aPIServiceBinding, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), 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 *FakeAPIServiceBindings) UpdateStatus(ctx context.Context, aPIServiceBinding *v1alpha2.APIServiceBinding, opts v1.UpdateOptions) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceActionWithOptions(apiservicebindingsResource, "status", aPIServiceBinding, opts), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// Delete takes name of the aPIServiceBinding and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(apiservicebindingsResource, name, opts), &v1alpha2.APIServiceBinding{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionActionWithOptions(apiservicebindingsResource, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceBindingList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceBinding. +func (c *FakeAPIServiceBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceBinding, err error) { + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiservicebindingsResource, name, pt, data, opts, subresources...), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied aPIServiceBinding. +func (c *FakeAPIServiceBindings) Apply(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceBinding, err error) { + if aPIServiceBinding == nil { + return nil, fmt.Errorf("aPIServiceBinding provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceBinding) + if err != nil { + return nil, err + } + name := aPIServiceBinding.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceBinding.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiservicebindingsResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeAPIServiceBindings) ApplyStatus(ctx context.Context, aPIServiceBinding *kubebindv1alpha2.APIServiceBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceBinding, err error) { + if aPIServiceBinding == nil { + return nil, fmt.Errorf("aPIServiceBinding provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceBinding) + if err != nil { + return nil, err + } + name := aPIServiceBinding.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceBinding.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceBinding{} + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceActionWithOptions(apiservicebindingsResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceBinding), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexport.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexport.go new file mode 100644 index 000000000..7644174fc --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexport.go @@ -0,0 +1,198 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" +) + +// FakeAPIServiceExports implements APIServiceExportInterface +type FakeAPIServiceExports struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var apiserviceexportsResource = v1alpha2.SchemeGroupVersion.WithResource("apiserviceexports") + +var apiserviceexportsKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceExport") + +// Get takes name of the aPIServiceExport, and returns the corresponding aPIServiceExport object, and an error if there is any. +func (c *FakeAPIServiceExports) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apiserviceexportsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// List takes label and field selectors, and returns the list of APIServiceExports that match those selectors. +func (c *FakeAPIServiceExports) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceExportList, err error) { + emptyResult := &v1alpha2.APIServiceExportList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apiserviceexportsResource, apiserviceexportsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceExportList{ListMeta: obj.(*v1alpha2.APIServiceExportList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceExportList).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 aPIServiceExports. +func (c *FakeAPIServiceExports) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apiserviceexportsResource, c.ns, opts)) + +} + +// Create takes the representation of a aPIServiceExport and creates it. Returns the server's representation of the aPIServiceExport, and an error, if there is any. +func (c *FakeAPIServiceExports) Create(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.CreateOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apiserviceexportsResource, c.ns, aPIServiceExport, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// Update takes the representation of a aPIServiceExport and updates it. Returns the server's representation of the aPIServiceExport, and an error, if there is any. +func (c *FakeAPIServiceExports) Update(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apiserviceexportsResource, c.ns, aPIServiceExport, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), 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 *FakeAPIServiceExports) UpdateStatus(ctx context.Context, aPIServiceExport *v1alpha2.APIServiceExport, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apiserviceexportsResource, "status", c.ns, aPIServiceExport, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// Delete takes name of the aPIServiceExport and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceExports) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apiserviceexportsResource, c.ns, name, opts), &v1alpha2.APIServiceExport{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceExports) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apiserviceexportsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceExportList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceExport. +func (c *FakeAPIServiceExports) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceExport, err error) { + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied aPIServiceExport. +func (c *FakeAPIServiceExports) Apply(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExportApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExport, err error) { + if aPIServiceExport == nil { + return nil, fmt.Errorf("aPIServiceExport provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceExport) + if err != nil { + return nil, err + } + name := aPIServiceExport.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceExport.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeAPIServiceExports) ApplyStatus(ctx context.Context, aPIServiceExport *kubebindv1alpha2.APIServiceExportApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExport, err error) { + if aPIServiceExport == nil { + return nil, fmt.Errorf("aPIServiceExport provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceExport) + if err != nil { + return nil, err + } + name := aPIServiceExport.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceExport.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceExport{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExport), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexportrequest.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexportrequest.go new file mode 100644 index 000000000..fa2cbdffa --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiserviceexportrequest.go @@ -0,0 +1,198 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" +) + +// FakeAPIServiceExportRequests implements APIServiceExportRequestInterface +type FakeAPIServiceExportRequests struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var apiserviceexportrequestsResource = v1alpha2.SchemeGroupVersion.WithResource("apiserviceexportrequests") + +var apiserviceexportrequestsKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceExportRequest") + +// Get takes name of the aPIServiceExportRequest, and returns the corresponding aPIServiceExportRequest object, and an error if there is any. +func (c *FakeAPIServiceExportRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apiserviceexportrequestsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// List takes label and field selectors, and returns the list of APIServiceExportRequests that match those selectors. +func (c *FakeAPIServiceExportRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceExportRequestList, err error) { + emptyResult := &v1alpha2.APIServiceExportRequestList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apiserviceexportrequestsResource, apiserviceexportrequestsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceExportRequestList{ListMeta: obj.(*v1alpha2.APIServiceExportRequestList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceExportRequestList).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 aPIServiceExportRequests. +func (c *FakeAPIServiceExportRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apiserviceexportrequestsResource, c.ns, opts)) + +} + +// Create takes the representation of a aPIServiceExportRequest and creates it. Returns the server's representation of the aPIServiceExportRequest, and an error, if there is any. +func (c *FakeAPIServiceExportRequests) Create(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.CreateOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apiserviceexportrequestsResource, c.ns, aPIServiceExportRequest, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// Update takes the representation of a aPIServiceExportRequest and updates it. Returns the server's representation of the aPIServiceExportRequest, and an error, if there is any. +func (c *FakeAPIServiceExportRequests) Update(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apiserviceexportrequestsResource, c.ns, aPIServiceExportRequest, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), 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 *FakeAPIServiceExportRequests) UpdateStatus(ctx context.Context, aPIServiceExportRequest *v1alpha2.APIServiceExportRequest, opts v1.UpdateOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apiserviceexportrequestsResource, "status", c.ns, aPIServiceExportRequest, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// Delete takes name of the aPIServiceExportRequest and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceExportRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apiserviceexportrequestsResource, c.ns, name, opts), &v1alpha2.APIServiceExportRequest{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceExportRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apiserviceexportrequestsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceExportRequestList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceExportRequest. +func (c *FakeAPIServiceExportRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceExportRequest, err error) { + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportrequestsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied aPIServiceExportRequest. +func (c *FakeAPIServiceExportRequests) Apply(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequestApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + if aPIServiceExportRequest == nil { + return nil, fmt.Errorf("aPIServiceExportRequest provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceExportRequest) + if err != nil { + return nil, err + } + name := aPIServiceExportRequest.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceExportRequest.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportrequestsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeAPIServiceExportRequests) ApplyStatus(ctx context.Context, aPIServiceExportRequest *kubebindv1alpha2.APIServiceExportRequestApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceExportRequest, err error) { + if aPIServiceExportRequest == nil { + return nil, fmt.Errorf("aPIServiceExportRequest provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceExportRequest) + if err != nil { + return nil, err + } + name := aPIServiceExportRequest.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceExportRequest.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceExportRequest{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiserviceexportrequestsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceExportRequest), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicenamespace.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicenamespace.go new file mode 100644 index 000000000..5d85421cf --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_apiservicenamespace.go @@ -0,0 +1,198 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" +) + +// FakeAPIServiceNamespaces implements APIServiceNamespaceInterface +type FakeAPIServiceNamespaces struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var apiservicenamespacesResource = v1alpha2.SchemeGroupVersion.WithResource("apiservicenamespaces") + +var apiservicenamespacesKind = v1alpha2.SchemeGroupVersion.WithKind("APIServiceNamespace") + +// Get takes name of the aPIServiceNamespace, and returns the corresponding aPIServiceNamespace object, and an error if there is any. +func (c *FakeAPIServiceNamespaces) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apiservicenamespacesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// List takes label and field selectors, and returns the list of APIServiceNamespaces that match those selectors. +func (c *FakeAPIServiceNamespaces) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.APIServiceNamespaceList, err error) { + emptyResult := &v1alpha2.APIServiceNamespaceList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apiservicenamespacesResource, apiservicenamespacesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.APIServiceNamespaceList{ListMeta: obj.(*v1alpha2.APIServiceNamespaceList).ListMeta} + for _, item := range obj.(*v1alpha2.APIServiceNamespaceList).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 aPIServiceNamespaces. +func (c *FakeAPIServiceNamespaces) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apiservicenamespacesResource, c.ns, opts)) + +} + +// Create takes the representation of a aPIServiceNamespace and creates it. Returns the server's representation of the aPIServiceNamespace, and an error, if there is any. +func (c *FakeAPIServiceNamespaces) Create(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.CreateOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apiservicenamespacesResource, c.ns, aPIServiceNamespace, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// Update takes the representation of a aPIServiceNamespace and updates it. Returns the server's representation of the aPIServiceNamespace, and an error, if there is any. +func (c *FakeAPIServiceNamespaces) Update(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apiservicenamespacesResource, c.ns, aPIServiceNamespace, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), 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 *FakeAPIServiceNamespaces) UpdateStatus(ctx context.Context, aPIServiceNamespace *v1alpha2.APIServiceNamespace, opts v1.UpdateOptions) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apiservicenamespacesResource, "status", c.ns, aPIServiceNamespace, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// Delete takes name of the aPIServiceNamespace and deletes it. Returns an error if one occurs. +func (c *FakeAPIServiceNamespaces) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apiservicenamespacesResource, c.ns, name, opts), &v1alpha2.APIServiceNamespace{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAPIServiceNamespaces) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apiservicenamespacesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.APIServiceNamespaceList{}) + return err +} + +// Patch applies the patch and returns the patched aPIServiceNamespace. +func (c *FakeAPIServiceNamespaces) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.APIServiceNamespace, err error) { + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiservicenamespacesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied aPIServiceNamespace. +func (c *FakeAPIServiceNamespaces) Apply(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceNamespace, err error) { + if aPIServiceNamespace == nil { + return nil, fmt.Errorf("aPIServiceNamespace provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceNamespace) + if err != nil { + return nil, err + } + name := aPIServiceNamespace.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceNamespace.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiservicenamespacesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeAPIServiceNamespaces) ApplyStatus(ctx context.Context, aPIServiceNamespace *kubebindv1alpha2.APIServiceNamespaceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.APIServiceNamespace, err error) { + if aPIServiceNamespace == nil { + return nil, fmt.Errorf("aPIServiceNamespace provided to Apply must not be nil") + } + data, err := json.Marshal(aPIServiceNamespace) + if err != nil { + return nil, err + } + name := aPIServiceNamespace.Name + if name == nil { + return nil, fmt.Errorf("aPIServiceNamespace.Name must be provided to Apply") + } + emptyResult := &v1alpha2.APIServiceNamespace{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apiservicenamespacesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.APIServiceNamespace), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_boundapiresourceschema.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_boundapiresourceschema.go new file mode 100644 index 000000000..938e0a3f6 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_boundapiresourceschema.go @@ -0,0 +1,198 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/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 +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied boundAPIResourceSchema. +func (c *FakeBoundAPIResourceSchemas) Apply(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) { + if boundAPIResourceSchema == nil { + return nil, fmt.Errorf("boundAPIResourceSchema provided to Apply must not be nil") + } + data, err := json.Marshal(boundAPIResourceSchema) + if err != nil { + return nil, err + } + name := boundAPIResourceSchema.Name + if name == nil { + return nil, fmt.Errorf("boundAPIResourceSchema.Name must be provided to Apply") + } + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(boundapiresourceschemasResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeBoundAPIResourceSchemas) ApplyStatus(ctx context.Context, boundAPIResourceSchema *kubebindv1alpha2.BoundAPIResourceSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.BoundAPIResourceSchema, err error) { + if boundAPIResourceSchema == nil { + return nil, fmt.Errorf("boundAPIResourceSchema provided to Apply must not be nil") + } + data, err := json.Marshal(boundAPIResourceSchema) + if err != nil { + return nil, err + } + name := boundAPIResourceSchema.Name + if name == nil { + return nil, fmt.Errorf("boundAPIResourceSchema.Name must be provided to Apply") + } + emptyResult := &v1alpha2.BoundAPIResourceSchema{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(boundapiresourceschemasResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.BoundAPIResourceSchema), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_clusterbinding.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_clusterbinding.go new file mode 100644 index 000000000..283e7971c --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_clusterbinding.go @@ -0,0 +1,198 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + 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" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/applyconfiguration/kubebind/v1alpha2" +) + +// FakeClusterBindings implements ClusterBindingInterface +type FakeClusterBindings struct { + Fake *FakeKubeBindV1alpha2 + ns string +} + +var clusterbindingsResource = v1alpha2.SchemeGroupVersion.WithResource("clusterbindings") + +var clusterbindingsKind = v1alpha2.SchemeGroupVersion.WithKind("ClusterBinding") + +// Get takes name of the clusterBinding, and returns the corresponding clusterBinding object, and an error if there is any. +func (c *FakeClusterBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(clusterbindingsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// List takes label and field selectors, and returns the list of ClusterBindings that match those selectors. +func (c *FakeClusterBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ClusterBindingList, err error) { + emptyResult := &v1alpha2.ClusterBindingList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(clusterbindingsResource, clusterbindingsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.ClusterBindingList{ListMeta: obj.(*v1alpha2.ClusterBindingList).ListMeta} + for _, item := range obj.(*v1alpha2.ClusterBindingList).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 clusterBindings. +func (c *FakeClusterBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(clusterbindingsResource, c.ns, opts)) + +} + +// Create takes the representation of a clusterBinding and creates it. Returns the server's representation of the clusterBinding, and an error, if there is any. +func (c *FakeClusterBindings) Create(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.CreateOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(clusterbindingsResource, c.ns, clusterBinding, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// Update takes the representation of a clusterBinding and updates it. Returns the server's representation of the clusterBinding, and an error, if there is any. +func (c *FakeClusterBindings) Update(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(clusterbindingsResource, c.ns, clusterBinding, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), 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 *FakeClusterBindings) UpdateStatus(ctx context.Context, clusterBinding *v1alpha2.ClusterBinding, opts v1.UpdateOptions) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(clusterbindingsResource, "status", c.ns, clusterBinding, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// Delete takes name of the clusterBinding and deletes it. Returns an error if one occurs. +func (c *FakeClusterBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(clusterbindingsResource, c.ns, name, opts), &v1alpha2.ClusterBinding{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(clusterbindingsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.ClusterBindingList{}) + return err +} + +// Patch applies the patch and returns the patched clusterBinding. +func (c *FakeClusterBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterBinding, err error) { + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(clusterbindingsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied clusterBinding. +func (c *FakeClusterBindings) Apply(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ClusterBinding, err error) { + if clusterBinding == nil { + return nil, fmt.Errorf("clusterBinding provided to Apply must not be nil") + } + data, err := json.Marshal(clusterBinding) + if err != nil { + return nil, err + } + name := clusterBinding.Name + if name == nil { + return nil, fmt.Errorf("clusterBinding.Name must be provided to Apply") + } + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(clusterbindingsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeClusterBindings) ApplyStatus(ctx context.Context, clusterBinding *kubebindv1alpha2.ClusterBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ClusterBinding, err error) { + if clusterBinding == nil { + return nil, fmt.Errorf("clusterBinding provided to Apply must not be nil") + } + data, err := json.Marshal(clusterBinding) + if err != nil { + return nil, err + } + name := clusterBinding.Name + if name == nil { + return nil, fmt.Errorf("clusterBinding.Name must be provided to Apply") + } + emptyResult := &v1alpha2.ClusterBinding{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(clusterbindingsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha2.ClusterBinding), err +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go new file mode 100644 index 000000000..3ab3b9bc5 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go @@ -0,0 +1,65 @@ +/* +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-v0.31. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2" +) + +type FakeKubeBindV1alpha2 struct { + *testing.Fake +} + +func (c *FakeKubeBindV1alpha2) APIResourceSchemas() v1alpha2.APIResourceSchemaInterface { + return &FakeAPIResourceSchemas{c} +} + +func (c *FakeKubeBindV1alpha2) APIServiceBindings() v1alpha2.APIServiceBindingInterface { + return &FakeAPIServiceBindings{c} +} + +func (c *FakeKubeBindV1alpha2) APIServiceExports(namespace string) v1alpha2.APIServiceExportInterface { + return &FakeAPIServiceExports{c, namespace} +} + +func (c *FakeKubeBindV1alpha2) APIServiceExportRequests(namespace string) v1alpha2.APIServiceExportRequestInterface { + return &FakeAPIServiceExportRequests{c, namespace} +} + +func (c *FakeKubeBindV1alpha2) APIServiceNamespaces(namespace string) v1alpha2.APIServiceNamespaceInterface { + return &FakeAPIServiceNamespaces{c, namespace} +} + +func (c *FakeKubeBindV1alpha2) BoundAPIResourceSchemas(namespace string) v1alpha2.BoundAPIResourceSchemaInterface { + return &FakeBoundAPIResourceSchemas{c, namespace} +} + +func (c *FakeKubeBindV1alpha2) ClusterBindings(namespace string) v1alpha2.ClusterBindingInterface { + return &FakeClusterBindings{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeKubeBindV1alpha2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go new file mode 100644 index 000000000..334622fc8 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go @@ -0,0 +1,33 @@ +/* +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-v0.31. DO NOT EDIT. + +package v1alpha2 + +type APIResourceSchemaExpansion interface{} + +type APIServiceBindingExpansion interface{} + +type APIServiceExportExpansion interface{} + +type APIServiceExportRequestExpansion interface{} + +type APIServiceNamespaceExpansion interface{} + +type BoundAPIResourceSchemaExpansion interface{} + +type ClusterBindingExpansion interface{} diff --git a/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go new file mode 100644 index 000000000..7b89ded43 --- /dev/null +++ b/sdk/kcp/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go @@ -0,0 +1,138 @@ +/* +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-v0.31. DO NOT EDIT. + +package v1alpha2 + +import ( + "net/http" + + rest "k8s.io/client-go/rest" + + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + "github.com/kube-bind/kube-bind/sdk/kcp/clientset/versioned/scheme" +) + +type KubeBindV1alpha2Interface interface { + RESTClient() rest.Interface + APIResourceSchemasGetter + APIServiceBindingsGetter + APIServiceExportsGetter + APIServiceExportRequestsGetter + APIServiceNamespacesGetter + BoundAPIResourceSchemasGetter + ClusterBindingsGetter +} + +// KubeBindV1alpha2Client is used to interact with features provided by the kube-bind.io group. +type KubeBindV1alpha2Client struct { + restClient rest.Interface +} + +func (c *KubeBindV1alpha2Client) APIResourceSchemas() APIResourceSchemaInterface { + return newAPIResourceSchemas(c) +} + +func (c *KubeBindV1alpha2Client) APIServiceBindings() APIServiceBindingInterface { + return newAPIServiceBindings(c) +} + +func (c *KubeBindV1alpha2Client) APIServiceExports(namespace string) APIServiceExportInterface { + return newAPIServiceExports(c, namespace) +} + +func (c *KubeBindV1alpha2Client) APIServiceExportRequests(namespace string) APIServiceExportRequestInterface { + return newAPIServiceExportRequests(c, namespace) +} + +func (c *KubeBindV1alpha2Client) APIServiceNamespaces(namespace string) APIServiceNamespaceInterface { + return newAPIServiceNamespaces(c, namespace) +} + +func (c *KubeBindV1alpha2Client) BoundAPIResourceSchemas(namespace string) BoundAPIResourceSchemaInterface { + return newBoundAPIResourceSchemas(c, namespace) +} + +func (c *KubeBindV1alpha2Client) ClusterBindings(namespace string) ClusterBindingInterface { + return newClusterBindings(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). +func NewForConfig(c *rest.Config) (*KubeBindV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new KubeBindV1alpha2Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*KubeBindV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &KubeBindV1alpha2Client{client}, nil +} + +// NewForConfigOrDie creates a new KubeBindV1alpha2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *KubeBindV1alpha2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new KubeBindV1alpha2Client for the given RESTClient. +func New(c rest.Interface) *KubeBindV1alpha2Client { + return &KubeBindV1alpha2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *KubeBindV1alpha2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/sdk/kcp/informers/externalversions/generic.go b/sdk/kcp/informers/externalversions/generic.go index 7f9f966e7..87eb8df1a 100644 --- a/sdk/kcp/informers/externalversions/generic.go +++ b/sdk/kcp/informers/externalversions/generic.go @@ -101,8 +101,18 @@ 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("apiservicebindings"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceBindings().Informer()}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiserviceexports"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceExports().Informer()}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiserviceexportrequests"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceExportRequests().Informer()}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiservicenamespaces"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceNamespaces().Informer()}, nil case kubebindv1alpha2.SchemeGroupVersion.WithResource("boundapiresourceschemas"): return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().BoundAPIResourceSchemas().Informer()}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("clusterbindings"): + return &genericClusterInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().ClusterBindings().Informer()}, nil } return nil, fmt.Errorf("no informer found for %v", resource) @@ -132,9 +142,24 @@ 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("apiservicebindings"): + informer := f.KubeBind().V1alpha2().APIServiceBindings().Informer() + return &genericInformer{lister: cache.NewGenericLister(informer.GetIndexer(), resource.GroupResource()), informer: informer}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiserviceexports"): + informer := f.KubeBind().V1alpha2().APIServiceExports().Informer() + return &genericInformer{lister: cache.NewGenericLister(informer.GetIndexer(), resource.GroupResource()), informer: informer}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiserviceexportrequests"): + informer := f.KubeBind().V1alpha2().APIServiceExportRequests().Informer() + return &genericInformer{lister: cache.NewGenericLister(informer.GetIndexer(), resource.GroupResource()), informer: informer}, nil + case kubebindv1alpha2.SchemeGroupVersion.WithResource("apiservicenamespaces"): + informer := f.KubeBind().V1alpha2().APIServiceNamespaces().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 + case kubebindv1alpha2.SchemeGroupVersion.WithResource("clusterbindings"): + informer := f.KubeBind().V1alpha2().ClusterBindings().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/apiresourceschema.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go index a01baaf3b..5713459d6 100644 --- a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiresourceschema.go @@ -88,8 +88,8 @@ func NewFilteredAPIResourceSchemaClusterInformer(client clientset.ClusterInterfa func (f *aPIResourceSchemaClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { return NewFilteredAPIResourceSchemaClusterInformer(client, resyncPeriod, cache.Indexers{ - kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, - kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + }, f.tweakListOptions, ) } @@ -132,7 +132,6 @@ func (f *aPIResourceSchemaInformer) Lister() kubebindv1alpha2listers.APIResource type aPIResourceSchemaScopedInformer struct { factory internalinterfaces.SharedScopedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string } func (f *aPIResourceSchemaScopedInformer) Informer() cache.SharedIndexInformer { @@ -146,27 +145,27 @@ func (f *aPIResourceSchemaScopedInformer) Lister() kubebindv1alpha2listers.APIRe // NewAPIResourceSchemaInformer constructs a new informer for APIResourceSchema 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 NewAPIResourceSchemaInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredAPIResourceSchemaInformer(client, resyncPeriod, namespace, indexers, nil) +func NewAPIResourceSchemaInformer(client scopedclientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIResourceSchemaInformer(client, resyncPeriod, indexers, nil) } // NewFilteredAPIResourceSchemaInformer constructs a new informer for APIResourceSchema 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 NewFilteredAPIResourceSchemaInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredAPIResourceSchemaInformer(client scopedclientset.Interface, resyncPeriod time.Duration, 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().APIResourceSchemas(namespace).List(context.TODO(), options) + return client.KubeBindV1alpha2().APIResourceSchemas().List(context.TODO(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.KubeBindV1alpha2().APIResourceSchemas(namespace).Watch(context.TODO(), options) + return client.KubeBindV1alpha2().APIResourceSchemas().Watch(context.TODO(), options) }, }, &kubebindv1alpha2.APIResourceSchema{}, @@ -176,7 +175,5 @@ func NewFilteredAPIResourceSchemaInformer(client scopedclientset.Interface, resy } func (f *aPIResourceSchemaScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredAPIResourceSchemaInformer(client, resyncPeriod, f.namespace, cache.Indexers{ - cache.NamespaceIndex: cache.MetaNamespaceIndexFunc, - }, f.tweakListOptions) + return NewFilteredAPIResourceSchemaInformer(client, resyncPeriod, cache.Indexers{}, f.tweakListOptions) } diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiservicebinding.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..706dcfd0f --- /dev/null +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,179 @@ +//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" +) + +// APIServiceBindingClusterInformer provides access to a shared informer and lister for +// APIServiceBindings. +type APIServiceBindingClusterInformer interface { + Cluster(logicalcluster.Name) APIServiceBindingInformer + Informer() kcpcache.ScopeableSharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceBindingClusterLister +} + +type aPIServiceBindingClusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewAPIServiceBindingClusterInformer constructs a new informer for APIServiceBinding 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 NewAPIServiceBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceBindingClusterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceBindingClusterInformer constructs a new informer for APIServiceBinding 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 NewFilteredAPIServiceBindingClusterInformer(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().APIServiceBindings().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceBindings().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceBindingClusterInformer(client, resyncPeriod, cache.Indexers{ + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + }, + f.tweakListOptions, + ) +} + +func (f *aPIServiceBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceBinding{}, f.defaultInformer) +} + +func (f *aPIServiceBindingClusterInformer) Lister() kubebindv1alpha2listers.APIServiceBindingClusterLister { + return kubebindv1alpha2listers.NewAPIServiceBindingClusterLister(f.Informer().GetIndexer()) +} + +// APIServiceBindingInformer provides access to a shared informer and lister for +// APIServiceBindings. +type APIServiceBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceBindingLister +} + +func (f *aPIServiceBindingClusterInformer) Cluster(clusterName logicalcluster.Name) APIServiceBindingInformer { + return &aPIServiceBindingInformer{ + informer: f.Informer().Cluster(clusterName), + lister: f.Lister().Cluster(clusterName), + } +} + +type aPIServiceBindingInformer struct { + informer cache.SharedIndexInformer + lister kubebindv1alpha2listers.APIServiceBindingLister +} + +func (f *aPIServiceBindingInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +func (f *aPIServiceBindingInformer) Lister() kubebindv1alpha2listers.APIServiceBindingLister { + return f.lister +} + +type aPIServiceBindingScopedInformer struct { + factory internalinterfaces.SharedScopedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +func (f *aPIServiceBindingScopedInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceBinding{}, f.defaultInformer) +} + +func (f *aPIServiceBindingScopedInformer) Lister() kubebindv1alpha2listers.APIServiceBindingLister { + return kubebindv1alpha2listers.NewAPIServiceBindingLister(f.Informer().GetIndexer()) +} + +// NewAPIServiceBindingInformer constructs a new informer for APIServiceBinding 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 NewAPIServiceBindingInformer(client scopedclientset.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceBindingInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceBindingInformer constructs a new informer for APIServiceBinding 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 NewFilteredAPIServiceBindingInformer(client scopedclientset.Interface, resyncPeriod time.Duration, 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().APIServiceBindings().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceBindings().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceBindingScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceBindingInformer(client, resyncPeriod, cache.Indexers{}, f.tweakListOptions) +} diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiserviceexport.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..92b6673c7 --- /dev/null +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiserviceexport.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" +) + +// APIServiceExportClusterInformer provides access to a shared informer and lister for +// APIServiceExports. +type APIServiceExportClusterInformer interface { + Cluster(logicalcluster.Name) APIServiceExportInformer + Informer() kcpcache.ScopeableSharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceExportClusterLister +} + +type aPIServiceExportClusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewAPIServiceExportClusterInformer constructs a new informer for APIServiceExport 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 NewAPIServiceExportClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceExportClusterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceExportClusterInformer constructs a new informer for APIServiceExport 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 NewFilteredAPIServiceExportClusterInformer(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().APIServiceExports().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceExports().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceExport{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceExportClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceExportClusterInformer(client, resyncPeriod, cache.Indexers{ + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, + f.tweakListOptions, + ) +} + +func (f *aPIServiceExportClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceExport{}, f.defaultInformer) +} + +func (f *aPIServiceExportClusterInformer) Lister() kubebindv1alpha2listers.APIServiceExportClusterLister { + return kubebindv1alpha2listers.NewAPIServiceExportClusterLister(f.Informer().GetIndexer()) +} + +// APIServiceExportInformer provides access to a shared informer and lister for +// APIServiceExports. +type APIServiceExportInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceExportLister +} + +func (f *aPIServiceExportClusterInformer) Cluster(clusterName logicalcluster.Name) APIServiceExportInformer { + return &aPIServiceExportInformer{ + informer: f.Informer().Cluster(clusterName), + lister: f.Lister().Cluster(clusterName), + } +} + +type aPIServiceExportInformer struct { + informer cache.SharedIndexInformer + lister kubebindv1alpha2listers.APIServiceExportLister +} + +func (f *aPIServiceExportInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +func (f *aPIServiceExportInformer) Lister() kubebindv1alpha2listers.APIServiceExportLister { + return f.lister +} + +type aPIServiceExportScopedInformer struct { + factory internalinterfaces.SharedScopedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +func (f *aPIServiceExportScopedInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceExport{}, f.defaultInformer) +} + +func (f *aPIServiceExportScopedInformer) Lister() kubebindv1alpha2listers.APIServiceExportLister { + return kubebindv1alpha2listers.NewAPIServiceExportLister(f.Informer().GetIndexer()) +} + +// NewAPIServiceExportInformer constructs a new informer for APIServiceExport 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 NewAPIServiceExportInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportInformer(client, resyncPeriod, namespace, indexers, nil) +} + +// NewFilteredAPIServiceExportInformer constructs a new informer for APIServiceExport 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 NewFilteredAPIServiceExportInformer(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().APIServiceExports(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceExports(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceExport{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceExportScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportInformer(client, resyncPeriod, f.namespace, cache.Indexers{ + cache.NamespaceIndex: cache.MetaNamespaceIndexFunc, + }, f.tweakListOptions) +} diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..3d0968afd --- /dev/null +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiserviceexportrequest.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" +) + +// APIServiceExportRequestClusterInformer provides access to a shared informer and lister for +// APIServiceExportRequests. +type APIServiceExportRequestClusterInformer interface { + Cluster(logicalcluster.Name) APIServiceExportRequestInformer + Informer() kcpcache.ScopeableSharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceExportRequestClusterLister +} + +type aPIServiceExportRequestClusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewAPIServiceExportRequestClusterInformer constructs a new informer for APIServiceExportRequest 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 NewAPIServiceExportRequestClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceExportRequestClusterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceExportRequestClusterInformer constructs a new informer for APIServiceExportRequest 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 NewFilteredAPIServiceExportRequestClusterInformer(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().APIServiceExportRequests().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceExportRequests().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceExportRequest{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceExportRequestClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceExportRequestClusterInformer(client, resyncPeriod, cache.Indexers{ + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, + f.tweakListOptions, + ) +} + +func (f *aPIServiceExportRequestClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceExportRequest{}, f.defaultInformer) +} + +func (f *aPIServiceExportRequestClusterInformer) Lister() kubebindv1alpha2listers.APIServiceExportRequestClusterLister { + return kubebindv1alpha2listers.NewAPIServiceExportRequestClusterLister(f.Informer().GetIndexer()) +} + +// APIServiceExportRequestInformer provides access to a shared informer and lister for +// APIServiceExportRequests. +type APIServiceExportRequestInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceExportRequestLister +} + +func (f *aPIServiceExportRequestClusterInformer) Cluster(clusterName logicalcluster.Name) APIServiceExportRequestInformer { + return &aPIServiceExportRequestInformer{ + informer: f.Informer().Cluster(clusterName), + lister: f.Lister().Cluster(clusterName), + } +} + +type aPIServiceExportRequestInformer struct { + informer cache.SharedIndexInformer + lister kubebindv1alpha2listers.APIServiceExportRequestLister +} + +func (f *aPIServiceExportRequestInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +func (f *aPIServiceExportRequestInformer) Lister() kubebindv1alpha2listers.APIServiceExportRequestLister { + return f.lister +} + +type aPIServiceExportRequestScopedInformer struct { + factory internalinterfaces.SharedScopedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +func (f *aPIServiceExportRequestScopedInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceExportRequest{}, f.defaultInformer) +} + +func (f *aPIServiceExportRequestScopedInformer) Lister() kubebindv1alpha2listers.APIServiceExportRequestLister { + return kubebindv1alpha2listers.NewAPIServiceExportRequestLister(f.Informer().GetIndexer()) +} + +// NewAPIServiceExportRequestInformer constructs a new informer for APIServiceExportRequest 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 NewAPIServiceExportRequestInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportRequestInformer(client, resyncPeriod, namespace, indexers, nil) +} + +// NewFilteredAPIServiceExportRequestInformer constructs a new informer for APIServiceExportRequest 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 NewFilteredAPIServiceExportRequestInformer(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().APIServiceExportRequests(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceExportRequests(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceExportRequest{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceExportRequestScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceExportRequestInformer(client, resyncPeriod, f.namespace, cache.Indexers{ + cache.NamespaceIndex: cache.MetaNamespaceIndexFunc, + }, f.tweakListOptions) +} diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiservicenamespace.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..778662261 --- /dev/null +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/apiservicenamespace.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" +) + +// APIServiceNamespaceClusterInformer provides access to a shared informer and lister for +// APIServiceNamespaces. +type APIServiceNamespaceClusterInformer interface { + Cluster(logicalcluster.Name) APIServiceNamespaceInformer + Informer() kcpcache.ScopeableSharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceNamespaceClusterLister +} + +type aPIServiceNamespaceClusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewAPIServiceNamespaceClusterInformer constructs a new informer for APIServiceNamespace 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 NewAPIServiceNamespaceClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceNamespaceClusterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredAPIServiceNamespaceClusterInformer constructs a new informer for APIServiceNamespace 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 NewFilteredAPIServiceNamespaceClusterInformer(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().APIServiceNamespaces().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceNamespaces().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceNamespace{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceNamespaceClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredAPIServiceNamespaceClusterInformer(client, resyncPeriod, cache.Indexers{ + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, + f.tweakListOptions, + ) +} + +func (f *aPIServiceNamespaceClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceNamespace{}, f.defaultInformer) +} + +func (f *aPIServiceNamespaceClusterInformer) Lister() kubebindv1alpha2listers.APIServiceNamespaceClusterLister { + return kubebindv1alpha2listers.NewAPIServiceNamespaceClusterLister(f.Informer().GetIndexer()) +} + +// APIServiceNamespaceInformer provides access to a shared informer and lister for +// APIServiceNamespaces. +type APIServiceNamespaceInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2listers.APIServiceNamespaceLister +} + +func (f *aPIServiceNamespaceClusterInformer) Cluster(clusterName logicalcluster.Name) APIServiceNamespaceInformer { + return &aPIServiceNamespaceInformer{ + informer: f.Informer().Cluster(clusterName), + lister: f.Lister().Cluster(clusterName), + } +} + +type aPIServiceNamespaceInformer struct { + informer cache.SharedIndexInformer + lister kubebindv1alpha2listers.APIServiceNamespaceLister +} + +func (f *aPIServiceNamespaceInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +func (f *aPIServiceNamespaceInformer) Lister() kubebindv1alpha2listers.APIServiceNamespaceLister { + return f.lister +} + +type aPIServiceNamespaceScopedInformer struct { + factory internalinterfaces.SharedScopedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +func (f *aPIServiceNamespaceScopedInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.APIServiceNamespace{}, f.defaultInformer) +} + +func (f *aPIServiceNamespaceScopedInformer) Lister() kubebindv1alpha2listers.APIServiceNamespaceLister { + return kubebindv1alpha2listers.NewAPIServiceNamespaceLister(f.Informer().GetIndexer()) +} + +// NewAPIServiceNamespaceInformer constructs a new informer for APIServiceNamespace 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 NewAPIServiceNamespaceInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAPIServiceNamespaceInformer(client, resyncPeriod, namespace, indexers, nil) +} + +// NewFilteredAPIServiceNamespaceInformer constructs a new informer for APIServiceNamespace 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 NewFilteredAPIServiceNamespaceInformer(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().APIServiceNamespaces(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().APIServiceNamespaces(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.APIServiceNamespace{}, + resyncPeriod, + indexers, + ) +} + +func (f *aPIServiceNamespaceScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAPIServiceNamespaceInformer(client, resyncPeriod, f.namespace, cache.Indexers{ + cache.NamespaceIndex: cache.MetaNamespaceIndexFunc, + }, f.tweakListOptions) +} diff --git a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/clusterbinding.go b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..3ff1bb1e0 --- /dev/null +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/clusterbinding.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" +) + +// ClusterBindingClusterInformer provides access to a shared informer and lister for +// ClusterBindings. +type ClusterBindingClusterInformer interface { + Cluster(logicalcluster.Name) ClusterBindingInformer + Informer() kcpcache.ScopeableSharedIndexInformer + Lister() kubebindv1alpha2listers.ClusterBindingClusterLister +} + +type clusterBindingClusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterBindingClusterInformer constructs a new informer for ClusterBinding 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 NewClusterBindingClusterInformer(client clientset.ClusterInterface, resyncPeriod time.Duration, indexers cache.Indexers) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredClusterBindingClusterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterBindingClusterInformer constructs a new informer for ClusterBinding 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 NewFilteredClusterBindingClusterInformer(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().ClusterBindings().List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().ClusterBindings().Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.ClusterBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterBindingClusterInformer) defaultInformer(client clientset.ClusterInterface, resyncPeriod time.Duration) kcpcache.ScopeableSharedIndexInformer { + return NewFilteredClusterBindingClusterInformer(client, resyncPeriod, cache.Indexers{ + kcpcache.ClusterIndexName: kcpcache.ClusterIndexFunc, + kcpcache.ClusterAndNamespaceIndexName: kcpcache.ClusterAndNamespaceIndexFunc}, + f.tweakListOptions, + ) +} + +func (f *clusterBindingClusterInformer) Informer() kcpcache.ScopeableSharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.ClusterBinding{}, f.defaultInformer) +} + +func (f *clusterBindingClusterInformer) Lister() kubebindv1alpha2listers.ClusterBindingClusterLister { + return kubebindv1alpha2listers.NewClusterBindingClusterLister(f.Informer().GetIndexer()) +} + +// ClusterBindingInformer provides access to a shared informer and lister for +// ClusterBindings. +type ClusterBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2listers.ClusterBindingLister +} + +func (f *clusterBindingClusterInformer) Cluster(clusterName logicalcluster.Name) ClusterBindingInformer { + return &clusterBindingInformer{ + informer: f.Informer().Cluster(clusterName), + lister: f.Lister().Cluster(clusterName), + } +} + +type clusterBindingInformer struct { + informer cache.SharedIndexInformer + lister kubebindv1alpha2listers.ClusterBindingLister +} + +func (f *clusterBindingInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +func (f *clusterBindingInformer) Lister() kubebindv1alpha2listers.ClusterBindingLister { + return f.lister +} + +type clusterBindingScopedInformer struct { + factory internalinterfaces.SharedScopedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +func (f *clusterBindingScopedInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubebindv1alpha2.ClusterBinding{}, f.defaultInformer) +} + +func (f *clusterBindingScopedInformer) Lister() kubebindv1alpha2listers.ClusterBindingLister { + return kubebindv1alpha2listers.NewClusterBindingLister(f.Informer().GetIndexer()) +} + +// NewClusterBindingInformer constructs a new informer for ClusterBinding 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 NewClusterBindingInformer(client scopedclientset.Interface, resyncPeriod time.Duration, namespace string, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterBindingInformer(client, resyncPeriod, namespace, indexers, nil) +} + +// NewFilteredClusterBindingInformer constructs a new informer for ClusterBinding 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 NewFilteredClusterBindingInformer(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().ClusterBindings(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().ClusterBindings(namespace).Watch(context.TODO(), options) + }, + }, + &kubebindv1alpha2.ClusterBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterBindingScopedInformer) defaultInformer(client scopedclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterBindingInformer(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 c0f96a907..789830fbd 100644 --- a/sdk/kcp/informers/externalversions/kubebind/v1alpha2/interface.go +++ b/sdk/kcp/informers/externalversions/kubebind/v1alpha2/interface.go @@ -28,8 +28,18 @@ import ( type ClusterInterface interface { // APIResourceSchemas returns a APIResourceSchemaClusterInformer APIResourceSchemas() APIResourceSchemaClusterInformer + // APIServiceBindings returns a APIServiceBindingClusterInformer + APIServiceBindings() APIServiceBindingClusterInformer + // APIServiceExports returns a APIServiceExportClusterInformer + APIServiceExports() APIServiceExportClusterInformer + // APIServiceExportRequests returns a APIServiceExportRequestClusterInformer + APIServiceExportRequests() APIServiceExportRequestClusterInformer + // APIServiceNamespaces returns a APIServiceNamespaceClusterInformer + APIServiceNamespaces() APIServiceNamespaceClusterInformer // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaClusterInformer BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInformer + // ClusterBindings returns a ClusterBindingClusterInformer + ClusterBindings() ClusterBindingClusterInformer } type version struct { @@ -47,16 +57,51 @@ func (v *version) APIResourceSchemas() APIResourceSchemaClusterInformer { return &aPIResourceSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// APIServiceBindings returns a APIServiceBindingClusterInformer +func (v *version) APIServiceBindings() APIServiceBindingClusterInformer { + return &aPIServiceBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceExports returns a APIServiceExportClusterInformer +func (v *version) APIServiceExports() APIServiceExportClusterInformer { + return &aPIServiceExportClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceExportRequests returns a APIServiceExportRequestClusterInformer +func (v *version) APIServiceExportRequests() APIServiceExportRequestClusterInformer { + return &aPIServiceExportRequestClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceNamespaces returns a APIServiceNamespaceClusterInformer +func (v *version) APIServiceNamespaces() APIServiceNamespaceClusterInformer { + return &aPIServiceNamespaceClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaClusterInformer func (v *version) BoundAPIResourceSchemas() BoundAPIResourceSchemaClusterInformer { return &boundAPIResourceSchemaClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// ClusterBindings returns a ClusterBindingClusterInformer +func (v *version) ClusterBindings() ClusterBindingClusterInformer { + return &clusterBindingClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + type Interface interface { // APIResourceSchemas returns a APIResourceSchemaInformer APIResourceSchemas() APIResourceSchemaInformer + // APIServiceBindings returns a APIServiceBindingInformer + APIServiceBindings() APIServiceBindingInformer + // APIServiceExports returns a APIServiceExportInformer + APIServiceExports() APIServiceExportInformer + // APIServiceExportRequests returns a APIServiceExportRequestInformer + APIServiceExportRequests() APIServiceExportRequestInformer + // APIServiceNamespaces returns a APIServiceNamespaceInformer + APIServiceNamespaces() APIServiceNamespaceInformer // BoundAPIResourceSchemas returns a BoundAPIResourceSchemaInformer BoundAPIResourceSchemas() BoundAPIResourceSchemaInformer + // ClusterBindings returns a ClusterBindingInformer + ClusterBindings() ClusterBindingInformer } type scopedVersion struct { @@ -72,10 +117,35 @@ func NewScoped(f internalinterfaces.SharedScopedInformerFactory, namespace strin // APIResourceSchemas returns a APIResourceSchemaInformer func (v *scopedVersion) APIResourceSchemas() APIResourceSchemaInformer { - return &aPIResourceSchemaScopedInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} + return &aPIResourceSchemaScopedInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceBindings returns a APIServiceBindingInformer +func (v *scopedVersion) APIServiceBindings() APIServiceBindingInformer { + return &aPIServiceBindingScopedInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// APIServiceExports returns a APIServiceExportInformer +func (v *scopedVersion) APIServiceExports() APIServiceExportInformer { + return &aPIServiceExportScopedInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// APIServiceExportRequests returns a APIServiceExportRequestInformer +func (v *scopedVersion) APIServiceExportRequests() APIServiceExportRequestInformer { + return &aPIServiceExportRequestScopedInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// APIServiceNamespaces returns a APIServiceNamespaceInformer +func (v *scopedVersion) APIServiceNamespaces() APIServiceNamespaceInformer { + return &aPIServiceNamespaceScopedInformer{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} } + +// ClusterBindings returns a ClusterBindingInformer +func (v *scopedVersion) ClusterBindings() ClusterBindingInformer { + return &clusterBindingScopedInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/sdk/kcp/listers/kubebind/v1alpha1/apiservicebinding_expansion.go b/sdk/kcp/listers/kubebind/v1alpha1/apiservicebinding_expansion.go index c52bcf6c2..de79d8523 100644 --- a/sdk/kcp/listers/kubebind/v1alpha1/apiservicebinding_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha1/apiservicebinding_expansion.go @@ -22,7 +22,7 @@ limitations under the License. package v1alpha1 // APIServiceBindingClusterListerExpansion allows custom methods to be added to APIServiceBindingClusterLister. -type APIServiceBindingClusterListerExpansion interface{} +type APIServiceBindingClusterListerExpansion any // APIServiceBindingListerExpansion allows custom methods to be added to APIServiceBindingLister. -type APIServiceBindingListerExpansion interface{} +type APIServiceBindingListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexport_expansion.go b/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexport_expansion.go index 84a07ed9d..f0e10323c 100644 --- a/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexport_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexport_expansion.go @@ -22,10 +22,10 @@ limitations under the License. package v1alpha1 // APIServiceExportClusterListerExpansion allows custom methods to be added to APIServiceExportClusterLister. -type APIServiceExportClusterListerExpansion interface{} +type APIServiceExportClusterListerExpansion any // APIServiceExportListerExpansion allows custom methods to be added to APIServiceExportLister. -type APIServiceExportListerExpansion interface{} +type APIServiceExportListerExpansion any // APIServiceExportNamespaceListerExpansion allows custom methods to be added to APIServiceExportNamespaceLister. -type APIServiceExportNamespaceListerExpansion interface{} +type APIServiceExportNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexportrequest_expansion.go b/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexportrequest_expansion.go index 5cd380912..2116affb2 100644 --- a/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexportrequest_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha1/apiserviceexportrequest_expansion.go @@ -22,10 +22,10 @@ limitations under the License. package v1alpha1 // APIServiceExportRequestClusterListerExpansion allows custom methods to be added to APIServiceExportRequestClusterLister. -type APIServiceExportRequestClusterListerExpansion interface{} +type APIServiceExportRequestClusterListerExpansion any // APIServiceExportRequestListerExpansion allows custom methods to be added to APIServiceExportRequestLister. -type APIServiceExportRequestListerExpansion interface{} +type APIServiceExportRequestListerExpansion any // APIServiceExportRequestNamespaceListerExpansion allows custom methods to be added to APIServiceExportRequestNamespaceLister. -type APIServiceExportRequestNamespaceListerExpansion interface{} +type APIServiceExportRequestNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha1/apiservicenamespace_expansion.go b/sdk/kcp/listers/kubebind/v1alpha1/apiservicenamespace_expansion.go index b8b0a3088..01abe877d 100644 --- a/sdk/kcp/listers/kubebind/v1alpha1/apiservicenamespace_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha1/apiservicenamespace_expansion.go @@ -22,10 +22,10 @@ limitations under the License. package v1alpha1 // APIServiceNamespaceClusterListerExpansion allows custom methods to be added to APIServiceNamespaceClusterLister. -type APIServiceNamespaceClusterListerExpansion interface{} +type APIServiceNamespaceClusterListerExpansion any // APIServiceNamespaceListerExpansion allows custom methods to be added to APIServiceNamespaceLister. -type APIServiceNamespaceListerExpansion interface{} +type APIServiceNamespaceListerExpansion any // APIServiceNamespaceNamespaceListerExpansion allows custom methods to be added to APIServiceNamespaceNamespaceLister. -type APIServiceNamespaceNamespaceListerExpansion interface{} +type APIServiceNamespaceNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha1/clusterbinding_expansion.go b/sdk/kcp/listers/kubebind/v1alpha1/clusterbinding_expansion.go index a3c5d74da..1c6494afe 100644 --- a/sdk/kcp/listers/kubebind/v1alpha1/clusterbinding_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha1/clusterbinding_expansion.go @@ -22,10 +22,10 @@ limitations under the License. package v1alpha1 // ClusterBindingClusterListerExpansion allows custom methods to be added to ClusterBindingClusterLister. -type ClusterBindingClusterListerExpansion interface{} +type ClusterBindingClusterListerExpansion any // ClusterBindingListerExpansion allows custom methods to be added to ClusterBindingLister. -type ClusterBindingListerExpansion interface{} +type ClusterBindingListerExpansion any // ClusterBindingNamespaceListerExpansion allows custom methods to be added to ClusterBindingNamespaceLister. -type ClusterBindingNamespaceListerExpansion interface{} +type ClusterBindingNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiconversion_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/apiconversion_expansion.go index 9ab53f362..24bfd7f03 100644 --- a/sdk/kcp/listers/kubebind/v1alpha2/apiconversion_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiconversion_expansion.go @@ -22,7 +22,7 @@ limitations under the License. package v1alpha2 // APIConversionClusterListerExpansion allows custom methods to be added to APIConversionClusterLister. -type APIConversionClusterListerExpansion interface{} +type APIConversionClusterListerExpansion any // APIConversionListerExpansion allows custom methods to be added to APIConversionLister. -type APIConversionListerExpansion interface{} +type APIConversionListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema.go b/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema.go index 5498fd446..99025a512 100644 --- a/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema.go +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema.go @@ -52,7 +52,6 @@ type aPIResourceSchemaClusterLister struct { // - 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 NewAPIResourceSchemaClusterLister(indexer cache.Indexer) *aPIResourceSchemaClusterLister { return &aPIResourceSchemaClusterLister{indexer: indexer} } @@ -70,18 +69,19 @@ func (s *aPIResourceSchemaClusterLister) Cluster(clusterName logicalcluster.Name return &aPIResourceSchemaLister{indexer: s.indexer, clusterName: clusterName} } -// APIResourceSchemaLister can list APIResourceSchemas across all namespaces, or scope down to a APIResourceSchemaNamespaceLister for one namespace. +// APIResourceSchemaLister can list all APIResourceSchemas, or get one in particular. // All objects returned here must be treated as read-only. type APIResourceSchemaLister interface { // List lists all APIResourceSchemas in the workspace. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*kubebindv1alpha2.APIResourceSchema, err error) - // APIResourceSchemas returns a lister that can list and get APIResourceSchemas in one workspace and namespace. - APIResourceSchemas(namespace string) APIResourceSchemaNamespaceLister + // Get retrieves the APIResourceSchema from the indexer for a given workspace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.APIResourceSchema, error) APIResourceSchemaListerExpansion } -// aPIResourceSchemaLister can list all APIResourceSchemas inside a workspace or scope down to a APIResourceSchemaLister for one namespace. +// aPIResourceSchemaLister can list all APIResourceSchemas inside a workspace. type aPIResourceSchemaLister struct { indexer cache.Indexer clusterName logicalcluster.Name @@ -95,42 +95,9 @@ func (s *aPIResourceSchemaLister) List(selector labels.Selector) (ret []*kubebin return ret, err } -// APIResourceSchemas returns an object that can list and get APIResourceSchemas in one namespace. -func (s *aPIResourceSchemaLister) APIResourceSchemas(namespace string) APIResourceSchemaNamespaceLister { - return &aPIResourceSchemaNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} -} - -// aPIResourceSchemaNamespaceLister helps list and get APIResourceSchemas. -// All objects returned here must be treated as read-only. -type APIResourceSchemaNamespaceLister interface { - // List lists all APIResourceSchemas in the workspace and namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*kubebindv1alpha2.APIResourceSchema, err error) - // Get retrieves the APIResourceSchema from the indexer for a given workspace, namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*kubebindv1alpha2.APIResourceSchema, error) - APIResourceSchemaNamespaceListerExpansion -} - -// aPIResourceSchemaNamespaceLister helps list and get APIResourceSchemas. -// All objects returned here must be treated as read-only. -type aPIResourceSchemaNamespaceLister struct { - indexer cache.Indexer - clusterName logicalcluster.Name - namespace string -} - -// List lists all APIResourceSchemas in the indexer for a given workspace and namespace. -func (s *aPIResourceSchemaNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIResourceSchema, err error) { - err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*kubebindv1alpha2.APIResourceSchema)) - }) - return ret, err -} - -// Get retrieves the APIResourceSchema from the indexer for a given workspace, namespace and name. -func (s *aPIResourceSchemaNamespaceLister) Get(name string) (*kubebindv1alpha2.APIResourceSchema, error) { - key := kcpcache.ToClusterAwareKey(s.clusterName.String(), s.namespace, name) +// Get retrieves the APIResourceSchema from the indexer for a given workspace and name. +func (s *aPIResourceSchemaLister) Get(name string) (*kubebindv1alpha2.APIResourceSchema, error) { + key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) obj, exists, err := s.indexer.GetByKey(key) if err != nil { return nil, err @@ -145,12 +112,11 @@ func (s *aPIResourceSchemaNamespaceLister) Get(name string) (*kubebindv1alpha2.A // 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 NewAPIResourceSchemaLister(indexer cache.Indexer) *aPIResourceSchemaScopedLister { return &aPIResourceSchemaScopedLister{indexer: indexer} } -// aPIResourceSchemaScopedLister can list all APIResourceSchemas inside a workspace or scope down to a APIResourceSchemaLister for one namespace. +// aPIResourceSchemaScopedLister can list all APIResourceSchemas inside a workspace. type aPIResourceSchemaScopedLister struct { indexer cache.Indexer } @@ -163,28 +129,9 @@ func (s *aPIResourceSchemaScopedLister) List(selector labels.Selector) (ret []*k return ret, err } -// APIResourceSchemas returns an object that can list and get APIResourceSchemas in one namespace. -func (s *aPIResourceSchemaScopedLister) APIResourceSchemas(namespace string) APIResourceSchemaNamespaceLister { - return &aPIResourceSchemaScopedNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// aPIResourceSchemaScopedNamespaceLister helps list and get APIResourceSchemas. -type aPIResourceSchemaScopedNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all APIResourceSchemas in the indexer for a given workspace and namespace. -func (s *aPIResourceSchemaScopedNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIResourceSchema, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(i interface{}) { - ret = append(ret, i.(*kubebindv1alpha2.APIResourceSchema)) - }) - return ret, err -} - -// Get retrieves the APIResourceSchema from the indexer for a given workspace, namespace and name. -func (s *aPIResourceSchemaScopedNamespaceLister) Get(name string) (*kubebindv1alpha2.APIResourceSchema, error) { - key := s.namespace + "/" + name +// Get retrieves the APIResourceSchema from the indexer for a given workspace and name. +func (s *aPIResourceSchemaScopedLister) Get(name string) (*kubebindv1alpha2.APIResourceSchema, error) { + key := name obj, exists, err := s.indexer.GetByKey(key) if err != nil { return nil, err diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema_expansion.go index f656c23de..74dd459ff 100644 --- a/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiresourceschema_expansion.go @@ -22,10 +22,10 @@ limitations under the License. package v1alpha2 // APIResourceSchemaClusterListerExpansion allows custom methods to be added to APIResourceSchemaClusterLister. -type APIResourceSchemaClusterListerExpansion interface{} +type APIResourceSchemaClusterListerExpansion any // APIResourceSchemaListerExpansion allows custom methods to be added to APIResourceSchemaLister. -type APIResourceSchemaListerExpansion interface{} +type APIResourceSchemaListerExpansion any // APIResourceSchemaNamespaceListerExpansion allows custom methods to be added to APIResourceSchemaNamespaceLister. -type APIResourceSchemaNamespaceListerExpansion interface{} +type APIResourceSchemaNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiservicebinding.go b/sdk/kcp/listers/kubebind/v1alpha2/apiservicebinding.go new file mode 100644 index 000000000..768604446 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiservicebinding.go @@ -0,0 +1,143 @@ +//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" +) + +// APIServiceBindingClusterLister can list APIServiceBindings across all workspaces, or scope down to a APIServiceBindingLister for one workspace. +// All objects returned here must be treated as read-only. +type APIServiceBindingClusterLister interface { + // List lists all APIServiceBindings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceBinding, err error) + // Cluster returns a lister that can list and get APIServiceBindings in one workspace. + Cluster(clusterName logicalcluster.Name) APIServiceBindingLister + APIServiceBindingClusterListerExpansion +} + +type aPIServiceBindingClusterLister struct { + indexer cache.Indexer +} + +// NewAPIServiceBindingClusterLister returns a new APIServiceBindingClusterLister. +// 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 +func NewAPIServiceBindingClusterLister(indexer cache.Indexer) *aPIServiceBindingClusterLister { + return &aPIServiceBindingClusterLister{indexer: indexer} +} + +// List lists all APIServiceBindings in the indexer across all workspaces. +func (s *aPIServiceBindingClusterLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*kubebindv1alpha2.APIServiceBinding)) + }) + return ret, err +} + +// Cluster scopes the lister to one workspace, allowing users to list and get APIServiceBindings. +func (s *aPIServiceBindingClusterLister) Cluster(clusterName logicalcluster.Name) APIServiceBindingLister { + return &aPIServiceBindingLister{indexer: s.indexer, clusterName: clusterName} +} + +// APIServiceBindingLister can list all APIServiceBindings, or get one in particular. +// All objects returned here must be treated as read-only. +type APIServiceBindingLister interface { + // List lists all APIServiceBindings in the workspace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceBinding, err error) + // Get retrieves the APIServiceBinding from the indexer for a given workspace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.APIServiceBinding, error) + APIServiceBindingListerExpansion +} + +// aPIServiceBindingLister can list all APIServiceBindings inside a workspace. +type aPIServiceBindingLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name +} + +// List lists all APIServiceBindings in the indexer for a workspace. +func (s *aPIServiceBindingLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceBinding, err error) { + err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceBinding)) + }) + return ret, err +} + +// Get retrieves the APIServiceBinding from the indexer for a given workspace and name. +func (s *aPIServiceBindingLister) Get(name string) (*kubebindv1alpha2.APIServiceBinding, error) { + key := kcpcache.ToClusterAwareKey(s.clusterName.String(), "", name) + obj, exists, err := s.indexer.GetByKey(key) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(kubebindv1alpha2.Resource("apiservicebindings"), name) + } + return obj.(*kubebindv1alpha2.APIServiceBinding), nil +} + +// NewAPIServiceBindingLister returns a new APIServiceBindingLister. +// We assume that the indexer: +// - is fed by a workspace-scoped LIST+WATCH +// - uses cache.MetaNamespaceKeyFunc as the key function +func NewAPIServiceBindingLister(indexer cache.Indexer) *aPIServiceBindingScopedLister { + return &aPIServiceBindingScopedLister{indexer: indexer} +} + +// aPIServiceBindingScopedLister can list all APIServiceBindings inside a workspace. +type aPIServiceBindingScopedLister struct { + indexer cache.Indexer +} + +// List lists all APIServiceBindings in the indexer for a workspace. +func (s *aPIServiceBindingScopedLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceBinding)) + }) + return ret, err +} + +// Get retrieves the APIServiceBinding from the indexer for a given workspace and name. +func (s *aPIServiceBindingScopedLister) Get(name string) (*kubebindv1alpha2.APIServiceBinding, error) { + key := name + obj, exists, err := s.indexer.GetByKey(key) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(kubebindv1alpha2.Resource("apiservicebindings"), name) + } + return obj.(*kubebindv1alpha2.APIServiceBinding), nil +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiservicebinding_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/apiservicebinding_expansion.go new file mode 100644 index 000000000..d683a4da1 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiservicebinding_expansion.go @@ -0,0 +1,28 @@ +//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 + +// APIServiceBindingClusterListerExpansion allows custom methods to be added to APIServiceBindingClusterLister. +type APIServiceBindingClusterListerExpansion any + +// APIServiceBindingListerExpansion allows custom methods to be added to APIServiceBindingLister. +type APIServiceBindingListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexport.go b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexport.go new file mode 100644 index 000000000..c20ac6685 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexport.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" +) + +// APIServiceExportClusterLister can list APIServiceExports across all workspaces, or scope down to a APIServiceExportLister for one workspace. +// All objects returned here must be treated as read-only. +type APIServiceExportClusterLister interface { + // List lists all APIServiceExports in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) + // Cluster returns a lister that can list and get APIServiceExports in one workspace. + Cluster(clusterName logicalcluster.Name) APIServiceExportLister + APIServiceExportClusterListerExpansion +} + +type aPIServiceExportClusterLister struct { + indexer cache.Indexer +} + +// NewAPIServiceExportClusterLister returns a new APIServiceExportClusterLister. +// 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 NewAPIServiceExportClusterLister(indexer cache.Indexer) *aPIServiceExportClusterLister { + return &aPIServiceExportClusterLister{indexer: indexer} +} + +// List lists all APIServiceExports in the indexer across all workspaces. +func (s *aPIServiceExportClusterLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*kubebindv1alpha2.APIServiceExport)) + }) + return ret, err +} + +// Cluster scopes the lister to one workspace, allowing users to list and get APIServiceExports. +func (s *aPIServiceExportClusterLister) Cluster(clusterName logicalcluster.Name) APIServiceExportLister { + return &aPIServiceExportLister{indexer: s.indexer, clusterName: clusterName} +} + +// APIServiceExportLister can list APIServiceExports across all namespaces, or scope down to a APIServiceExportNamespaceLister for one namespace. +// All objects returned here must be treated as read-only. +type APIServiceExportLister interface { + // List lists all APIServiceExports in the workspace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) + // APIServiceExports returns a lister that can list and get APIServiceExports in one workspace and namespace. + APIServiceExports(namespace string) APIServiceExportNamespaceLister + APIServiceExportListerExpansion +} + +// aPIServiceExportLister can list all APIServiceExports inside a workspace or scope down to a APIServiceExportLister for one namespace. +type aPIServiceExportLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name +} + +// List lists all APIServiceExports in the indexer for a workspace. +func (s *aPIServiceExportLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) { + err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExport)) + }) + return ret, err +} + +// APIServiceExports returns an object that can list and get APIServiceExports in one namespace. +func (s *aPIServiceExportLister) APIServiceExports(namespace string) APIServiceExportNamespaceLister { + return &aPIServiceExportNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +} + +// aPIServiceExportNamespaceLister helps list and get APIServiceExports. +// All objects returned here must be treated as read-only. +type APIServiceExportNamespaceLister interface { + // List lists all APIServiceExports in the workspace and namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) + // Get retrieves the APIServiceExport from the indexer for a given workspace, namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.APIServiceExport, error) + APIServiceExportNamespaceListerExpansion +} + +// aPIServiceExportNamespaceLister helps list and get APIServiceExports. +// All objects returned here must be treated as read-only. +type aPIServiceExportNamespaceLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name + namespace string +} + +// List lists all APIServiceExports in the indexer for a given workspace and namespace. +func (s *aPIServiceExportNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) { + err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExport)) + }) + return ret, err +} + +// Get retrieves the APIServiceExport from the indexer for a given workspace, namespace and name. +func (s *aPIServiceExportNamespaceLister) Get(name string) (*kubebindv1alpha2.APIServiceExport, 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("apiserviceexports"), name) + } + return obj.(*kubebindv1alpha2.APIServiceExport), nil +} + +// NewAPIServiceExportLister returns a new APIServiceExportLister. +// 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 NewAPIServiceExportLister(indexer cache.Indexer) *aPIServiceExportScopedLister { + return &aPIServiceExportScopedLister{indexer: indexer} +} + +// aPIServiceExportScopedLister can list all APIServiceExports inside a workspace or scope down to a APIServiceExportLister for one namespace. +type aPIServiceExportScopedLister struct { + indexer cache.Indexer +} + +// List lists all APIServiceExports in the indexer for a workspace. +func (s *aPIServiceExportScopedLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) { + err = cache.ListAll(s.indexer, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExport)) + }) + return ret, err +} + +// APIServiceExports returns an object that can list and get APIServiceExports in one namespace. +func (s *aPIServiceExportScopedLister) APIServiceExports(namespace string) APIServiceExportNamespaceLister { + return &aPIServiceExportScopedNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// aPIServiceExportScopedNamespaceLister helps list and get APIServiceExports. +type aPIServiceExportScopedNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all APIServiceExports in the indexer for a given workspace and namespace. +func (s *aPIServiceExportScopedNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExport, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExport)) + }) + return ret, err +} + +// Get retrieves the APIServiceExport from the indexer for a given workspace, namespace and name. +func (s *aPIServiceExportScopedNamespaceLister) Get(name string) (*kubebindv1alpha2.APIServiceExport, 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("apiserviceexports"), name) + } + return obj.(*kubebindv1alpha2.APIServiceExport), nil +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexport_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexport_expansion.go new file mode 100644 index 000000000..7b5f5b94e --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexport_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 + +// APIServiceExportClusterListerExpansion allows custom methods to be added to APIServiceExportClusterLister. +type APIServiceExportClusterListerExpansion any + +// APIServiceExportListerExpansion allows custom methods to be added to APIServiceExportLister. +type APIServiceExportListerExpansion any + +// APIServiceExportNamespaceListerExpansion allows custom methods to be added to APIServiceExportNamespaceLister. +type APIServiceExportNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexportrequest.go b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexportrequest.go new file mode 100644 index 000000000..d5c414f65 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexportrequest.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" +) + +// APIServiceExportRequestClusterLister can list APIServiceExportRequests across all workspaces, or scope down to a APIServiceExportRequestLister for one workspace. +// All objects returned here must be treated as read-only. +type APIServiceExportRequestClusterLister interface { + // List lists all APIServiceExportRequests in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) + // Cluster returns a lister that can list and get APIServiceExportRequests in one workspace. + Cluster(clusterName logicalcluster.Name) APIServiceExportRequestLister + APIServiceExportRequestClusterListerExpansion +} + +type aPIServiceExportRequestClusterLister struct { + indexer cache.Indexer +} + +// NewAPIServiceExportRequestClusterLister returns a new APIServiceExportRequestClusterLister. +// 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 NewAPIServiceExportRequestClusterLister(indexer cache.Indexer) *aPIServiceExportRequestClusterLister { + return &aPIServiceExportRequestClusterLister{indexer: indexer} +} + +// List lists all APIServiceExportRequests in the indexer across all workspaces. +func (s *aPIServiceExportRequestClusterLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*kubebindv1alpha2.APIServiceExportRequest)) + }) + return ret, err +} + +// Cluster scopes the lister to one workspace, allowing users to list and get APIServiceExportRequests. +func (s *aPIServiceExportRequestClusterLister) Cluster(clusterName logicalcluster.Name) APIServiceExportRequestLister { + return &aPIServiceExportRequestLister{indexer: s.indexer, clusterName: clusterName} +} + +// APIServiceExportRequestLister can list APIServiceExportRequests across all namespaces, or scope down to a APIServiceExportRequestNamespaceLister for one namespace. +// All objects returned here must be treated as read-only. +type APIServiceExportRequestLister interface { + // List lists all APIServiceExportRequests in the workspace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) + // APIServiceExportRequests returns a lister that can list and get APIServiceExportRequests in one workspace and namespace. + APIServiceExportRequests(namespace string) APIServiceExportRequestNamespaceLister + APIServiceExportRequestListerExpansion +} + +// aPIServiceExportRequestLister can list all APIServiceExportRequests inside a workspace or scope down to a APIServiceExportRequestLister for one namespace. +type aPIServiceExportRequestLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name +} + +// List lists all APIServiceExportRequests in the indexer for a workspace. +func (s *aPIServiceExportRequestLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) { + err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExportRequest)) + }) + return ret, err +} + +// APIServiceExportRequests returns an object that can list and get APIServiceExportRequests in one namespace. +func (s *aPIServiceExportRequestLister) APIServiceExportRequests(namespace string) APIServiceExportRequestNamespaceLister { + return &aPIServiceExportRequestNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +} + +// aPIServiceExportRequestNamespaceLister helps list and get APIServiceExportRequests. +// All objects returned here must be treated as read-only. +type APIServiceExportRequestNamespaceLister interface { + // List lists all APIServiceExportRequests in the workspace and namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) + // Get retrieves the APIServiceExportRequest from the indexer for a given workspace, namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.APIServiceExportRequest, error) + APIServiceExportRequestNamespaceListerExpansion +} + +// aPIServiceExportRequestNamespaceLister helps list and get APIServiceExportRequests. +// All objects returned here must be treated as read-only. +type aPIServiceExportRequestNamespaceLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name + namespace string +} + +// List lists all APIServiceExportRequests in the indexer for a given workspace and namespace. +func (s *aPIServiceExportRequestNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) { + err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExportRequest)) + }) + return ret, err +} + +// Get retrieves the APIServiceExportRequest from the indexer for a given workspace, namespace and name. +func (s *aPIServiceExportRequestNamespaceLister) Get(name string) (*kubebindv1alpha2.APIServiceExportRequest, 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("apiserviceexportrequests"), name) + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), nil +} + +// NewAPIServiceExportRequestLister returns a new APIServiceExportRequestLister. +// 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 NewAPIServiceExportRequestLister(indexer cache.Indexer) *aPIServiceExportRequestScopedLister { + return &aPIServiceExportRequestScopedLister{indexer: indexer} +} + +// aPIServiceExportRequestScopedLister can list all APIServiceExportRequests inside a workspace or scope down to a APIServiceExportRequestLister for one namespace. +type aPIServiceExportRequestScopedLister struct { + indexer cache.Indexer +} + +// List lists all APIServiceExportRequests in the indexer for a workspace. +func (s *aPIServiceExportRequestScopedLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) { + err = cache.ListAll(s.indexer, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExportRequest)) + }) + return ret, err +} + +// APIServiceExportRequests returns an object that can list and get APIServiceExportRequests in one namespace. +func (s *aPIServiceExportRequestScopedLister) APIServiceExportRequests(namespace string) APIServiceExportRequestNamespaceLister { + return &aPIServiceExportRequestScopedNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// aPIServiceExportRequestScopedNamespaceLister helps list and get APIServiceExportRequests. +type aPIServiceExportRequestScopedNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all APIServiceExportRequests in the indexer for a given workspace and namespace. +func (s *aPIServiceExportRequestScopedNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceExportRequest, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceExportRequest)) + }) + return ret, err +} + +// Get retrieves the APIServiceExportRequest from the indexer for a given workspace, namespace and name. +func (s *aPIServiceExportRequestScopedNamespaceLister) Get(name string) (*kubebindv1alpha2.APIServiceExportRequest, 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("apiserviceexportrequests"), name) + } + return obj.(*kubebindv1alpha2.APIServiceExportRequest), nil +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexportrequest_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexportrequest_expansion.go new file mode 100644 index 000000000..652f98783 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiserviceexportrequest_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 + +// APIServiceExportRequestClusterListerExpansion allows custom methods to be added to APIServiceExportRequestClusterLister. +type APIServiceExportRequestClusterListerExpansion any + +// APIServiceExportRequestListerExpansion allows custom methods to be added to APIServiceExportRequestLister. +type APIServiceExportRequestListerExpansion any + +// APIServiceExportRequestNamespaceListerExpansion allows custom methods to be added to APIServiceExportRequestNamespaceLister. +type APIServiceExportRequestNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiservicenamespace.go b/sdk/kcp/listers/kubebind/v1alpha2/apiservicenamespace.go new file mode 100644 index 000000000..8bf6c9619 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiservicenamespace.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" +) + +// APIServiceNamespaceClusterLister can list APIServiceNamespaces across all workspaces, or scope down to a APIServiceNamespaceLister for one workspace. +// All objects returned here must be treated as read-only. +type APIServiceNamespaceClusterLister interface { + // List lists all APIServiceNamespaces in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) + // Cluster returns a lister that can list and get APIServiceNamespaces in one workspace. + Cluster(clusterName logicalcluster.Name) APIServiceNamespaceLister + APIServiceNamespaceClusterListerExpansion +} + +type aPIServiceNamespaceClusterLister struct { + indexer cache.Indexer +} + +// NewAPIServiceNamespaceClusterLister returns a new APIServiceNamespaceClusterLister. +// 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 NewAPIServiceNamespaceClusterLister(indexer cache.Indexer) *aPIServiceNamespaceClusterLister { + return &aPIServiceNamespaceClusterLister{indexer: indexer} +} + +// List lists all APIServiceNamespaces in the indexer across all workspaces. +func (s *aPIServiceNamespaceClusterLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*kubebindv1alpha2.APIServiceNamespace)) + }) + return ret, err +} + +// Cluster scopes the lister to one workspace, allowing users to list and get APIServiceNamespaces. +func (s *aPIServiceNamespaceClusterLister) Cluster(clusterName logicalcluster.Name) APIServiceNamespaceLister { + return &aPIServiceNamespaceLister{indexer: s.indexer, clusterName: clusterName} +} + +// APIServiceNamespaceLister can list APIServiceNamespaces across all namespaces, or scope down to a APIServiceNamespaceNamespaceLister for one namespace. +// All objects returned here must be treated as read-only. +type APIServiceNamespaceLister interface { + // List lists all APIServiceNamespaces in the workspace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) + // APIServiceNamespaces returns a lister that can list and get APIServiceNamespaces in one workspace and namespace. + APIServiceNamespaces(namespace string) APIServiceNamespaceNamespaceLister + APIServiceNamespaceListerExpansion +} + +// aPIServiceNamespaceLister can list all APIServiceNamespaces inside a workspace or scope down to a APIServiceNamespaceLister for one namespace. +type aPIServiceNamespaceLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name +} + +// List lists all APIServiceNamespaces in the indexer for a workspace. +func (s *aPIServiceNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) { + err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceNamespace)) + }) + return ret, err +} + +// APIServiceNamespaces returns an object that can list and get APIServiceNamespaces in one namespace. +func (s *aPIServiceNamespaceLister) APIServiceNamespaces(namespace string) APIServiceNamespaceNamespaceLister { + return &aPIServiceNamespaceNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +} + +// aPIServiceNamespaceNamespaceLister helps list and get APIServiceNamespaces. +// All objects returned here must be treated as read-only. +type APIServiceNamespaceNamespaceLister interface { + // List lists all APIServiceNamespaces in the workspace and namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) + // Get retrieves the APIServiceNamespace from the indexer for a given workspace, namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.APIServiceNamespace, error) + APIServiceNamespaceNamespaceListerExpansion +} + +// aPIServiceNamespaceNamespaceLister helps list and get APIServiceNamespaces. +// All objects returned here must be treated as read-only. +type aPIServiceNamespaceNamespaceLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name + namespace string +} + +// List lists all APIServiceNamespaces in the indexer for a given workspace and namespace. +func (s *aPIServiceNamespaceNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) { + err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceNamespace)) + }) + return ret, err +} + +// Get retrieves the APIServiceNamespace from the indexer for a given workspace, namespace and name. +func (s *aPIServiceNamespaceNamespaceLister) Get(name string) (*kubebindv1alpha2.APIServiceNamespace, 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("apiservicenamespaces"), name) + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), nil +} + +// NewAPIServiceNamespaceLister returns a new APIServiceNamespaceLister. +// 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 NewAPIServiceNamespaceLister(indexer cache.Indexer) *aPIServiceNamespaceScopedLister { + return &aPIServiceNamespaceScopedLister{indexer: indexer} +} + +// aPIServiceNamespaceScopedLister can list all APIServiceNamespaces inside a workspace or scope down to a APIServiceNamespaceLister for one namespace. +type aPIServiceNamespaceScopedLister struct { + indexer cache.Indexer +} + +// List lists all APIServiceNamespaces in the indexer for a workspace. +func (s *aPIServiceNamespaceScopedLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) { + err = cache.ListAll(s.indexer, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceNamespace)) + }) + return ret, err +} + +// APIServiceNamespaces returns an object that can list and get APIServiceNamespaces in one namespace. +func (s *aPIServiceNamespaceScopedLister) APIServiceNamespaces(namespace string) APIServiceNamespaceNamespaceLister { + return &aPIServiceNamespaceScopedNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// aPIServiceNamespaceScopedNamespaceLister helps list and get APIServiceNamespaces. +type aPIServiceNamespaceScopedNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all APIServiceNamespaces in the indexer for a given workspace and namespace. +func (s *aPIServiceNamespaceScopedNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.APIServiceNamespace, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.APIServiceNamespace)) + }) + return ret, err +} + +// Get retrieves the APIServiceNamespace from the indexer for a given workspace, namespace and name. +func (s *aPIServiceNamespaceScopedNamespaceLister) Get(name string) (*kubebindv1alpha2.APIServiceNamespace, 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("apiservicenamespaces"), name) + } + return obj.(*kubebindv1alpha2.APIServiceNamespace), nil +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/apiservicenamespace_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/apiservicenamespace_expansion.go new file mode 100644 index 000000000..b4c9dc910 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/apiservicenamespace_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 + +// APIServiceNamespaceClusterListerExpansion allows custom methods to be added to APIServiceNamespaceClusterLister. +type APIServiceNamespaceClusterListerExpansion any + +// APIServiceNamespaceListerExpansion allows custom methods to be added to APIServiceNamespaceLister. +type APIServiceNamespaceListerExpansion any + +// APIServiceNamespaceNamespaceListerExpansion allows custom methods to be added to APIServiceNamespaceNamespaceLister. +type APIServiceNamespaceNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go index 38db5beeb..236d3a16b 100644 --- a/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go +++ b/sdk/kcp/listers/kubebind/v1alpha2/boundapiresourceschema_expansion.go @@ -22,10 +22,10 @@ limitations under the License. package v1alpha2 // BoundAPIResourceSchemaClusterListerExpansion allows custom methods to be added to BoundAPIResourceSchemaClusterLister. -type BoundAPIResourceSchemaClusterListerExpansion interface{} +type BoundAPIResourceSchemaClusterListerExpansion any // BoundAPIResourceSchemaListerExpansion allows custom methods to be added to BoundAPIResourceSchemaLister. -type BoundAPIResourceSchemaListerExpansion interface{} +type BoundAPIResourceSchemaListerExpansion any // BoundAPIResourceSchemaNamespaceListerExpansion allows custom methods to be added to BoundAPIResourceSchemaNamespaceLister. -type BoundAPIResourceSchemaNamespaceListerExpansion interface{} +type BoundAPIResourceSchemaNamespaceListerExpansion any diff --git a/sdk/kcp/listers/kubebind/v1alpha2/clusterbinding.go b/sdk/kcp/listers/kubebind/v1alpha2/clusterbinding.go new file mode 100644 index 000000000..ecda43ff5 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/clusterbinding.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" +) + +// ClusterBindingClusterLister can list ClusterBindings across all workspaces, or scope down to a ClusterBindingLister for one workspace. +// All objects returned here must be treated as read-only. +type ClusterBindingClusterLister interface { + // List lists all ClusterBindings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) + // Cluster returns a lister that can list and get ClusterBindings in one workspace. + Cluster(clusterName logicalcluster.Name) ClusterBindingLister + ClusterBindingClusterListerExpansion +} + +type clusterBindingClusterLister struct { + indexer cache.Indexer +} + +// NewClusterBindingClusterLister returns a new ClusterBindingClusterLister. +// 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 NewClusterBindingClusterLister(indexer cache.Indexer) *clusterBindingClusterLister { + return &clusterBindingClusterLister{indexer: indexer} +} + +// List lists all ClusterBindings in the indexer across all workspaces. +func (s *clusterBindingClusterLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*kubebindv1alpha2.ClusterBinding)) + }) + return ret, err +} + +// Cluster scopes the lister to one workspace, allowing users to list and get ClusterBindings. +func (s *clusterBindingClusterLister) Cluster(clusterName logicalcluster.Name) ClusterBindingLister { + return &clusterBindingLister{indexer: s.indexer, clusterName: clusterName} +} + +// ClusterBindingLister can list ClusterBindings across all namespaces, or scope down to a ClusterBindingNamespaceLister for one namespace. +// All objects returned here must be treated as read-only. +type ClusterBindingLister interface { + // List lists all ClusterBindings in the workspace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) + // ClusterBindings returns a lister that can list and get ClusterBindings in one workspace and namespace. + ClusterBindings(namespace string) ClusterBindingNamespaceLister + ClusterBindingListerExpansion +} + +// clusterBindingLister can list all ClusterBindings inside a workspace or scope down to a ClusterBindingLister for one namespace. +type clusterBindingLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name +} + +// List lists all ClusterBindings in the indexer for a workspace. +func (s *clusterBindingLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) { + err = kcpcache.ListAllByCluster(s.indexer, s.clusterName, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.ClusterBinding)) + }) + return ret, err +} + +// ClusterBindings returns an object that can list and get ClusterBindings in one namespace. +func (s *clusterBindingLister) ClusterBindings(namespace string) ClusterBindingNamespaceLister { + return &clusterBindingNamespaceLister{indexer: s.indexer, clusterName: s.clusterName, namespace: namespace} +} + +// clusterBindingNamespaceLister helps list and get ClusterBindings. +// All objects returned here must be treated as read-only. +type ClusterBindingNamespaceLister interface { + // List lists all ClusterBindings in the workspace and namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) + // Get retrieves the ClusterBinding from the indexer for a given workspace, namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.ClusterBinding, error) + ClusterBindingNamespaceListerExpansion +} + +// clusterBindingNamespaceLister helps list and get ClusterBindings. +// All objects returned here must be treated as read-only. +type clusterBindingNamespaceLister struct { + indexer cache.Indexer + clusterName logicalcluster.Name + namespace string +} + +// List lists all ClusterBindings in the indexer for a given workspace and namespace. +func (s *clusterBindingNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) { + err = kcpcache.ListAllByClusterAndNamespace(s.indexer, s.clusterName, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.ClusterBinding)) + }) + return ret, err +} + +// Get retrieves the ClusterBinding from the indexer for a given workspace, namespace and name. +func (s *clusterBindingNamespaceLister) Get(name string) (*kubebindv1alpha2.ClusterBinding, 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("clusterbindings"), name) + } + return obj.(*kubebindv1alpha2.ClusterBinding), nil +} + +// NewClusterBindingLister returns a new ClusterBindingLister. +// 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 NewClusterBindingLister(indexer cache.Indexer) *clusterBindingScopedLister { + return &clusterBindingScopedLister{indexer: indexer} +} + +// clusterBindingScopedLister can list all ClusterBindings inside a workspace or scope down to a ClusterBindingLister for one namespace. +type clusterBindingScopedLister struct { + indexer cache.Indexer +} + +// List lists all ClusterBindings in the indexer for a workspace. +func (s *clusterBindingScopedLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.ClusterBinding)) + }) + return ret, err +} + +// ClusterBindings returns an object that can list and get ClusterBindings in one namespace. +func (s *clusterBindingScopedLister) ClusterBindings(namespace string) ClusterBindingNamespaceLister { + return &clusterBindingScopedNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// clusterBindingScopedNamespaceLister helps list and get ClusterBindings. +type clusterBindingScopedNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ClusterBindings in the indexer for a given workspace and namespace. +func (s *clusterBindingScopedNamespaceLister) List(selector labels.Selector) (ret []*kubebindv1alpha2.ClusterBinding, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(i interface{}) { + ret = append(ret, i.(*kubebindv1alpha2.ClusterBinding)) + }) + return ret, err +} + +// Get retrieves the ClusterBinding from the indexer for a given workspace, namespace and name. +func (s *clusterBindingScopedNamespaceLister) Get(name string) (*kubebindv1alpha2.ClusterBinding, 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("clusterbindings"), name) + } + return obj.(*kubebindv1alpha2.ClusterBinding), nil +} diff --git a/sdk/kcp/listers/kubebind/v1alpha2/clusterbinding_expansion.go b/sdk/kcp/listers/kubebind/v1alpha2/clusterbinding_expansion.go new file mode 100644 index 000000000..52859ddf5 --- /dev/null +++ b/sdk/kcp/listers/kubebind/v1alpha2/clusterbinding_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 + +// ClusterBindingClusterListerExpansion allows custom methods to be added to ClusterBindingClusterLister. +type ClusterBindingClusterListerExpansion any + +// ClusterBindingListerExpansion allows custom methods to be added to ClusterBindingLister. +type ClusterBindingListerExpansion any + +// ClusterBindingNamespaceListerExpansion allows custom methods to be added to ClusterBindingNamespaceLister. +type ClusterBindingNamespaceListerExpansion any diff --git a/test/e2e/bind/happy-case_test.go b/test/e2e/bind/happy-case_test.go index 2597d3bac..c46a26585 100644 --- a/test/e2e/bind/happy-case_test.go +++ b/test/e2e/bind/happy-case_test.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/yaml" clusterscoped "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/cluster-scoped" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" providerfixtures "github.com/kube-bind/kube-bind/test/e2e/bind/fixtures/provider" "github.com/kube-bind/kube-bind/test/e2e/framework" ) @@ -46,19 +46,19 @@ func TestClusterScoped(t *testing.T) { t.Parallel() // cluster scoped resource, with cluster scoped informers - testHappyCase(t, apiextensionsv1.ClusterScoped, kubebindv1alpha1.ClusterScope) + testHappyCase(t, apiextensionsv1.ClusterScoped, kubebindv1alpha2.ClusterScope) } func TestNamespacedScoped(t *testing.T) { t.Parallel() // namespaced resource, with namespace scoped informers - testHappyCase(t, apiextensionsv1.NamespaceScoped, kubebindv1alpha1.NamespacedScope) + testHappyCase(t, apiextensionsv1.NamespaceScoped, kubebindv1alpha2.NamespacedScope) // namespaced resource, but with cluster scoped informers - testHappyCase(t, apiextensionsv1.NamespaceScoped, kubebindv1alpha1.ClusterScope) + testHappyCase(t, apiextensionsv1.NamespaceScoped, kubebindv1alpha2.ClusterScope) } -func testHappyCase(t *testing.T, resourceScope apiextensionsv1.ResourceScope, informerScope kubebindv1alpha1.Scope) { +func testHappyCase(t *testing.T, resourceScope apiextensionsv1.ResourceScope, informerScope kubebindv1alpha2.InformerScope) { ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) @@ -385,7 +385,7 @@ func simulateBrowser(t *testing.T, authURLCh chan string, resource string) { func toUnstructured(t *testing.T, manifest string) *unstructured.Unstructured { t.Helper() - obj := map[string]interface{}{} + obj := map[string]any{} err := yaml.Unmarshal([]byte(manifest), &obj) require.NoError(t, err) diff --git a/test/e2e/framework/backend.go b/test/e2e/framework/backend.go index 4fbc9d342..99f9c34f4 100644 --- a/test/e2e/framework/backend.go +++ b/test/e2e/framework/backend.go @@ -38,7 +38,7 @@ import ( backend "github.com/kube-bind/kube-bind/contrib/example-backend" "github.com/kube-bind/kube-bind/contrib/example-backend/options" "github.com/kube-bind/kube-bind/deploy/crd" - kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) func StartBackend(t *testing.T, clientConfig *rest.Config, args ...string) (net.Addr, *backend.Server) { @@ -63,10 +63,12 @@ func StartBackendWithoutDefaultArgs(t *testing.T, clientConfig *rest.Config, arg require.NoError(t, err) err = crd.Create(ctx, crdClient.ApiextensionsV1().CustomResourceDefinitions(), - metav1.GroupResource{Group: kubebindv1alpha1.GroupName, Resource: "clusterbindings"}, - metav1.GroupResource{Group: kubebindv1alpha1.GroupName, Resource: "apiserviceexports"}, - metav1.GroupResource{Group: kubebindv1alpha1.GroupName, Resource: "apiservicenamespaces"}, - metav1.GroupResource{Group: kubebindv1alpha1.GroupName, Resource: "apiserviceexportrequests"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "apiresourceschemas"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "boundapiresourceschemas"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "clusterbindings"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "apiserviceexports"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "apiservicenamespaces"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "apiserviceexportrequests"}, ) require.NoError(t, err) diff --git a/test/e2e/framework/kcp.go b/test/e2e/framework/kcp.go index 65493681f..fe85bd7b4 100644 --- a/test/e2e/framework/kcp.go +++ b/test/e2e/framework/kcp.go @@ -54,14 +54,14 @@ func init() { utilruntime.Must(tenancyv1alpha1.AddToScheme(kcpScheme)) } -func WithName(s string, formatArgs ...interface{}) ClusterWorkspaceOption { +func WithName(s string, formatArgs ...any) ClusterWorkspaceOption { return func(ws *tenancyv1alpha1.Workspace) { ws.Name = fmt.Sprintf(s, formatArgs...) ws.GenerateName = "" } } -func WithGenerateName(s string, formatArgs ...interface{}) ClusterWorkspaceOption { +func WithGenerateName(s string, formatArgs ...any) ClusterWorkspaceOption { return func(ws *tenancyv1alpha1.Workspace) { s = fmt.Sprintf(s, formatArgs...) // Workspace.ObjectMeta.GenerateName is broken in kcp: https://github.com/kcp-dev/kcp/pull/2193