diff --git a/.gitignore b/.gitignore index a037ae76..54f12567 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ dist/ /kubeflex/ +# Code generator tools (repo-local) +hack/tools/bin/ + # Ignore generated CRDs for the chart chart/crds/controlplanes.yaml chart/crds/postcreatehooks.yaml diff --git a/Makefile b/Makefile index e0780a03..13034ee1 100644 --- a/Makefile +++ b/Makefile @@ -104,6 +104,14 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." +.PHONY: generate-clients +generate-clients: ## Generate typed clientset, informers, and listers using Kubernetes code-generator. + ./hack/update-codegen.sh + +.PHONY: verify-codegen +verify-codegen: ## Verify that generated code is up-to-date. + ./hack/verify-codegen.sh + .PHONY: fmt fmt: ## Run go fmt against code. go fmt ./... diff --git a/api/v1alpha1/controlplane_types.go b/api/v1alpha1/controlplane_types.go index ef7079ad..f8d05337 100644 --- a/api/v1alpha1/controlplane_types.go +++ b/api/v1alpha1/controlplane_types.go @@ -76,6 +76,8 @@ type ControlPlaneStatus struct { } // ControlPlane is the Schema for the controlplanes API +// +genclient +// +genclient:nonNamespaced // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" @@ -159,7 +161,3 @@ type BootstrapSecretReference struct { // Required InClusterKey string `json:"inClusterKey"` } - -func init() { - SchemeBuilder.Register(&ControlPlane{}, &ControlPlaneList{}) -} diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/doc.go similarity index 59% rename from api/v1alpha1/groupversion_info.go rename to api/v1alpha1/doc.go index c88234de..8d554c92 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/doc.go @@ -14,23 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the tenancy v1alpha1 API group // +kubebuilder:object:generate=true // +groupName=tenancy.kflex.kubestellar.org -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "tenancy.kflex.kubestellar.org", Version: "v1alpha1"} - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) +// Package v1alpha1 contains API Schema definitions for the tenancy v1alpha1 API group +package v1alpha1 diff --git a/api/v1alpha1/postcreatehook_types.go b/api/v1alpha1/postcreatehook_types.go index 61b77d79..847ec532 100644 --- a/api/v1alpha1/postcreatehook_types.go +++ b/api/v1alpha1/postcreatehook_types.go @@ -41,7 +41,9 @@ type PostCreateHookStatus struct { SecretRef *SecretReference `json:"secretRef,omitempty"` } -// PostCreateHook is the Schema for the controlplanes API +// PostCreateHook is the Schema for the postcreatehooks API +// +genclient +// +genclient:nonNamespaced // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" @@ -72,7 +74,3 @@ type Manifest struct { // +kubebuilder:pruning:PreserveUnknownFields runtime.RawExtension `json:",inline"` } - -func init() { - SchemeBuilder.Register(&PostCreateHook{}, &PostCreateHookList{}) -} diff --git a/api/v1alpha1/register.go b/api/v1alpha1/register.go new file mode 100644 index 00000000..7abfd9e3 --- /dev/null +++ b/api/v1alpha1/register.go @@ -0,0 +1,51 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: "tenancy.kflex.kubestellar.org", Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &ControlPlane{}, + &ControlPlaneList{}, + &PostCreateHook{}, + &PostCreateHookList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/config/crd/bases/tenancy.kflex.kubestellar.org_controlplanes.yaml b/config/crd/bases/tenancy.kflex.kubestellar.org_controlplanes.yaml index c1e350b1..6c2912e7 100644 --- a/config/crd/bases/tenancy.kflex.kubestellar.org_controlplanes.yaml +++ b/config/crd/bases/tenancy.kflex.kubestellar.org_controlplanes.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.15.0 + controller-gen.kubebuilder.io/version: v0.17.3 name: controlplanes.tenancy.kflex.kubestellar.org spec: group: tenancy.kflex.kubestellar.org @@ -142,6 +142,8 @@ spec: WaitForPostCreateHooks determines if the control plane should wait for all post create hook resources to be ready before marking the control plane as ready type: boolean + required: + - type type: object status: description: ControlPlaneStatus defines the observed state of ControlPlane diff --git a/config/crd/bases/tenancy.kflex.kubestellar.org_postcreatehooks.yaml b/config/crd/bases/tenancy.kflex.kubestellar.org_postcreatehooks.yaml index a1c24c1f..3a8b37d4 100644 --- a/config/crd/bases/tenancy.kflex.kubestellar.org_postcreatehooks.yaml +++ b/config/crd/bases/tenancy.kflex.kubestellar.org_postcreatehooks.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.15.0 + controller-gen.kubebuilder.io/version: v0.17.3 name: postcreatehooks.tenancy.kflex.kubestellar.org spec: group: tenancy.kflex.kubestellar.org @@ -33,7 +33,7 @@ spec: name: v1alpha1 schema: openAPIV3Schema: - description: PostCreateHook is the Schema for the controlplanes API + description: PostCreateHook is the Schema for the postcreatehooks API properties: apiVersion: description: |- diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 69377ee9..5d74eb70 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -12,138 +12,18 @@ rules: - "" resources: - configmaps - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - endpoints - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - endpoints/restricted - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - events - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - namespaces - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - persistentvolumeclaims - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - pods - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - pods/attach - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - pods/exec - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - pods/log - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - pods/portforward - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - secrets + - services verbs: - create - delete @@ -165,18 +45,6 @@ rules: - services - update - watch -- apiGroups: - - "" - resources: - - services - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - apiextensions.k8s.io resources: @@ -193,6 +61,7 @@ rules: - apps resources: - deployments + - statefulsets verbs: - create - delete @@ -209,18 +78,6 @@ rules: - get - list - watch -- apiGroups: - - apps - resources: - - statefulsets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - batch resources: @@ -261,41 +118,8 @@ rules: - rbac.authorization.k8s.io resources: - clusterrolebindings - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - rbac.authorization.k8s.io - resources: - clusterroles - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - rbac.authorization.k8s.io - resources: - rolebindings - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - rbac.authorization.k8s.io - resources: - roles verbs: - create diff --git a/docs/code-generation.md b/docs/code-generation.md new file mode 100644 index 00000000..2b3cb317 --- /dev/null +++ b/docs/code-generation.md @@ -0,0 +1,52 @@ +# Code Generation Guide + +This document describes how to generate and maintain typed Kubernetes clients for the kubeflex CRDs. + +## Overview + +kubeflex uses the standard Kubernetes code-generator tools to generate: + +- **Typed Clientsets**: Strongly-typed clients for interacting with CRDs via the Kubernetes API +- **Informers**: SharedInformerFactory for watching CRD resources with local caching +- **Listers**: Typed listers for reading CRD resources from informer caches + +## Prerequisites + +- Go 1.24.5+ installed +- Access to `k8s.io/code-generator` (automatically fetched during generation) + +## Generating Code + +To regenerate all typed clients, informers, and listers: + +```bash +make generate-clients +``` + +This runs `hack/update-codegen.sh`, which invokes the Kubernetes code-generator tools. + +## Verifying Generated Code + +To verify that generated code is up-to-date: + +```bash +make verify-codegen +``` + +This is useful in CI pipelines to ensure generated code is committed after API changes. + +## When to Regenerate + +Regenerate typed clients when API types in `api/v1alpha1/` are modified. + +## Troubleshooting + +### Code generation fails + +Ensure you have the correct version of Go installed and that `k8s.io/code-generator` is accessible. + +### Generated code doesn't compile + +Check that: +1. API types have proper markers (`+k8s:deepcopy-gen=package`, `+groupName=...`, `+genclient`) + diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh new file mode 100755 index 00000000..33e10171 --- /dev/null +++ b/hack/update-codegen.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Copyright 2023 The KubeStellar 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. + +# This script generates typed clients, informers, and listers for the +# kubeflex CRDs using the Kubernetes code-generator. + +set -o errexit +set -o nounset +set -o pipefail + +REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +cd "${REPO_ROOT}" + +# Module and package configuration +MODULE="github.com/kubestellar/kubeflex" +API_PKG="api" +OUTPUT_PKG="pkg/generated" + +# Determine code-generator version from go.mod +CODEGEN_VERSION=$(go list -m -f '{{.Version}}' k8s.io/code-generator) + +# Tools directory (repo-local, not GOPATH) +TOOLS_BIN_DIR="${REPO_ROOT}/hack/tools/bin" +mkdir -p "${TOOLS_BIN_DIR}" +TOOLS_BIN_DIR="$(cd "${TOOLS_BIN_DIR}" && pwd)" + +# Install code generators to repo-local directory +echo "Installing code-generator tools to ${TOOLS_BIN_DIR}..." +GOBIN="${TOOLS_BIN_DIR}" go install "k8s.io/code-generator/cmd/client-gen@${CODEGEN_VERSION}" +GOBIN="${TOOLS_BIN_DIR}" go install "k8s.io/code-generator/cmd/lister-gen@${CODEGEN_VERSION}" +GOBIN="${TOOLS_BIN_DIR}" go install "k8s.io/code-generator/cmd/informer-gen@${CODEGEN_VERSION}" + +# Header file for generated code +BOILERPLATE="${REPO_ROOT}/hack/boilerplate.go.txt" + +# Delete entire generated code tree for reproducibility +echo "Clearing ${OUTPUT_PKG}..." +rm -rf "${REPO_ROOT}/${OUTPUT_PKG}" + +echo "Generating clientset..." +"${TOOLS_BIN_DIR}/client-gen" \ + --clientset-name "versioned" \ + --input-base "" \ + --input "${MODULE}/${API_PKG}/v1alpha1" \ + --output-dir "${REPO_ROOT}/${OUTPUT_PKG}/clientset" \ + --output-pkg "${MODULE}/${OUTPUT_PKG}/clientset" \ + --go-header-file "${BOILERPLATE}" + +echo "Generating listers..." +"${TOOLS_BIN_DIR}/lister-gen" \ + --output-dir "${REPO_ROOT}/${OUTPUT_PKG}/listers" \ + --output-pkg "${MODULE}/${OUTPUT_PKG}/listers" \ + --go-header-file "${BOILERPLATE}" \ + "${MODULE}/api/v1alpha1" + +echo "Generating informers..." +"${TOOLS_BIN_DIR}/informer-gen" \ + --versioned-clientset-package "${MODULE}/${OUTPUT_PKG}/clientset/versioned" \ + --listers-package "${MODULE}/${OUTPUT_PKG}/listers" \ + --output-dir "${REPO_ROOT}/${OUTPUT_PKG}/informers" \ + --output-pkg "${MODULE}/${OUTPUT_PKG}/informers" \ + --go-header-file "${BOILERPLATE}" \ + "${MODULE}/api/v1alpha1" + +echo "Code generation complete." diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh new file mode 100755 index 00000000..5edc25e7 --- /dev/null +++ b/hack/verify-codegen.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Copyright 2023 The KubeStellar 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. + +# This script verifies that the generated code is up-to-date. + +set -o errexit +set -o nounset +set -o pipefail + +REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +cd "${REPO_ROOT}" + +# Create temporary directory for generated code +DIFFROOT="${REPO_ROOT}/pkg/generated" +TMP_DIFFROOT="$(mktemp -d)" +trap 'rm -rf "${TMP_DIFFROOT}"' EXIT + +# Copy current generated code to temp +if [[ -d "${DIFFROOT}" ]]; then + cp -a "${DIFFROOT}/." "${TMP_DIFFROOT}" +fi + +# Invoke update-codegen.sh to regenerate code (it handles clearing) +echo "Regenerating code..." +"${REPO_ROOT}/hack/update-codegen.sh" + +echo "Verifying generated code is up-to-date..." + +# Check for differences +if ! diff -Naupr "${TMP_DIFFROOT}" "${DIFFROOT}"; then + echo "" + echo "Generated code is out of date. Please run:" + echo " hack/update-codegen.sh" + echo "" + exit 1 +fi + +echo "Generated code is up-to-date." diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 677e1307..6b02fa41 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -19,10 +19,10 @@ limitations under the License. package versioned import ( - "fmt" - "net/http" + fmt "fmt" + http "net/http" - tenancyv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/v1alpha1" + tenancyv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/api/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,18 +30,18 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - Tenancy() tenancyv1alpha1.TenancyInterface + TenancyV1alpha1() tenancyv1alpha1.TenancyV1alpha1Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient - tenancy *tenancyv1alpha1.TenancyClient + tenancyV1alpha1 *tenancyv1alpha1.TenancyV1alpha1Client } -// Tenancy retrieves the TenancyClient -func (c *Clientset) Tenancy() tenancyv1alpha1.TenancyInterface { - return c.tenancy +// TenancyV1alpha1 retrieves the TenancyV1alpha1Client +func (c *Clientset) TenancyV1alpha1() tenancyv1alpha1.TenancyV1alpha1Interface { + return c.tenancyV1alpha1 } // Discovery retrieves the DiscoveryClient @@ -88,7 +88,7 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error - cs.tenancy, err = tenancyv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + cs.tenancyV1alpha1, err = tenancyv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -113,7 +113,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.tenancy = tenancyv1alpha1.New(c) + cs.tenancyV1alpha1 = tenancyv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index e3b29531..d9ef0838 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -20,8 +20,8 @@ package fake import ( clientset "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned" - tenancyv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/v1alpha1" - faketenancyv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/v1alpha1/fake" + tenancyv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/api/v1alpha1" + faketenancyv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -31,8 +31,12 @@ import ( // NewSimpleClientset returns a clientset that will respond with the provided objects. // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement +// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement // for a real clientset and is mostly useful in simple unit tests. +// +// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves +// server side apply testing. NewClientset is only available when apply configurations are generated (e.g. +// via --with-applyconfig). func NewSimpleClientset(objects ...runtime.Object) *Clientset { o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) for _, obj := range objects { @@ -79,7 +83,7 @@ var ( _ testing.FakeClient = &Clientset{} ) -// Tenancy retrieves the TenancyClient -func (c *Clientset) Tenancy() tenancyv1alpha1.TenancyInterface { - return &faketenancyv1alpha1.FakeTenancy{Fake: &c.Fake} +// TenancyV1alpha1 retrieves the TenancyV1alpha1Client +func (c *Clientset) TenancyV1alpha1() tenancyv1alpha1.TenancyV1alpha1Interface { + return &faketenancyv1alpha1.FakeTenancyV1alpha1{Fake: &c.Fake} } diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 43b3cc3c..b7c1fbc2 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - tenancyinternalversion "github.com/kubestellar/kubeflex/api/v1alpha1" + tenancyv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - tenancyinternalversion.AddToScheme, + tenancyv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index 4e2c7b5e..ce77f0fc 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -19,23 +19,38 @@ limitations under the License. package scheme import ( - tenancy "github.com/kubestellar/kubeflex/api/v1alpha1" + tenancyv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" ) var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + tenancyv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme func init() { v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - Install(Scheme) -} - -// Install registers the API group and adds types to a scheme -func Install(scheme *runtime.Scheme) { - tenancy.Install(scheme) + utilruntime.Must(AddToScheme(Scheme)) } diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/v1alpha1_client.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/api_client.go similarity index 57% rename from pkg/generated/clientset/versioned/typed/v1alpha1/v1alpha1_client.go rename to pkg/generated/clientset/versioned/typed/api/v1alpha1/api_client.go index ad7460fb..a43197c8 100644 --- a/pkg/generated/clientset/versioned/typed/v1alpha1/v1alpha1_client.go +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/api_client.go @@ -19,30 +19,36 @@ limitations under the License. package v1alpha1 import ( - "net/http" + http "net/http" - "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/scheme" + apiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + scheme "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) -type TenancyInterface interface { +type TenancyV1alpha1Interface interface { RESTClient() rest.Interface ControlPlanesGetter + PostCreateHooksGetter } -// TenancyClient is used to interact with features provided by the tenancy.kflex.kubestellar.org group. -type TenancyClient struct { +// TenancyV1alpha1Client is used to interact with features provided by the tenancy.kflex.kubestellar.org group. +type TenancyV1alpha1Client struct { restClient rest.Interface } -func (c *TenancyClient) ControlPlanes(namespace string) ControlPlaneInterface { - return newControlPlanes(c, namespace) +func (c *TenancyV1alpha1Client) ControlPlanes() ControlPlaneInterface { + return newControlPlanes(c) } -// NewForConfig creates a new TenancyClient for the given config. +func (c *TenancyV1alpha1Client) PostCreateHooks() PostCreateHookInterface { + return newPostCreateHooks(c) +} + +// NewForConfig creates a new TenancyV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*TenancyClient, error) { +func NewForConfig(c *rest.Config) (*TenancyV1alpha1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -54,9 +60,9 @@ func NewForConfig(c *rest.Config) (*TenancyClient, error) { return NewForConfigAndClient(&config, httpClient) } -// NewForConfigAndClient creates a new TenancyClient for the given config and http client. +// NewForConfigAndClient creates a new TenancyV1alpha1Client 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) (*TenancyClient, error) { +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*TenancyV1alpha1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -65,12 +71,12 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*TenancyClient, erro if err != nil { return nil, err } - return &TenancyClient{client}, nil + return &TenancyV1alpha1Client{client}, nil } -// NewForConfigOrDie creates a new TenancyClient for the given config and +// NewForConfigOrDie creates a new TenancyV1alpha1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *TenancyClient { +func NewForConfigOrDie(c *rest.Config) *TenancyV1alpha1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -78,35 +84,27 @@ func NewForConfigOrDie(c *rest.Config) *TenancyClient { return client } -// New creates a new TenancyClient for the given RESTClient. -func New(c rest.Interface) *TenancyClient { - return &TenancyClient{c} +// New creates a new TenancyV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *TenancyV1alpha1Client { + return &TenancyV1alpha1Client{c} } func setConfigDefaults(config *rest.Config) error { + gv := apiv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() + if config.UserAgent == "" { config.UserAgent = rest.DefaultKubernetesUserAgent() } - if config.GroupVersion == nil || config.GroupVersion.Group != scheme.Scheme.PrioritizedVersionsForGroup("tenancy.kflex.kubestellar.org")[0].Group { - gv := scheme.Scheme.PrioritizedVersionsForGroup("tenancy.kflex.kubestellar.org")[0] - config.GroupVersion = &gv - } - config.NegotiatedSerializer = scheme.Codecs - - if config.QPS == 0 { - config.QPS = 5 - } - if config.Burst == 0 { - config.Burst = 10 - } return nil } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *TenancyClient) RESTClient() rest.Interface { +func (c *TenancyV1alpha1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/generated/clientset/versioned/typed/api/v1alpha1/controlplane.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/controlplane.go new file mode 100644 index 00000000..e883c351 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/controlplane.go @@ -0,0 +1,70 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + context "context" + + apiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + scheme "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/scheme" + 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" +) + +// ControlPlanesGetter has a method to return a ControlPlaneInterface. +// A group's client should implement this interface. +type ControlPlanesGetter interface { + ControlPlanes() ControlPlaneInterface +} + +// ControlPlaneInterface has methods to work with ControlPlane resources. +type ControlPlaneInterface interface { + Create(ctx context.Context, controlPlane *apiv1alpha1.ControlPlane, opts v1.CreateOptions) (*apiv1alpha1.ControlPlane, error) + Update(ctx context.Context, controlPlane *apiv1alpha1.ControlPlane, opts v1.UpdateOptions) (*apiv1alpha1.ControlPlane, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, controlPlane *apiv1alpha1.ControlPlane, opts v1.UpdateOptions) (*apiv1alpha1.ControlPlane, 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) (*apiv1alpha1.ControlPlane, error) + List(ctx context.Context, opts v1.ListOptions) (*apiv1alpha1.ControlPlaneList, 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 *apiv1alpha1.ControlPlane, err error) + ControlPlaneExpansion +} + +// controlPlanes implements ControlPlaneInterface +type controlPlanes struct { + *gentype.ClientWithList[*apiv1alpha1.ControlPlane, *apiv1alpha1.ControlPlaneList] +} + +// newControlPlanes returns a ControlPlanes +func newControlPlanes(c *TenancyV1alpha1Client) *controlPlanes { + return &controlPlanes{ + gentype.NewClientWithList[*apiv1alpha1.ControlPlane, *apiv1alpha1.ControlPlaneList]( + "controlplanes", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *apiv1alpha1.ControlPlane { return &apiv1alpha1.ControlPlane{} }, + func() *apiv1alpha1.ControlPlaneList { return &apiv1alpha1.ControlPlaneList{} }, + ), + } +} diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/v1alpha1/doc.go rename to pkg/generated/clientset/versioned/typed/api/v1alpha1/doc.go diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/v1alpha1/fake/doc.go rename to pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/doc.go diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/fake/fake_v1alpha1_client.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_api_client.go similarity index 72% rename from pkg/generated/clientset/versioned/typed/v1alpha1/fake/fake_v1alpha1_client.go rename to pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_api_client.go index b7986355..b3896e10 100644 --- a/pkg/generated/clientset/versioned/typed/v1alpha1/fake/fake_v1alpha1_client.go +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_api_client.go @@ -19,22 +19,26 @@ limitations under the License. package fake import ( - v1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/v1alpha1" + v1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/api/v1alpha1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeTenancy struct { +type FakeTenancyV1alpha1 struct { *testing.Fake } -func (c *FakeTenancy) ControlPlanes(namespace string) v1alpha1.ControlPlaneInterface { - return &FakeControlPlanes{c, namespace} +func (c *FakeTenancyV1alpha1) ControlPlanes() v1alpha1.ControlPlaneInterface { + return newFakeControlPlanes(c) +} + +func (c *FakeTenancyV1alpha1) PostCreateHooks() v1alpha1.PostCreateHookInterface { + return newFakePostCreateHooks(c) } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeTenancy) RESTClient() rest.Interface { +func (c *FakeTenancyV1alpha1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_controlplane.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_controlplane.go new file mode 100644 index 00000000..e4131012 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_controlplane.go @@ -0,0 +1,52 @@ +/* +Copyright 2023 The KubeStellar 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 ( + v1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + apiv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/api/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakeControlPlanes implements ControlPlaneInterface +type fakeControlPlanes struct { + *gentype.FakeClientWithList[*v1alpha1.ControlPlane, *v1alpha1.ControlPlaneList] + Fake *FakeTenancyV1alpha1 +} + +func newFakeControlPlanes(fake *FakeTenancyV1alpha1) apiv1alpha1.ControlPlaneInterface { + return &fakeControlPlanes{ + gentype.NewFakeClientWithList[*v1alpha1.ControlPlane, *v1alpha1.ControlPlaneList]( + fake.Fake, + "", + v1alpha1.SchemeGroupVersion.WithResource("controlplanes"), + v1alpha1.SchemeGroupVersion.WithKind("ControlPlane"), + func() *v1alpha1.ControlPlane { return &v1alpha1.ControlPlane{} }, + func() *v1alpha1.ControlPlaneList { return &v1alpha1.ControlPlaneList{} }, + func(dst, src *v1alpha1.ControlPlaneList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.ControlPlaneList) []*v1alpha1.ControlPlane { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1alpha1.ControlPlaneList, items []*v1alpha1.ControlPlane) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_postcreatehook.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_postcreatehook.go new file mode 100644 index 00000000..575e58a2 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/fake/fake_postcreatehook.go @@ -0,0 +1,52 @@ +/* +Copyright 2023 The KubeStellar 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 ( + v1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + apiv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/typed/api/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakePostCreateHooks implements PostCreateHookInterface +type fakePostCreateHooks struct { + *gentype.FakeClientWithList[*v1alpha1.PostCreateHook, *v1alpha1.PostCreateHookList] + Fake *FakeTenancyV1alpha1 +} + +func newFakePostCreateHooks(fake *FakeTenancyV1alpha1) apiv1alpha1.PostCreateHookInterface { + return &fakePostCreateHooks{ + gentype.NewFakeClientWithList[*v1alpha1.PostCreateHook, *v1alpha1.PostCreateHookList]( + fake.Fake, + "", + v1alpha1.SchemeGroupVersion.WithResource("postcreatehooks"), + v1alpha1.SchemeGroupVersion.WithKind("PostCreateHook"), + func() *v1alpha1.PostCreateHook { return &v1alpha1.PostCreateHook{} }, + func() *v1alpha1.PostCreateHookList { return &v1alpha1.PostCreateHookList{} }, + func(dst, src *v1alpha1.PostCreateHookList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.PostCreateHookList) []*v1alpha1.PostCreateHook { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1alpha1.PostCreateHookList, items []*v1alpha1.PostCreateHook) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/generated_expansion.go similarity index 94% rename from pkg/generated/clientset/versioned/typed/v1alpha1/generated_expansion.go rename to pkg/generated/clientset/versioned/typed/api/v1alpha1/generated_expansion.go index 5cfca081..c0968c35 100644 --- a/pkg/generated/clientset/versioned/typed/v1alpha1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/generated_expansion.go @@ -19,3 +19,5 @@ limitations under the License. package v1alpha1 type ControlPlaneExpansion interface{} + +type PostCreateHookExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/api/v1alpha1/postcreatehook.go b/pkg/generated/clientset/versioned/typed/api/v1alpha1/postcreatehook.go new file mode 100644 index 00000000..f55c41c7 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/api/v1alpha1/postcreatehook.go @@ -0,0 +1,70 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + context "context" + + apiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + scheme "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/scheme" + 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" +) + +// PostCreateHooksGetter has a method to return a PostCreateHookInterface. +// A group's client should implement this interface. +type PostCreateHooksGetter interface { + PostCreateHooks() PostCreateHookInterface +} + +// PostCreateHookInterface has methods to work with PostCreateHook resources. +type PostCreateHookInterface interface { + Create(ctx context.Context, postCreateHook *apiv1alpha1.PostCreateHook, opts v1.CreateOptions) (*apiv1alpha1.PostCreateHook, error) + Update(ctx context.Context, postCreateHook *apiv1alpha1.PostCreateHook, opts v1.UpdateOptions) (*apiv1alpha1.PostCreateHook, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, postCreateHook *apiv1alpha1.PostCreateHook, opts v1.UpdateOptions) (*apiv1alpha1.PostCreateHook, 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) (*apiv1alpha1.PostCreateHook, error) + List(ctx context.Context, opts v1.ListOptions) (*apiv1alpha1.PostCreateHookList, 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 *apiv1alpha1.PostCreateHook, err error) + PostCreateHookExpansion +} + +// postCreateHooks implements PostCreateHookInterface +type postCreateHooks struct { + *gentype.ClientWithList[*apiv1alpha1.PostCreateHook, *apiv1alpha1.PostCreateHookList] +} + +// newPostCreateHooks returns a PostCreateHooks +func newPostCreateHooks(c *TenancyV1alpha1Client) *postCreateHooks { + return &postCreateHooks{ + gentype.NewClientWithList[*apiv1alpha1.PostCreateHook, *apiv1alpha1.PostCreateHookList]( + "postcreatehooks", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *apiv1alpha1.PostCreateHook { return &apiv1alpha1.PostCreateHook{} }, + func() *apiv1alpha1.PostCreateHookList { return &apiv1alpha1.PostCreateHookList{} }, + ), + } +} diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/controlplane.go b/pkg/generated/clientset/versioned/typed/v1alpha1/controlplane.go deleted file mode 100644 index 409b3e5f..00000000 --- a/pkg/generated/clientset/versioned/typed/v1alpha1/controlplane.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright 2023 The KubeStellar 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 v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" - scheme "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ControlPlanesGetter has a method to return a ControlPlaneInterface. -// A group's client should implement this interface. -type ControlPlanesGetter interface { - ControlPlanes(namespace string) ControlPlaneInterface -} - -// ControlPlaneInterface has methods to work with ControlPlane resources. -type ControlPlaneInterface interface { - Create(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.CreateOptions) (*v1alpha1.ControlPlane, error) - Update(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.UpdateOptions) (*v1alpha1.ControlPlane, error) - UpdateStatus(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.UpdateOptions) (*v1alpha1.ControlPlane, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ControlPlane, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ControlPlaneList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ControlPlane, err error) - ControlPlaneExpansion -} - -// controlPlanes implements ControlPlaneInterface -type controlPlanes struct { - client rest.Interface - ns string -} - -// newControlPlanes returns a ControlPlanes -func newControlPlanes(c *TenancyClient, namespace string) *controlPlanes { - return &controlPlanes{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the controlPlane, and returns the corresponding controlPlane object, and an error if there is any. -func (c *controlPlanes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ControlPlane, err error) { - result = &v1alpha1.ControlPlane{} - err = c.client.Get(). - Namespace(c.ns). - Resource("controlplanes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ControlPlanes that match those selectors. -func (c *controlPlanes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ControlPlaneList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ControlPlaneList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("controlplanes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested controlPlanes. -func (c *controlPlanes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("controlplanes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a controlPlane and creates it. Returns the server's representation of the controlPlane, and an error, if there is any. -func (c *controlPlanes) Create(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.CreateOptions) (result *v1alpha1.ControlPlane, err error) { - result = &v1alpha1.ControlPlane{} - err = c.client.Post(). - Namespace(c.ns). - Resource("controlplanes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(controlPlane). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a controlPlane and updates it. Returns the server's representation of the controlPlane, and an error, if there is any. -func (c *controlPlanes) Update(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.UpdateOptions) (result *v1alpha1.ControlPlane, err error) { - result = &v1alpha1.ControlPlane{} - err = c.client.Put(). - Namespace(c.ns). - Resource("controlplanes"). - Name(controlPlane.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(controlPlane). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *controlPlanes) UpdateStatus(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.UpdateOptions) (result *v1alpha1.ControlPlane, err error) { - result = &v1alpha1.ControlPlane{} - err = c.client.Put(). - Namespace(c.ns). - Resource("controlplanes"). - Name(controlPlane.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(controlPlane). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the controlPlane and deletes it. Returns an error if one occurs. -func (c *controlPlanes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("controlplanes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *controlPlanes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("controlplanes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched controlPlane. -func (c *controlPlanes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ControlPlane, err error) { - result = &v1alpha1.ControlPlane{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("controlplanes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/generated/clientset/versioned/typed/v1alpha1/fake/fake_controlplane.go b/pkg/generated/clientset/versioned/typed/v1alpha1/fake/fake_controlplane.go deleted file mode 100644 index 9b0c45d3..00000000 --- a/pkg/generated/clientset/versioned/typed/v1alpha1/fake/fake_controlplane.go +++ /dev/null @@ -1,141 +0,0 @@ -/* -Copyright 2023 The KubeStellar 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" - - v1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeControlPlanes implements ControlPlaneInterface -type FakeControlPlanes struct { - Fake *FakeTenancy - ns string -} - -var controlplanesResource = v1alpha1.GroupVersion.WithResource("controlplanes") - -var controlplanesKind = v1alpha1.GroupVersion.WithKind("ControlPlane") - -// Get takes name of the controlPlane, and returns the corresponding controlPlane object, and an error if there is any. -func (c *FakeControlPlanes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ControlPlane, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(controlplanesResource, c.ns, name), &v1alpha1.ControlPlane{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ControlPlane), err -} - -// List takes label and field selectors, and returns the list of ControlPlanes that match those selectors. -func (c *FakeControlPlanes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ControlPlaneList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(controlplanesResource, controlplanesKind, c.ns, opts), &v1alpha1.ControlPlaneList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ControlPlaneList{ListMeta: obj.(*v1alpha1.ControlPlaneList).ListMeta} - for _, item := range obj.(*v1alpha1.ControlPlaneList).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 controlPlanes. -func (c *FakeControlPlanes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(controlplanesResource, c.ns, opts)) - -} - -// Create takes the representation of a controlPlane and creates it. Returns the server's representation of the controlPlane, and an error, if there is any. -func (c *FakeControlPlanes) Create(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.CreateOptions) (result *v1alpha1.ControlPlane, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(controlplanesResource, c.ns, controlPlane), &v1alpha1.ControlPlane{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ControlPlane), err -} - -// Update takes the representation of a controlPlane and updates it. Returns the server's representation of the controlPlane, and an error, if there is any. -func (c *FakeControlPlanes) Update(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.UpdateOptions) (result *v1alpha1.ControlPlane, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(controlplanesResource, c.ns, controlPlane), &v1alpha1.ControlPlane{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ControlPlane), 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 *FakeControlPlanes) UpdateStatus(ctx context.Context, controlPlane *v1alpha1.ControlPlane, opts v1.UpdateOptions) (*v1alpha1.ControlPlane, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(controlplanesResource, "status", c.ns, controlPlane), &v1alpha1.ControlPlane{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ControlPlane), err -} - -// Delete takes name of the controlPlane and deletes it. Returns an error if one occurs. -func (c *FakeControlPlanes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(controlplanesResource, c.ns, name, opts), &v1alpha1.ControlPlane{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeControlPlanes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(controlplanesResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.ControlPlaneList{}) - return err -} - -// Patch applies the patch and returns the patched controlPlane. -func (c *FakeControlPlanes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ControlPlane, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(controlplanesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ControlPlane{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ControlPlane), err -} diff --git a/pkg/generated/informers/externalversions/api/interface.go b/pkg/generated/informers/externalversions/api/interface.go new file mode 100644 index 00000000..de90c128 --- /dev/null +++ b/pkg/generated/informers/externalversions/api/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2023 The KubeStellar 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 api + +import ( + v1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/api/v1alpha1" + internalinterfaces "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/api/v1alpha1/controlplane.go b/pkg/generated/informers/externalversions/api/v1alpha1/controlplane.go new file mode 100644 index 00000000..c5e19550 --- /dev/null +++ b/pkg/generated/informers/externalversions/api/v1alpha1/controlplane.go @@ -0,0 +1,89 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + context "context" + time "time" + + kubeflexapiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + versioned "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned" + internalinterfaces "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/internalinterfaces" + apiv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/listers/api/v1alpha1" + 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" +) + +// ControlPlaneInformer provides access to a shared informer and lister for +// ControlPlanes. +type ControlPlaneInformer interface { + Informer() cache.SharedIndexInformer + Lister() apiv1alpha1.ControlPlaneLister +} + +type controlPlaneInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewControlPlaneInformer constructs a new informer for ControlPlane 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 NewControlPlaneInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredControlPlaneInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredControlPlaneInformer constructs a new informer for ControlPlane 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 NewFilteredControlPlaneInformer(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.TenancyV1alpha1().ControlPlanes().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TenancyV1alpha1().ControlPlanes().Watch(context.TODO(), options) + }, + }, + &kubeflexapiv1alpha1.ControlPlane{}, + resyncPeriod, + indexers, + ) +} + +func (f *controlPlaneInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredControlPlaneInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *controlPlaneInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubeflexapiv1alpha1.ControlPlane{}, f.defaultInformer) +} + +func (f *controlPlaneInformer) Lister() apiv1alpha1.ControlPlaneLister { + return apiv1alpha1.NewControlPlaneLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/api/v1alpha1/interface.go b/pkg/generated/informers/externalversions/api/v1alpha1/interface.go new file mode 100644 index 00000000..f1d568de --- /dev/null +++ b/pkg/generated/informers/externalversions/api/v1alpha1/interface.go @@ -0,0 +1,52 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + internalinterfaces "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ControlPlanes returns a ControlPlaneInformer. + ControlPlanes() ControlPlaneInformer + // PostCreateHooks returns a PostCreateHookInformer. + PostCreateHooks() PostCreateHookInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// ControlPlanes returns a ControlPlaneInformer. +func (v *version) ControlPlanes() ControlPlaneInformer { + return &controlPlaneInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// PostCreateHooks returns a PostCreateHookInformer. +func (v *version) PostCreateHooks() PostCreateHookInformer { + return &postCreateHookInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/informers/externalversions/api/v1alpha1/postcreatehook.go b/pkg/generated/informers/externalversions/api/v1alpha1/postcreatehook.go new file mode 100644 index 00000000..7a2a581d --- /dev/null +++ b/pkg/generated/informers/externalversions/api/v1alpha1/postcreatehook.go @@ -0,0 +1,89 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + context "context" + time "time" + + kubeflexapiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + versioned "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned" + internalinterfaces "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/internalinterfaces" + apiv1alpha1 "github.com/kubestellar/kubeflex/pkg/generated/listers/api/v1alpha1" + 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" +) + +// PostCreateHookInformer provides access to a shared informer and lister for +// PostCreateHooks. +type PostCreateHookInformer interface { + Informer() cache.SharedIndexInformer + Lister() apiv1alpha1.PostCreateHookLister +} + +type postCreateHookInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewPostCreateHookInformer constructs a new informer for PostCreateHook 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 NewPostCreateHookInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPostCreateHookInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredPostCreateHookInformer constructs a new informer for PostCreateHook 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 NewFilteredPostCreateHookInformer(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.TenancyV1alpha1().PostCreateHooks().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TenancyV1alpha1().PostCreateHooks().Watch(context.TODO(), options) + }, + }, + &kubeflexapiv1alpha1.PostCreateHook{}, + resyncPeriod, + indexers, + ) +} + +func (f *postCreateHookInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPostCreateHookInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *postCreateHookInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kubeflexapiv1alpha1.PostCreateHook{}, f.defaultInformer) +} + +func (f *postCreateHookInformer) Lister() apiv1alpha1.PostCreateHookLister { + return apiv1alpha1.NewPostCreateHookLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go new file mode 100644 index 00000000..7be87f79 --- /dev/null +++ b/pkg/generated/informers/externalversions/factory.go @@ -0,0 +1,262 @@ +/* +Copyright 2023 The KubeStellar 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 externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned" + api "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/api" + internalinterfaces "github.com/kubestellar/kubeflex/pkg/generated/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + // Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Tenancy() api.Interface +} + +func (f *sharedInformerFactory) Tenancy() api.Interface { + return api.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go new file mode 100644 index 00000000..91386954 --- /dev/null +++ b/pkg/generated/informers/externalversions/generic.go @@ -0,0 +1,64 @@ +/* +Copyright 2023 The KubeStellar 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 externalversions + +import ( + fmt "fmt" + + v1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=tenancy.kflex.kubestellar.org, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("controlplanes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Tenancy().V1alpha1().ControlPlanes().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("postcreatehooks"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Tenancy().V1alpha1().PostCreateHooks().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 00000000..e5c8a69b --- /dev/null +++ b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2023 The KubeStellar 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 internalinterfaces + +import ( + time "time" + + versioned "github.com/kubestellar/kubeflex/pkg/generated/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/generated/listers/api/v1alpha1/controlplane.go b/pkg/generated/listers/api/v1alpha1/controlplane.go new file mode 100644 index 00000000..6917bf22 --- /dev/null +++ b/pkg/generated/listers/api/v1alpha1/controlplane.go @@ -0,0 +1,48 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + apiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// ControlPlaneLister helps list ControlPlanes. +// All objects returned here must be treated as read-only. +type ControlPlaneLister interface { + // List lists all ControlPlanes in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*apiv1alpha1.ControlPlane, err error) + // Get retrieves the ControlPlane from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*apiv1alpha1.ControlPlane, error) + ControlPlaneListerExpansion +} + +// controlPlaneLister implements the ControlPlaneLister interface. +type controlPlaneLister struct { + listers.ResourceIndexer[*apiv1alpha1.ControlPlane] +} + +// NewControlPlaneLister returns a new ControlPlaneLister. +func NewControlPlaneLister(indexer cache.Indexer) ControlPlaneLister { + return &controlPlaneLister{listers.New[*apiv1alpha1.ControlPlane](indexer, apiv1alpha1.Resource("controlplane"))} +} diff --git a/pkg/generated/listers/api/v1alpha1/expansion_generated.go b/pkg/generated/listers/api/v1alpha1/expansion_generated.go new file mode 100644 index 00000000..9c346b4a --- /dev/null +++ b/pkg/generated/listers/api/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +// ControlPlaneListerExpansion allows custom methods to be added to +// ControlPlaneLister. +type ControlPlaneListerExpansion interface{} + +// PostCreateHookListerExpansion allows custom methods to be added to +// PostCreateHookLister. +type PostCreateHookListerExpansion interface{} diff --git a/pkg/generated/listers/api/v1alpha1/postcreatehook.go b/pkg/generated/listers/api/v1alpha1/postcreatehook.go new file mode 100644 index 00000000..aaa57eb9 --- /dev/null +++ b/pkg/generated/listers/api/v1alpha1/postcreatehook.go @@ -0,0 +1,48 @@ +/* +Copyright 2023 The KubeStellar 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 v1alpha1 + +import ( + apiv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// PostCreateHookLister helps list PostCreateHooks. +// All objects returned here must be treated as read-only. +type PostCreateHookLister interface { + // List lists all PostCreateHooks in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*apiv1alpha1.PostCreateHook, err error) + // Get retrieves the PostCreateHook from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*apiv1alpha1.PostCreateHook, error) + PostCreateHookListerExpansion +} + +// postCreateHookLister implements the PostCreateHookLister interface. +type postCreateHookLister struct { + listers.ResourceIndexer[*apiv1alpha1.PostCreateHook] +} + +// NewPostCreateHookLister returns a new PostCreateHookLister. +func NewPostCreateHookLister(indexer cache.Indexer) PostCreateHookLister { + return &postCreateHookLister{listers.New[*apiv1alpha1.PostCreateHook](indexer, apiv1alpha1.Resource("postcreatehook"))} +}