diff --git a/Makefile b/Makefile index ffbcf3905..9e1bd54aa 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,38 @@ 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-client ## Generate client packages +generate-client: code-generator + rm -rf client + $(APPLYCONFIGURATION_GEN) \ + --input-dirs="github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" \ + --go-header-file="hack/boilerplate.go.txt" \ + --output-package="github.com/project-codeflare/codeflare-operator/client/applyconfiguration" \ + --trim-path-prefix "github.com/project-codeflare/codeflare-operator" + $(CLIENT_GEN) \ + --input="codeflare/v1alpha1" \ + --input-base="github.com/project-codeflare/codeflare-operator/api" \ + --apply-configuration-package="github.com/project-codeflare/codeflare-operator/client/applyconfiguration" \ + --go-header-file="hack/boilerplate.go.txt" \ + --clientset-name "versioned" \ + --output-package="github.com/project-codeflare/codeflare-operator/client/clientset" \ + --output-base="." \ + --trim-path-prefix "github.com/project-codeflare/codeflare-operator" + $(LISTER_GEN) \ + --input-dirs="github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" \ + --go-header-file="hack/boilerplate.go.txt" \ + --output-base="." \ + --output-package="github.com/project-codeflare/codeflare-operator/client/listers" \ + --trim-path-prefix "github.com/project-codeflare/codeflare-operator" + $(INFORMER_GEN) \ + --input-dirs="github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" \ + --versioned-clientset-package="github.com/project-codeflare/codeflare-operator/client/clientset/versioned" \ + --listers-package="github.com/project-codeflare/codeflare-operator/client/listers" \ + --go-header-file="hack/boilerplate.go.txt" \ + --output-base="." \ + --output-package="github.com/project-codeflare/codeflare-operator/client/informer" \ + --trim-path-prefix "github.com/project-codeflare/codeflare-operator" + .PHONY: fmt fmt: ## Run go fmt against code. go fmt ./... @@ -184,6 +216,10 @@ $(LOCALBIN): ## Tool Binaries KUSTOMIZE ?= $(LOCALBIN)/kustomize +APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen +CLIENT_GEN ?= $(LOCALBIN)/client-gen +LISTER_GEN ?= $(LOCALBIN)/lister-gen +INFORMER_GEN ?= $(LOCALBIN)/informer-gen CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk @@ -191,6 +227,7 @@ GH_CLI ?= $(LOCALBIN)/gh ## Tool Versions KUSTOMIZE_VERSION ?= v4.5.4 +CODEGEN_VERSION ?= v0.27.2 CONTROLLER_TOOLS_VERSION ?= v0.9.2 OPERATOR_SDK_VERSION ?= v1.27.0 GH_CLI_VERSION ?= 2.30.0 @@ -212,6 +249,29 @@ $(GH_CLI): $(LOCALBIN) rm -rf $(GH_CLI_DL_FILENAME) rm $(GH_CLI_DL_FILENAME).tar.gz +.PHONY: code-generator +code-generator: $(APPLYCONFIGURATION_GEN) $(CLIENT_GEN) $(LISTER_GEN) $(INFORMER_GEN) + +.PHONY: applyconfiguration-gen +applyconfiguration-gen: $(APPLYCONFIGURATION_GEN) +$(APPLYCONFIGURATION_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODEGEN_VERSION) + +.PHONY: client-gen +client-gen: $(CLIENT_GEN) +$(CLIENT_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODEGEN_VERSION) + +.PHONY: lister-gen +lister-gen: $(LISTER_GEN) +$(LISTER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODEGEN_VERSION) + +.PHONY: informer-gen +informer-gen: $(INFORMER_GEN) +$(INFORMER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODEGEN_VERSION) + .PHONY: controller-gen controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. $(CONTROLLER_GEN): $(LOCALBIN) diff --git a/api/v1alpha1/groupversion_info.go b/api/codeflare/v1alpha1/doc.go similarity index 51% rename from api/v1alpha1/groupversion_info.go rename to api/codeflare/v1alpha1/doc.go index cce3fbc09..13be1de49 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/codeflare/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 codeflare v1alpha1 API group +// +k8s:deepcopy-gen=package,register // +kubebuilder:object:generate=true // +groupName=codeflare.codeflare.dev -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: "codeflare.codeflare.dev", 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 diff --git a/api/v1alpha1/instascale_types.go b/api/codeflare/v1alpha1/instascale_types.go similarity index 97% rename from api/v1alpha1/instascale_types.go rename to api/codeflare/v1alpha1/instascale_types.go index 063f9a0d4..7368cb1a9 100644 --- a/api/v1alpha1/instascale_types.go +++ b/api/codeflare/v1alpha1/instascale_types.go @@ -59,6 +59,7 @@ type InstaScaleStatus struct { Ready bool `json:"ready"` } +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status @@ -80,7 +81,3 @@ type InstaScaleList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []InstaScale `json:"items"` } - -func init() { - SchemeBuilder.Register(&InstaScale{}, &InstaScaleList{}) -} diff --git a/api/v1alpha1/mcad_types.go b/api/codeflare/v1alpha1/mcad_types.go similarity index 93% rename from api/v1alpha1/mcad_types.go rename to api/codeflare/v1alpha1/mcad_types.go index e109bcaac..217791a21 100644 --- a/api/v1alpha1/mcad_types.go +++ b/api/codeflare/v1alpha1/mcad_types.go @@ -48,7 +48,7 @@ type MCADSpec struct { // PodCreationTimeout determines timeout in milliseconds for pods to be created after dispatching job. // +kubebuilder:default=-1 PodCreationTimeout int `json:"podCreationTimeout,omitempty"` - //podCreationTimeout: //int (default blank) + // podCreationTimeout: //int (default blank) // ControllerResources defines the cpu and memory resource requirements for the MCAD Controller // +kubebuilder:default={} @@ -63,8 +63,9 @@ type MCADStatus struct { Ready bool `json:"ready"` } -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status // MCAD is the Schema for the mcads API type MCAD struct { @@ -75,7 +76,7 @@ type MCAD struct { Status MCADStatus `json:"status,omitempty"` } -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // MCADList contains a list of MCAD type MCADList struct { @@ -83,7 +84,3 @@ type MCADList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []MCAD `json:"items"` } - -func init() { - SchemeBuilder.Register(&MCAD{}, &MCADList{}) -} diff --git a/api/codeflare/v1alpha1/register.go b/api/codeflare/v1alpha1/register.go new file mode 100644 index 000000000..12bd39978 --- /dev/null +++ b/api/codeflare/v1alpha1/register.go @@ -0,0 +1,51 @@ +/* +Copyright 2023. + +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" +) + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind. +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource. +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeGroupVersion = schema.GroupVersion{Group: "codeflare.codeflare.dev", Version: "v1alpha1"} + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &MCAD{}, + &MCADList{}, + &InstaScale{}, + &InstaScaleList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/codeflare/v1alpha1/zz_generated.deepcopy.go similarity index 99% rename from api/v1alpha1/zz_generated.deepcopy.go rename to api/codeflare/v1alpha1/zz_generated.deepcopy.go index 8a7f57135..5f0dd24ab 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/codeflare/v1alpha1/zz_generated.deepcopy.go @@ -23,7 +23,7 @@ package v1alpha1 import ( "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/client/applyconfiguration/codeflare/v1alpha1/instascale.go b/client/applyconfiguration/codeflare/v1alpha1/instascale.go new file mode 100644 index 000000000..3cb4c8c67 --- /dev/null +++ b/client/applyconfiguration/codeflare/v1alpha1/instascale.go @@ -0,0 +1,219 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// InstaScaleApplyConfiguration represents an declarative configuration of the InstaScale type for use +// with apply. +type InstaScaleApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *InstaScaleSpecApplyConfiguration `json:"spec,omitempty"` + Status *InstaScaleStatusApplyConfiguration `json:"status,omitempty"` +} + +// InstaScale constructs an declarative configuration of the InstaScale type for use with +// apply. +func InstaScale(name, namespace string) *InstaScaleApplyConfiguration { + b := &InstaScaleApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("InstaScale") + b.WithAPIVersion("codeflare.codeflare.dev/v1alpha1") + 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 *InstaScaleApplyConfiguration) WithKind(value string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithAPIVersion(value string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithName(value string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithGenerateName(value string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithNamespace(value string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithUID(value types.UID) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithResourceVersion(value string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithGeneration(value int64) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithCreationTimestamp(value metav1.Time) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithLabels(entries map[string]string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithAnnotations(entries map[string]string) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithFinalizers(values ...string) *InstaScaleApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *InstaScaleApplyConfiguration) 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 *InstaScaleApplyConfiguration) WithSpec(value *InstaScaleSpecApplyConfiguration) *InstaScaleApplyConfiguration { + 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 *InstaScaleApplyConfiguration) WithStatus(value *InstaScaleStatusApplyConfiguration) *InstaScaleApplyConfiguration { + b.Status = value + return b +} diff --git a/client/applyconfiguration/codeflare/v1alpha1/instascalespec.go b/client/applyconfiguration/codeflare/v1alpha1/instascalespec.go new file mode 100644 index 000000000..e6ed5abd7 --- /dev/null +++ b/client/applyconfiguration/codeflare/v1alpha1/instascalespec.go @@ -0,0 +1,79 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// InstaScaleSpecApplyConfiguration represents an declarative configuration of the InstaScaleSpec type for use +// with apply. +type InstaScaleSpecApplyConfiguration struct { + EnableMonitoring *bool `json:"enableMonitoring,omitempty"` + MaxScaleoutAllowed *int `json:"maxScaleoutAllowed,omitempty"` + UseMachinePools *bool `json:"useMachinePools,omitempty"` + ControllerResources *v1.ResourceRequirements `json:"controllerResources,omitempty"` + ControllerImage *string `json:"controllerImage,omitempty"` +} + +// InstaScaleSpecApplyConfiguration constructs an declarative configuration of the InstaScaleSpec type for use with +// apply. +func InstaScaleSpec() *InstaScaleSpecApplyConfiguration { + return &InstaScaleSpecApplyConfiguration{} +} + +// WithEnableMonitoring sets the EnableMonitoring 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 EnableMonitoring field is set to the value of the last call. +func (b *InstaScaleSpecApplyConfiguration) WithEnableMonitoring(value bool) *InstaScaleSpecApplyConfiguration { + b.EnableMonitoring = &value + return b +} + +// WithMaxScaleoutAllowed sets the MaxScaleoutAllowed 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 MaxScaleoutAllowed field is set to the value of the last call. +func (b *InstaScaleSpecApplyConfiguration) WithMaxScaleoutAllowed(value int) *InstaScaleSpecApplyConfiguration { + b.MaxScaleoutAllowed = &value + return b +} + +// WithUseMachinePools sets the UseMachinePools 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 UseMachinePools field is set to the value of the last call. +func (b *InstaScaleSpecApplyConfiguration) WithUseMachinePools(value bool) *InstaScaleSpecApplyConfiguration { + b.UseMachinePools = &value + return b +} + +// WithControllerResources sets the ControllerResources 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 ControllerResources field is set to the value of the last call. +func (b *InstaScaleSpecApplyConfiguration) WithControllerResources(value v1.ResourceRequirements) *InstaScaleSpecApplyConfiguration { + b.ControllerResources = &value + return b +} + +// WithControllerImage sets the ControllerImage 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 ControllerImage field is set to the value of the last call. +func (b *InstaScaleSpecApplyConfiguration) WithControllerImage(value string) *InstaScaleSpecApplyConfiguration { + b.ControllerImage = &value + return b +} diff --git a/client/applyconfiguration/codeflare/v1alpha1/instascalestatus.go b/client/applyconfiguration/codeflare/v1alpha1/instascalestatus.go new file mode 100644 index 000000000..9643218f1 --- /dev/null +++ b/client/applyconfiguration/codeflare/v1alpha1/instascalestatus.go @@ -0,0 +1,39 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package v1alpha1 + +// InstaScaleStatusApplyConfiguration represents an declarative configuration of the InstaScaleStatus type for use +// with apply. +type InstaScaleStatusApplyConfiguration struct { + Ready *bool `json:"ready,omitempty"` +} + +// InstaScaleStatusApplyConfiguration constructs an declarative configuration of the InstaScaleStatus type for use with +// apply. +func InstaScaleStatus() *InstaScaleStatusApplyConfiguration { + return &InstaScaleStatusApplyConfiguration{} +} + +// WithReady sets the Ready 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 Ready field is set to the value of the last call. +func (b *InstaScaleStatusApplyConfiguration) WithReady(value bool) *InstaScaleStatusApplyConfiguration { + b.Ready = &value + return b +} diff --git a/client/applyconfiguration/codeflare/v1alpha1/mcad.go b/client/applyconfiguration/codeflare/v1alpha1/mcad.go new file mode 100644 index 000000000..0b7a441b1 --- /dev/null +++ b/client/applyconfiguration/codeflare/v1alpha1/mcad.go @@ -0,0 +1,219 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MCADApplyConfiguration represents an declarative configuration of the MCAD type for use +// with apply. +type MCADApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *MCADSpecApplyConfiguration `json:"spec,omitempty"` + Status *MCADStatusApplyConfiguration `json:"status,omitempty"` +} + +// MCAD constructs an declarative configuration of the MCAD type for use with +// apply. +func MCAD(name, namespace string) *MCADApplyConfiguration { + b := &MCADApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("MCAD") + b.WithAPIVersion("codeflare.codeflare.dev/v1alpha1") + 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 *MCADApplyConfiguration) WithKind(value string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithAPIVersion(value string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithName(value string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithGenerateName(value string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithNamespace(value string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithUID(value types.UID) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithResourceVersion(value string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithGeneration(value int64) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithCreationTimestamp(value metav1.Time) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithLabels(entries map[string]string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithAnnotations(entries map[string]string) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithFinalizers(values ...string) *MCADApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *MCADApplyConfiguration) 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 *MCADApplyConfiguration) WithSpec(value *MCADSpecApplyConfiguration) *MCADApplyConfiguration { + 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 *MCADApplyConfiguration) WithStatus(value *MCADStatusApplyConfiguration) *MCADApplyConfiguration { + b.Status = value + return b +} diff --git a/client/applyconfiguration/codeflare/v1alpha1/mcadspec.go b/client/applyconfiguration/codeflare/v1alpha1/mcadspec.go new file mode 100644 index 000000000..c7cb170a5 --- /dev/null +++ b/client/applyconfiguration/codeflare/v1alpha1/mcadspec.go @@ -0,0 +1,106 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// MCADSpecApplyConfiguration represents an declarative configuration of the MCADSpec type for use +// with apply. +type MCADSpecApplyConfiguration struct { + EnableMonitoring *bool `json:"enableMonitoring,omitempty"` + MultiCluster *bool `json:"multiCluster,omitempty"` + DispatcherMode *bool `json:"dispatcherMode,omitempty"` + PreemptionEnabled *bool `json:"preemptionEnabled,omitempty"` + AgentConfigs *string `json:"agentConfigs,omitempty"` + QuotaRestURL *string `json:"quotaRestURL,omitempty"` + PodCreationTimeout *int `json:"podCreationTimeout,omitempty"` + ControllerResources *v1.ResourceRequirements `json:"controllerResources,omitempty"` +} + +// MCADSpecApplyConfiguration constructs an declarative configuration of the MCADSpec type for use with +// apply. +func MCADSpec() *MCADSpecApplyConfiguration { + return &MCADSpecApplyConfiguration{} +} + +// WithEnableMonitoring sets the EnableMonitoring 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 EnableMonitoring field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithEnableMonitoring(value bool) *MCADSpecApplyConfiguration { + b.EnableMonitoring = &value + return b +} + +// WithMultiCluster sets the MultiCluster 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 MultiCluster field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithMultiCluster(value bool) *MCADSpecApplyConfiguration { + b.MultiCluster = &value + return b +} + +// WithDispatcherMode sets the DispatcherMode 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 DispatcherMode field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithDispatcherMode(value bool) *MCADSpecApplyConfiguration { + b.DispatcherMode = &value + return b +} + +// WithPreemptionEnabled sets the PreemptionEnabled 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 PreemptionEnabled field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithPreemptionEnabled(value bool) *MCADSpecApplyConfiguration { + b.PreemptionEnabled = &value + return b +} + +// WithAgentConfigs sets the AgentConfigs 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 AgentConfigs field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithAgentConfigs(value string) *MCADSpecApplyConfiguration { + b.AgentConfigs = &value + return b +} + +// WithQuotaRestURL sets the QuotaRestURL 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 QuotaRestURL field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithQuotaRestURL(value string) *MCADSpecApplyConfiguration { + b.QuotaRestURL = &value + return b +} + +// WithPodCreationTimeout sets the PodCreationTimeout 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 PodCreationTimeout field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithPodCreationTimeout(value int) *MCADSpecApplyConfiguration { + b.PodCreationTimeout = &value + return b +} + +// WithControllerResources sets the ControllerResources 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 ControllerResources field is set to the value of the last call. +func (b *MCADSpecApplyConfiguration) WithControllerResources(value v1.ResourceRequirements) *MCADSpecApplyConfiguration { + b.ControllerResources = &value + return b +} diff --git a/client/applyconfiguration/codeflare/v1alpha1/mcadstatus.go b/client/applyconfiguration/codeflare/v1alpha1/mcadstatus.go new file mode 100644 index 000000000..0b93b070a --- /dev/null +++ b/client/applyconfiguration/codeflare/v1alpha1/mcadstatus.go @@ -0,0 +1,39 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package v1alpha1 + +// MCADStatusApplyConfiguration represents an declarative configuration of the MCADStatus type for use +// with apply. +type MCADStatusApplyConfiguration struct { + Ready *bool `json:"ready,omitempty"` +} + +// MCADStatusApplyConfiguration constructs an declarative configuration of the MCADStatus type for use with +// apply. +func MCADStatus() *MCADStatusApplyConfiguration { + return &MCADStatusApplyConfiguration{} +} + +// WithReady sets the Ready 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 Ready field is set to the value of the last call. +func (b *MCADStatusApplyConfiguration) WithReady(value bool) *MCADStatusApplyConfiguration { + b.Ready = &value + return b +} diff --git a/client/applyconfiguration/internal/internal.go b/client/applyconfiguration/internal/internal.go new file mode 100644 index 000000000..e3bfb7d5b --- /dev/null +++ b/client/applyconfiguration/internal/internal.go @@ -0,0 +1,62 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/client/applyconfiguration/utils.go b/client/applyconfiguration/utils.go new file mode 100644 index 000000000..fd87ac36b --- /dev/null +++ b/client/applyconfiguration/utils.go @@ -0,0 +1,47 @@ +/* +Copyright 2023. + +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. DO NOT EDIT. + +package applyconfiguration + +import ( + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/applyconfiguration/codeflare/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=codeflare.codeflare.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("InstaScale"): + return &codeflarev1alpha1.InstaScaleApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstaScaleSpec"): + return &codeflarev1alpha1.InstaScaleSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstaScaleStatus"): + return &codeflarev1alpha1.InstaScaleStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MCAD"): + return &codeflarev1alpha1.MCADApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MCADSpec"): + return &codeflarev1alpha1.MCADSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MCADStatus"): + return &codeflarev1alpha1.MCADStatusApplyConfiguration{} + + } + return nil +} diff --git a/client/clientset/versioned/clientset.go b/client/clientset/versioned/clientset.go new file mode 100644 index 000000000..1d91a6641 --- /dev/null +++ b/client/clientset/versioned/clientset.go @@ -0,0 +1,120 @@ +/* +Copyright 2023. + +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 versioned + +import ( + "fmt" + "net/http" + + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/clientset/versioned/typed/codeflare/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + CodeflareV1alpha1() codeflarev1alpha1.CodeflareV1alpha1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + codeflareV1alpha1 *codeflarev1alpha1.CodeflareV1alpha1Client +} + +// CodeflareV1alpha1 retrieves the CodeflareV1alpha1Client +func (c *Clientset) CodeflareV1alpha1() codeflarev1alpha1.CodeflareV1alpha1Interface { + return c.codeflareV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.codeflareV1alpha1, err = codeflarev1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.codeflareV1alpha1 = codeflarev1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/client/clientset/versioned/fake/clientset_generated.go b/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 000000000..fbbb80dc3 --- /dev/null +++ b/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,85 @@ +/* +Copyright 2023. + +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 ( + clientset "github.com/project-codeflare/codeflare-operator/client/clientset/versioned" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/clientset/versioned/typed/codeflare/v1alpha1" + fakecodeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/clientset/versioned/typed/codeflare/v1alpha1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// 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 +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// CodeflareV1alpha1 retrieves the CodeflareV1alpha1Client +func (c *Clientset) CodeflareV1alpha1() codeflarev1alpha1.CodeflareV1alpha1Interface { + return &fakecodeflarev1alpha1.FakeCodeflareV1alpha1{Fake: &c.Fake} +} diff --git a/client/clientset/versioned/fake/doc.go b/client/clientset/versioned/fake/doc.go new file mode 100644 index 000000000..86aee2a9e --- /dev/null +++ b/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2023. + +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. + +// This package has the automatically generated fake clientset. +package fake diff --git a/client/clientset/versioned/fake/register.go b/client/clientset/versioned/fake/register.go new file mode 100644 index 000000000..4ff1cb3a3 --- /dev/null +++ b/client/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2023. + +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 ( + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/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 localSchemeBuilder = runtime.SchemeBuilder{ + codeflarev1alpha1.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"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/client/clientset/versioned/scheme/doc.go b/client/clientset/versioned/scheme/doc.go new file mode 100644 index 000000000..5f6297fd6 --- /dev/null +++ b/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2023. + +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. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/client/clientset/versioned/scheme/register.go b/client/clientset/versioned/scheme/register.go new file mode 100644 index 000000000..743173cea --- /dev/null +++ b/client/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2023. + +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 scheme + +import ( + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/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{ + codeflarev1alpha1.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"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/codeflare_client.go b/client/clientset/versioned/typed/codeflare/v1alpha1/codeflare_client.go new file mode 100644 index 000000000..4b93fe6fe --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/codeflare_client.go @@ -0,0 +1,112 @@ +/* +Copyright 2023. + +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 ( + "net/http" + + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + "github.com/project-codeflare/codeflare-operator/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type CodeflareV1alpha1Interface interface { + RESTClient() rest.Interface + InstaScalesGetter + MCADsGetter +} + +// CodeflareV1alpha1Client is used to interact with features provided by the codeflare.codeflare.dev group. +type CodeflareV1alpha1Client struct { + restClient rest.Interface +} + +func (c *CodeflareV1alpha1Client) InstaScales(namespace string) InstaScaleInterface { + return newInstaScales(c, namespace) +} + +func (c *CodeflareV1alpha1Client) MCADs(namespace string) MCADInterface { + return newMCADs(c, namespace) +} + +// NewForConfig creates a new CodeflareV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*CodeflareV1alpha1Client, 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 CodeflareV1alpha1Client 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) (*CodeflareV1alpha1Client, 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 &CodeflareV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new CodeflareV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *CodeflareV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new CodeflareV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *CodeflareV1alpha1Client { + return &CodeflareV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.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 *CodeflareV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/doc.go b/client/clientset/versioned/typed/codeflare/v1alpha1/doc.go new file mode 100644 index 000000000..cf7c15204 --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2023. + +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. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/fake/doc.go b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/doc.go new file mode 100644 index 000000000..7c26ebe20 --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2023. + +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 has the automatically generated clients. +package fake diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_codeflare_client.go b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_codeflare_client.go new file mode 100644 index 000000000..9e234aca7 --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_codeflare_client.go @@ -0,0 +1,44 @@ +/* +Copyright 2023. + +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/project-codeflare/codeflare-operator/client/clientset/versioned/typed/codeflare/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeCodeflareV1alpha1 struct { + *testing.Fake +} + +func (c *FakeCodeflareV1alpha1) InstaScales(namespace string) v1alpha1.InstaScaleInterface { + return &FakeInstaScales{c, namespace} +} + +func (c *FakeCodeflareV1alpha1) MCADs(namespace string) v1alpha1.MCADInterface { + return &FakeMCADs{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeCodeflareV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_instascale.go b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_instascale.go new file mode 100644 index 000000000..8abbdc792 --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_instascale.go @@ -0,0 +1,189 @@ +/* +Copyright 2023. + +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" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/applyconfiguration/codeflare/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" +) + +// FakeInstaScales implements InstaScaleInterface +type FakeInstaScales struct { + Fake *FakeCodeflareV1alpha1 + ns string +} + +var instascalesResource = v1alpha1.SchemeGroupVersion.WithResource("instascales") + +var instascalesKind = v1alpha1.SchemeGroupVersion.WithKind("InstaScale") + +// Get takes name of the instaScale, and returns the corresponding instaScale object, and an error if there is any. +func (c *FakeInstaScales) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.InstaScale, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(instascalesResource, c.ns, name), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), err +} + +// List takes label and field selectors, and returns the list of InstaScales that match those selectors. +func (c *FakeInstaScales) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.InstaScaleList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(instascalesResource, instascalesKind, c.ns, opts), &v1alpha1.InstaScaleList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.InstaScaleList{ListMeta: obj.(*v1alpha1.InstaScaleList).ListMeta} + for _, item := range obj.(*v1alpha1.InstaScaleList).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 instaScales. +func (c *FakeInstaScales) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(instascalesResource, c.ns, opts)) + +} + +// Create takes the representation of a instaScale and creates it. Returns the server's representation of the instaScale, and an error, if there is any. +func (c *FakeInstaScales) Create(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.CreateOptions) (result *v1alpha1.InstaScale, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(instascalesResource, c.ns, instaScale), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), err +} + +// Update takes the representation of a instaScale and updates it. Returns the server's representation of the instaScale, and an error, if there is any. +func (c *FakeInstaScales) Update(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.UpdateOptions) (result *v1alpha1.InstaScale, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(instascalesResource, c.ns, instaScale), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), 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 *FakeInstaScales) UpdateStatus(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.UpdateOptions) (*v1alpha1.InstaScale, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(instascalesResource, "status", c.ns, instaScale), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), err +} + +// Delete takes name of the instaScale and deletes it. Returns an error if one occurs. +func (c *FakeInstaScales) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(instascalesResource, c.ns, name, opts), &v1alpha1.InstaScale{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeInstaScales) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(instascalesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.InstaScaleList{}) + return err +} + +// Patch applies the patch and returns the patched instaScale. +func (c *FakeInstaScales) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.InstaScale, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(instascalesResource, c.ns, name, pt, data, subresources...), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied instaScale. +func (c *FakeInstaScales) Apply(ctx context.Context, instaScale *codeflarev1alpha1.InstaScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.InstaScale, err error) { + if instaScale == nil { + return nil, fmt.Errorf("instaScale provided to Apply must not be nil") + } + data, err := json.Marshal(instaScale) + if err != nil { + return nil, err + } + name := instaScale.Name + if name == nil { + return nil, fmt.Errorf("instaScale.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(instascalesResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), 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 *FakeInstaScales) ApplyStatus(ctx context.Context, instaScale *codeflarev1alpha1.InstaScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.InstaScale, err error) { + if instaScale == nil { + return nil, fmt.Errorf("instaScale provided to Apply must not be nil") + } + data, err := json.Marshal(instaScale) + if err != nil { + return nil, err + } + name := instaScale.Name + if name == nil { + return nil, fmt.Errorf("instaScale.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(instascalesResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.InstaScale{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.InstaScale), err +} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_mcad.go b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_mcad.go new file mode 100644 index 000000000..027f2817d --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/fake/fake_mcad.go @@ -0,0 +1,189 @@ +/* +Copyright 2023. + +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" + json "encoding/json" + "fmt" + + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/applyconfiguration/codeflare/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" +) + +// FakeMCADs implements MCADInterface +type FakeMCADs struct { + Fake *FakeCodeflareV1alpha1 + ns string +} + +var mcadsResource = v1alpha1.SchemeGroupVersion.WithResource("mcads") + +var mcadsKind = v1alpha1.SchemeGroupVersion.WithKind("MCAD") + +// Get takes name of the mCAD, and returns the corresponding mCAD object, and an error if there is any. +func (c *FakeMCADs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.MCAD, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(mcadsResource, c.ns, name), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), err +} + +// List takes label and field selectors, and returns the list of MCADs that match those selectors. +func (c *FakeMCADs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.MCADList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(mcadsResource, mcadsKind, c.ns, opts), &v1alpha1.MCADList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.MCADList{ListMeta: obj.(*v1alpha1.MCADList).ListMeta} + for _, item := range obj.(*v1alpha1.MCADList).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 mCADs. +func (c *FakeMCADs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(mcadsResource, c.ns, opts)) + +} + +// Create takes the representation of a mCAD and creates it. Returns the server's representation of the mCAD, and an error, if there is any. +func (c *FakeMCADs) Create(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.CreateOptions) (result *v1alpha1.MCAD, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(mcadsResource, c.ns, mCAD), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), err +} + +// Update takes the representation of a mCAD and updates it. Returns the server's representation of the mCAD, and an error, if there is any. +func (c *FakeMCADs) Update(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.UpdateOptions) (result *v1alpha1.MCAD, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(mcadsResource, c.ns, mCAD), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), 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 *FakeMCADs) UpdateStatus(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.UpdateOptions) (*v1alpha1.MCAD, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(mcadsResource, "status", c.ns, mCAD), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), err +} + +// Delete takes name of the mCAD and deletes it. Returns an error if one occurs. +func (c *FakeMCADs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(mcadsResource, c.ns, name, opts), &v1alpha1.MCAD{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMCADs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(mcadsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.MCADList{}) + return err +} + +// Patch applies the patch and returns the patched mCAD. +func (c *FakeMCADs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.MCAD, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(mcadsResource, c.ns, name, pt, data, subresources...), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied mCAD. +func (c *FakeMCADs) Apply(ctx context.Context, mCAD *codeflarev1alpha1.MCADApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.MCAD, err error) { + if mCAD == nil { + return nil, fmt.Errorf("mCAD provided to Apply must not be nil") + } + data, err := json.Marshal(mCAD) + if err != nil { + return nil, err + } + name := mCAD.Name + if name == nil { + return nil, fmt.Errorf("mCAD.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(mcadsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), 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 *FakeMCADs) ApplyStatus(ctx context.Context, mCAD *codeflarev1alpha1.MCADApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.MCAD, err error) { + if mCAD == nil { + return nil, fmt.Errorf("mCAD provided to Apply must not be nil") + } + data, err := json.Marshal(mCAD) + if err != nil { + return nil, err + } + name := mCAD.Name + if name == nil { + return nil, fmt.Errorf("mCAD.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(mcadsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.MCAD{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MCAD), err +} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/generated_expansion.go b/client/clientset/versioned/typed/codeflare/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..4727cc4df --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2023. + +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 + +type InstaScaleExpansion interface{} + +type MCADExpansion interface{} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/instascale.go b/client/clientset/versioned/typed/codeflare/v1alpha1/instascale.go new file mode 100644 index 000000000..c146a98d2 --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/instascale.go @@ -0,0 +1,256 @@ +/* +Copyright 2023. + +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" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/applyconfiguration/codeflare/v1alpha1" + scheme "github.com/project-codeflare/codeflare-operator/client/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" +) + +// InstaScalesGetter has a method to return a InstaScaleInterface. +// A group's client should implement this interface. +type InstaScalesGetter interface { + InstaScales(namespace string) InstaScaleInterface +} + +// InstaScaleInterface has methods to work with InstaScale resources. +type InstaScaleInterface interface { + Create(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.CreateOptions) (*v1alpha1.InstaScale, error) + Update(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.UpdateOptions) (*v1alpha1.InstaScale, error) + UpdateStatus(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.UpdateOptions) (*v1alpha1.InstaScale, 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.InstaScale, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.InstaScaleList, 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.InstaScale, err error) + Apply(ctx context.Context, instaScale *codeflarev1alpha1.InstaScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.InstaScale, err error) + ApplyStatus(ctx context.Context, instaScale *codeflarev1alpha1.InstaScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.InstaScale, err error) + InstaScaleExpansion +} + +// instaScales implements InstaScaleInterface +type instaScales struct { + client rest.Interface + ns string +} + +// newInstaScales returns a InstaScales +func newInstaScales(c *CodeflareV1alpha1Client, namespace string) *instaScales { + return &instaScales{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the instaScale, and returns the corresponding instaScale object, and an error if there is any. +func (c *instaScales) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.InstaScale, err error) { + result = &v1alpha1.InstaScale{} + err = c.client.Get(). + Namespace(c.ns). + Resource("instascales"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of InstaScales that match those selectors. +func (c *instaScales) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.InstaScaleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.InstaScaleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("instascales"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested instaScales. +func (c *instaScales) 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("instascales"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a instaScale and creates it. Returns the server's representation of the instaScale, and an error, if there is any. +func (c *instaScales) Create(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.CreateOptions) (result *v1alpha1.InstaScale, err error) { + result = &v1alpha1.InstaScale{} + err = c.client.Post(). + Namespace(c.ns). + Resource("instascales"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(instaScale). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a instaScale and updates it. Returns the server's representation of the instaScale, and an error, if there is any. +func (c *instaScales) Update(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.UpdateOptions) (result *v1alpha1.InstaScale, err error) { + result = &v1alpha1.InstaScale{} + err = c.client.Put(). + Namespace(c.ns). + Resource("instascales"). + Name(instaScale.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(instaScale). + 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 *instaScales) UpdateStatus(ctx context.Context, instaScale *v1alpha1.InstaScale, opts v1.UpdateOptions) (result *v1alpha1.InstaScale, err error) { + result = &v1alpha1.InstaScale{} + err = c.client.Put(). + Namespace(c.ns). + Resource("instascales"). + Name(instaScale.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(instaScale). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the instaScale and deletes it. Returns an error if one occurs. +func (c *instaScales) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("instascales"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *instaScales) 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("instascales"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched instaScale. +func (c *instaScales) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.InstaScale, err error) { + result = &v1alpha1.InstaScale{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("instascales"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied instaScale. +func (c *instaScales) Apply(ctx context.Context, instaScale *codeflarev1alpha1.InstaScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.InstaScale, err error) { + if instaScale == nil { + return nil, fmt.Errorf("instaScale provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(instaScale) + if err != nil { + return nil, err + } + name := instaScale.Name + if name == nil { + return nil, fmt.Errorf("instaScale.Name must be provided to Apply") + } + result = &v1alpha1.InstaScale{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("instascales"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *instaScales) ApplyStatus(ctx context.Context, instaScale *codeflarev1alpha1.InstaScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.InstaScale, err error) { + if instaScale == nil { + return nil, fmt.Errorf("instaScale provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(instaScale) + if err != nil { + return nil, err + } + + name := instaScale.Name + if name == nil { + return nil, fmt.Errorf("instaScale.Name must be provided to Apply") + } + + result = &v1alpha1.InstaScale{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("instascales"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/clientset/versioned/typed/codeflare/v1alpha1/mcad.go b/client/clientset/versioned/typed/codeflare/v1alpha1/mcad.go new file mode 100644 index 000000000..7d70e4035 --- /dev/null +++ b/client/clientset/versioned/typed/codeflare/v1alpha1/mcad.go @@ -0,0 +1,256 @@ +/* +Copyright 2023. + +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" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/client/applyconfiguration/codeflare/v1alpha1" + scheme "github.com/project-codeflare/codeflare-operator/client/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" +) + +// MCADsGetter has a method to return a MCADInterface. +// A group's client should implement this interface. +type MCADsGetter interface { + MCADs(namespace string) MCADInterface +} + +// MCADInterface has methods to work with MCAD resources. +type MCADInterface interface { + Create(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.CreateOptions) (*v1alpha1.MCAD, error) + Update(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.UpdateOptions) (*v1alpha1.MCAD, error) + UpdateStatus(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.UpdateOptions) (*v1alpha1.MCAD, 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.MCAD, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.MCADList, 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.MCAD, err error) + Apply(ctx context.Context, mCAD *codeflarev1alpha1.MCADApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.MCAD, err error) + ApplyStatus(ctx context.Context, mCAD *codeflarev1alpha1.MCADApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.MCAD, err error) + MCADExpansion +} + +// mCADs implements MCADInterface +type mCADs struct { + client rest.Interface + ns string +} + +// newMCADs returns a MCADs +func newMCADs(c *CodeflareV1alpha1Client, namespace string) *mCADs { + return &mCADs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the mCAD, and returns the corresponding mCAD object, and an error if there is any. +func (c *mCADs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.MCAD, err error) { + result = &v1alpha1.MCAD{} + err = c.client.Get(). + Namespace(c.ns). + Resource("mcads"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of MCADs that match those selectors. +func (c *mCADs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.MCADList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.MCADList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("mcads"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested mCADs. +func (c *mCADs) 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("mcads"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a mCAD and creates it. Returns the server's representation of the mCAD, and an error, if there is any. +func (c *mCADs) Create(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.CreateOptions) (result *v1alpha1.MCAD, err error) { + result = &v1alpha1.MCAD{} + err = c.client.Post(). + Namespace(c.ns). + Resource("mcads"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(mCAD). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a mCAD and updates it. Returns the server's representation of the mCAD, and an error, if there is any. +func (c *mCADs) Update(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.UpdateOptions) (result *v1alpha1.MCAD, err error) { + result = &v1alpha1.MCAD{} + err = c.client.Put(). + Namespace(c.ns). + Resource("mcads"). + Name(mCAD.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(mCAD). + 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 *mCADs) UpdateStatus(ctx context.Context, mCAD *v1alpha1.MCAD, opts v1.UpdateOptions) (result *v1alpha1.MCAD, err error) { + result = &v1alpha1.MCAD{} + err = c.client.Put(). + Namespace(c.ns). + Resource("mcads"). + Name(mCAD.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(mCAD). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the mCAD and deletes it. Returns an error if one occurs. +func (c *mCADs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("mcads"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *mCADs) 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("mcads"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched mCAD. +func (c *mCADs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.MCAD, err error) { + result = &v1alpha1.MCAD{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("mcads"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied mCAD. +func (c *mCADs) Apply(ctx context.Context, mCAD *codeflarev1alpha1.MCADApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.MCAD, err error) { + if mCAD == nil { + return nil, fmt.Errorf("mCAD provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(mCAD) + if err != nil { + return nil, err + } + name := mCAD.Name + if name == nil { + return nil, fmt.Errorf("mCAD.Name must be provided to Apply") + } + result = &v1alpha1.MCAD{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("mcads"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *mCADs) ApplyStatus(ctx context.Context, mCAD *codeflarev1alpha1.MCADApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.MCAD, err error) { + if mCAD == nil { + return nil, fmt.Errorf("mCAD provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(mCAD) + if err != nil { + return nil, err + } + + name := mCAD.Name + if name == nil { + return nil, fmt.Errorf("mCAD.Name must be provided to Apply") + } + + result = &v1alpha1.MCAD{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("mcads"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/informer/externalversions/codeflare/interface.go b/client/informer/externalversions/codeflare/interface.go new file mode 100644 index 000000000..63ab10ffc --- /dev/null +++ b/client/informer/externalversions/codeflare/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2023. + +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 codeflare + +import ( + v1alpha1 "github.com/project-codeflare/codeflare-operator/client/informer/externalversions/codeflare/v1alpha1" + internalinterfaces "github.com/project-codeflare/codeflare-operator/client/informer/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/client/informer/externalversions/codeflare/v1alpha1/instascale.go b/client/informer/externalversions/codeflare/v1alpha1/instascale.go new file mode 100644 index 000000000..70346e653 --- /dev/null +++ b/client/informer/externalversions/codeflare/v1alpha1/instascale.go @@ -0,0 +1,90 @@ +/* +Copyright 2023. + +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" + time "time" + + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + versioned "github.com/project-codeflare/codeflare-operator/client/clientset/versioned" + internalinterfaces "github.com/project-codeflare/codeflare-operator/client/informer/externalversions/internalinterfaces" + v1alpha1 "github.com/project-codeflare/codeflare-operator/client/listers/codeflare/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" +) + +// InstaScaleInformer provides access to a shared informer and lister for +// InstaScales. +type InstaScaleInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.InstaScaleLister +} + +type instaScaleInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewInstaScaleInformer constructs a new informer for InstaScale 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 NewInstaScaleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredInstaScaleInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredInstaScaleInformer constructs a new informer for InstaScale 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 NewFilteredInstaScaleInformer(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.CodeflareV1alpha1().InstaScales(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CodeflareV1alpha1().InstaScales(namespace).Watch(context.TODO(), options) + }, + }, + &codeflarev1alpha1.InstaScale{}, + resyncPeriod, + indexers, + ) +} + +func (f *instaScaleInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredInstaScaleInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *instaScaleInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&codeflarev1alpha1.InstaScale{}, f.defaultInformer) +} + +func (f *instaScaleInformer) Lister() v1alpha1.InstaScaleLister { + return v1alpha1.NewInstaScaleLister(f.Informer().GetIndexer()) +} diff --git a/client/informer/externalversions/codeflare/v1alpha1/interface.go b/client/informer/externalversions/codeflare/v1alpha1/interface.go new file mode 100644 index 000000000..6003a7031 --- /dev/null +++ b/client/informer/externalversions/codeflare/v1alpha1/interface.go @@ -0,0 +1,52 @@ +/* +Copyright 2023. + +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/project-codeflare/codeflare-operator/client/informer/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // InstaScales returns a InstaScaleInformer. + InstaScales() InstaScaleInformer + // MCADs returns a MCADInformer. + MCADs() MCADInformer +} + +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} +} + +// InstaScales returns a InstaScaleInformer. +func (v *version) InstaScales() InstaScaleInformer { + return &instaScaleInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// MCADs returns a MCADInformer. +func (v *version) MCADs() MCADInformer { + return &mCADInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/client/informer/externalversions/codeflare/v1alpha1/mcad.go b/client/informer/externalversions/codeflare/v1alpha1/mcad.go new file mode 100644 index 000000000..2fe4d5a30 --- /dev/null +++ b/client/informer/externalversions/codeflare/v1alpha1/mcad.go @@ -0,0 +1,90 @@ +/* +Copyright 2023. + +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" + time "time" + + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + versioned "github.com/project-codeflare/codeflare-operator/client/clientset/versioned" + internalinterfaces "github.com/project-codeflare/codeflare-operator/client/informer/externalversions/internalinterfaces" + v1alpha1 "github.com/project-codeflare/codeflare-operator/client/listers/codeflare/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" +) + +// MCADInformer provides access to a shared informer and lister for +// MCADs. +type MCADInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.MCADLister +} + +type mCADInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMCADInformer constructs a new informer for MCAD 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 NewMCADInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMCADInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMCADInformer constructs a new informer for MCAD 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 NewFilteredMCADInformer(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.CodeflareV1alpha1().MCADs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CodeflareV1alpha1().MCADs(namespace).Watch(context.TODO(), options) + }, + }, + &codeflarev1alpha1.MCAD{}, + resyncPeriod, + indexers, + ) +} + +func (f *mCADInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMCADInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *mCADInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&codeflarev1alpha1.MCAD{}, f.defaultInformer) +} + +func (f *mCADInformer) Lister() v1alpha1.MCADLister { + return v1alpha1.NewMCADLister(f.Informer().GetIndexer()) +} diff --git a/client/informer/externalversions/factory.go b/client/informer/externalversions/factory.go new file mode 100644 index 000000000..e1f7f14a1 --- /dev/null +++ b/client/informer/externalversions/factory.go @@ -0,0 +1,251 @@ +/* +Copyright 2023. + +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/project-codeflare/codeflare-operator/client/clientset/versioned" + codeflare "github.com/project-codeflare/codeflare-operator/client/informer/externalversions/codeflare" + internalinterfaces "github.com/project-codeflare/codeflare-operator/client/informer/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 + + 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 + } +} + +// 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 +} + +// InternalInformerFor 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) + 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. + 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) + + // InternalInformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Codeflare() codeflare.Interface +} + +func (f *sharedInformerFactory) Codeflare() codeflare.Interface { + return codeflare.New(f, f.namespace, f.tweakListOptions) +} diff --git a/client/informer/externalversions/generic.go b/client/informer/externalversions/generic.go new file mode 100644 index 000000000..9eea54ebf --- /dev/null +++ b/client/informer/externalversions/generic.go @@ -0,0 +1,64 @@ +/* +Copyright 2023. + +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" + + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/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=codeflare.codeflare.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("instascales"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Codeflare().V1alpha1().InstaScales().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("mcads"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Codeflare().V1alpha1().MCADs().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/client/informer/externalversions/internalinterfaces/factory_interfaces.go b/client/informer/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 000000000..b380f668c --- /dev/null +++ b/client/informer/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2023. + +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/project-codeflare/codeflare-operator/client/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/client/listers/codeflare/v1alpha1/expansion_generated.go b/client/listers/codeflare/v1alpha1/expansion_generated.go new file mode 100644 index 000000000..23082ab9d --- /dev/null +++ b/client/listers/codeflare/v1alpha1/expansion_generated.go @@ -0,0 +1,35 @@ +/* +Copyright 2023. + +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 + +// InstaScaleListerExpansion allows custom methods to be added to +// InstaScaleLister. +type InstaScaleListerExpansion interface{} + +// InstaScaleNamespaceListerExpansion allows custom methods to be added to +// InstaScaleNamespaceLister. +type InstaScaleNamespaceListerExpansion interface{} + +// MCADListerExpansion allows custom methods to be added to +// MCADLister. +type MCADListerExpansion interface{} + +// MCADNamespaceListerExpansion allows custom methods to be added to +// MCADNamespaceLister. +type MCADNamespaceListerExpansion interface{} diff --git a/client/listers/codeflare/v1alpha1/instascale.go b/client/listers/codeflare/v1alpha1/instascale.go new file mode 100644 index 000000000..ee5c22847 --- /dev/null +++ b/client/listers/codeflare/v1alpha1/instascale.go @@ -0,0 +1,99 @@ +/* +Copyright 2023. + +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 ( + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// InstaScaleLister helps list InstaScales. +// All objects returned here must be treated as read-only. +type InstaScaleLister interface { + // List lists all InstaScales in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.InstaScale, err error) + // InstaScales returns an object that can list and get InstaScales. + InstaScales(namespace string) InstaScaleNamespaceLister + InstaScaleListerExpansion +} + +// instaScaleLister implements the InstaScaleLister interface. +type instaScaleLister struct { + indexer cache.Indexer +} + +// NewInstaScaleLister returns a new InstaScaleLister. +func NewInstaScaleLister(indexer cache.Indexer) InstaScaleLister { + return &instaScaleLister{indexer: indexer} +} + +// List lists all InstaScales in the indexer. +func (s *instaScaleLister) List(selector labels.Selector) (ret []*v1alpha1.InstaScale, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.InstaScale)) + }) + return ret, err +} + +// InstaScales returns an object that can list and get InstaScales. +func (s *instaScaleLister) InstaScales(namespace string) InstaScaleNamespaceLister { + return instaScaleNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// InstaScaleNamespaceLister helps list and get InstaScales. +// All objects returned here must be treated as read-only. +type InstaScaleNamespaceLister interface { + // List lists all InstaScales in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.InstaScale, err error) + // Get retrieves the InstaScale from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.InstaScale, error) + InstaScaleNamespaceListerExpansion +} + +// instaScaleNamespaceLister implements the InstaScaleNamespaceLister +// interface. +type instaScaleNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all InstaScales in the indexer for a given namespace. +func (s instaScaleNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.InstaScale, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.InstaScale)) + }) + return ret, err +} + +// Get retrieves the InstaScale from the indexer for a given namespace and name. +func (s instaScaleNamespaceLister) Get(name string) (*v1alpha1.InstaScale, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("instascale"), name) + } + return obj.(*v1alpha1.InstaScale), nil +} diff --git a/client/listers/codeflare/v1alpha1/mcad.go b/client/listers/codeflare/v1alpha1/mcad.go new file mode 100644 index 000000000..8ac44bfce --- /dev/null +++ b/client/listers/codeflare/v1alpha1/mcad.go @@ -0,0 +1,99 @@ +/* +Copyright 2023. + +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 ( + v1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MCADLister helps list MCADs. +// All objects returned here must be treated as read-only. +type MCADLister interface { + // List lists all MCADs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.MCAD, err error) + // MCADs returns an object that can list and get MCADs. + MCADs(namespace string) MCADNamespaceLister + MCADListerExpansion +} + +// mCADLister implements the MCADLister interface. +type mCADLister struct { + indexer cache.Indexer +} + +// NewMCADLister returns a new MCADLister. +func NewMCADLister(indexer cache.Indexer) MCADLister { + return &mCADLister{indexer: indexer} +} + +// List lists all MCADs in the indexer. +func (s *mCADLister) List(selector labels.Selector) (ret []*v1alpha1.MCAD, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.MCAD)) + }) + return ret, err +} + +// MCADs returns an object that can list and get MCADs. +func (s *mCADLister) MCADs(namespace string) MCADNamespaceLister { + return mCADNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MCADNamespaceLister helps list and get MCADs. +// All objects returned here must be treated as read-only. +type MCADNamespaceLister interface { + // List lists all MCADs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.MCAD, err error) + // Get retrieves the MCAD from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.MCAD, error) + MCADNamespaceListerExpansion +} + +// mCADNamespaceLister implements the MCADNamespaceLister +// interface. +type mCADNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MCADs in the indexer for a given namespace. +func (s mCADNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MCAD, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.MCAD)) + }) + return ret, err +} + +// Get retrieves the MCAD from the indexer for a given namespace and name. +func (s mCADNamespaceLister) Get(name string) (*v1alpha1.MCAD, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("mcad"), name) + } + return obj.(*v1alpha1.MCAD), nil +} diff --git a/controllers/instascale.go b/controllers/instascale.go index f4b9c3d3f..3a35e05a9 100644 --- a/controllers/instascale.go +++ b/controllers/instascale.go @@ -1,7 +1,7 @@ package controllers import ( - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" ) var instascaleTemplates = []string{ diff --git a/controllers/instascale_controller.go b/controllers/instascale_controller.go index c9fabdf57..31fcb53b9 100644 --- a/controllers/instascale_controller.go +++ b/controllers/instascale_controller.go @@ -39,7 +39,7 @@ import ( "github.com/go-logr/logr" mf "github.com/manifestival/manifestival" - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" "github.com/project-codeflare/codeflare-operator/controllers/config" "github.com/project-codeflare/codeflare-operator/controllers/util" ) @@ -106,7 +106,7 @@ func (r *InstaScaleReconciler) Reconcile(ctx context.Context, req ctrl.Request) log.V(1).Info("InstaScale reconciler called.") params := &InstaScaleParams{} - instascaleCustomResource := &codeflarev1alpha1.InstaScale{} + instascaleCustomResource := &v1alpha1.InstaScale{} err := r.Get(ctx, req.NamespacedName, instascaleCustomResource) if err != nil && apierrs.IsNotFound(err) { @@ -122,7 +122,7 @@ func (r *InstaScaleReconciler) Reconcile(ctx context.Context, req ctrl.Request) // In production we expect these to be populated if instascaleCustomResource.Kind == "" { instascaleCustomResource = instascaleCustomResource.DeepCopy() - gvk := codeflarev1alpha1.GroupVersion.WithKind("InstaScale") + gvk := v1alpha1.SchemeGroupVersion.WithKind("InstaScale") instascaleCustomResource.APIVersion, instascaleCustomResource.Kind = gvk.Version, gvk.Kind } @@ -168,7 +168,7 @@ func (r *InstaScaleReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, nil } -func updateInstascaleReadyStatus(ctx context.Context, r *InstaScaleReconciler, req ctrl.Request, instascaleCustomResource *codeflarev1alpha1.InstaScale) error { +func updateInstascaleReadyStatus(ctx context.Context, r *InstaScaleReconciler, req ctrl.Request, instascaleCustomResource *v1alpha1.InstaScale) error { deployment := &appsv1.Deployment{} err := r.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("instascale-%s", req.Name), Namespace: req.Namespace}, deployment) if err != nil { @@ -198,7 +198,7 @@ func (r *InstaScaleReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil }) return ctrl.NewControllerManagedBy(mgr). - For(&codeflarev1alpha1.InstaScale{}). + For(&v1alpha1.InstaScale{}). Owns(&corev1.ConfigMap{}). Owns(&corev1.ServiceAccount{}). Owns(&authv1.ClusterRole{}). diff --git a/controllers/instascale_controller_test.go b/controllers/instascale_controller_test.go index 7017e681f..4071c515a 100644 --- a/controllers/instascale_controller_test.go +++ b/controllers/instascale_controller_test.go @@ -9,7 +9,7 @@ import ( mfc "github.com/manifestival/controller-runtime-client" mf "github.com/manifestival/manifestival" - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" ) const ( diff --git a/controllers/instascale_params.go b/controllers/instascale_params.go index eb6737c79..0def69351 100644 --- a/controllers/instascale_params.go +++ b/controllers/instascale_params.go @@ -8,7 +8,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - instascalev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + instascalev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" ) type InstaScaleParams struct { diff --git a/controllers/mcad_controller.go b/controllers/mcad_controller.go index 68dc0886c..1dfe8b9b1 100644 --- a/controllers/mcad_controller.go +++ b/controllers/mcad_controller.go @@ -22,22 +22,24 @@ import ( "github.com/go-logr/logr" mf "github.com/manifestival/manifestival" - "github.com/project-codeflare/codeflare-operator/controllers/config" - "github.com/project-codeflare/codeflare-operator/controllers/util" - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + "github.com/project-codeflare/codeflare-operator/controllers/config" + "github.com/project-codeflare/codeflare-operator/controllers/util" ) const finalizerName = "codeflare.codeflare.dev/finalizer" @@ -98,30 +100,30 @@ func (r *MCADReconciler) DeleteResource(params *MCADParams, template string, fns return tmplManifest.Delete() } -//+kubebuilder:rbac:groups=codeflare.codeflare.dev,resources=mcads,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=codeflare.codeflare.dev,resources=mcads/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=codeflare.codeflare.dev,resources=mcads/finalizers,verbs=update -//+kubebuilder:rbac:groups=mcad.ibm.com,resources=queuejobs;schedulingspecs;appwrappers;appwrappers/finalizers;appwrappers/status,verbs=get;list;watch;create;update;patch;delete;deletecollection -//+kubebuilder:rbac:groups=core,resources=pods;lists;namespaces,verbs=get;list;watch;create;update;patch;delete;deletecollection -//+kubebuilder:rbac:groups=core,resources=bindings;pods/binding,verbs=create -//+kubebuilder:rbac:groups=core,resources=kube-scheduler,verbs=get;update -//+kubebuilder:rbac:groups=core,resources=endpoints;kube-scheduler,verbs=create;get;update -//+kubebuilder:rbac:groups=core,resources=events,verbs=create;patch;update -//+kubebuilder:rbac:groups=core,resources=pods/status,verbs=patch;update -//+kubebuilder:rbac:groups=core,resources=replicationcontrollers,verbs=get;list;watch -//+kubebuilder:rbac:groups=scheduling.sigs.k8s.io,resources=podgroups,verbs=get;list;watch;create;update;patch;delete;deletecollection -//+kubebuilder:rbac:groups=apps,resources=deployments;replicasets;statefulsets,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=*,resources=deployments;services,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=core,resources=secrets;configmaps;services;serviceaccounts;persistentvolumes;persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=core,resources=persistentvolumes;persistentvolumeclaims,verbs=* -//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles;rolebindings,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings,verbs=get;list;watch;create;update;delete -//+kubebuilder:rbac:groups=custom.metrics.k8s.io,resources=*,verbs=* -//+kubebuilder:rbac:groups=coordination.k8s.io,resources=leases;kube-scheduler,verbs=create;update;get -//+kubebuilder:rbac:groups=events.k8s.io,resources=events;kube-scheduler,verbs=create;update;patch -//+kubebuilder:rbac:groups=extensions,resources=replicasets,verbs=get;list;watch -//+kubebuilder:rbac:groups=policy,resources=poddisruptionbudgets,verbs=get;list;watch -//+kubebuilder:rbac:groups=storage.k8s.io,resources=csidrivers;csinodes;csistoragecapacities,verbs=get;list;watch +// +kubebuilder:rbac:groups=codeflare.codeflare.dev,resources=mcads,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=codeflare.codeflare.dev,resources=mcads/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=codeflare.codeflare.dev,resources=mcads/finalizers,verbs=update +// +kubebuilder:rbac:groups=mcad.ibm.com,resources=queuejobs;schedulingspecs;appwrappers;appwrappers/finalizers;appwrappers/status,verbs=get;list;watch;create;update;patch;delete;deletecollection +// +kubebuilder:rbac:groups=core,resources=pods;lists;namespaces,verbs=get;list;watch;create;update;patch;delete;deletecollection +// +kubebuilder:rbac:groups=core,resources=bindings;pods/binding,verbs=create +// +kubebuilder:rbac:groups=core,resources=kube-scheduler,verbs=get;update +// +kubebuilder:rbac:groups=core,resources=endpoints;kube-scheduler,verbs=create;get;update +// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch;update +// +kubebuilder:rbac:groups=core,resources=pods/status,verbs=patch;update +// +kubebuilder:rbac:groups=core,resources=replicationcontrollers,verbs=get;list;watch +// +kubebuilder:rbac:groups=scheduling.sigs.k8s.io,resources=podgroups,verbs=get;list;watch;create;update;patch;delete;deletecollection +// +kubebuilder:rbac:groups=apps,resources=deployments;replicasets;statefulsets,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=*,resources=deployments;services,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=core,resources=secrets;configmaps;services;serviceaccounts;persistentvolumes;persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=core,resources=persistentvolumes;persistentvolumeclaims,verbs=* +// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles;rolebindings,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings,verbs=get;list;watch;create;update;delete +// +kubebuilder:rbac:groups=custom.metrics.k8s.io,resources=*,verbs=* +// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases;kube-scheduler,verbs=create;update;get +// +kubebuilder:rbac:groups=events.k8s.io,resources=events;kube-scheduler,verbs=create;update;patch +// +kubebuilder:rbac:groups=extensions,resources=replicasets,verbs=get;list;watch +// +kubebuilder:rbac:groups=policy,resources=poddisruptionbudgets,verbs=get;list;watch +// +kubebuilder:rbac:groups=storage.k8s.io,resources=csidrivers;csinodes;csistoragecapacities,verbs=get;list;watch func (r *MCADReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := r.Log.WithValues("namespace", req.Namespace) @@ -129,7 +131,7 @@ func (r *MCADReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. log.V(1).Info("MCAD reconciler called.") params := &MCADParams{} - mcadCustomResource := &codeflarev1alpha1.MCAD{} + mcadCustomResource := &v1alpha1.MCAD{} err := r.Get(ctx, req.NamespacedName, mcadCustomResource) if err != nil && apierrs.IsNotFound(err) { @@ -145,7 +147,7 @@ func (r *MCADReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. // In production we expect these to be populated if mcadCustomResource.Kind == "" { mcadCustomResource = mcadCustomResource.DeepCopy() - gvk := codeflarev1alpha1.GroupVersion.WithKind("MCAD") + gvk := v1alpha1.SchemeGroupVersion.WithKind("MCAD") mcadCustomResource.APIVersion, mcadCustomResource.Kind = gvk.Version, gvk.Kind } @@ -195,7 +197,7 @@ func (r *MCADReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. return ctrl.Result{}, nil } -func updateMCADReadyStatus(ctx context.Context, r *MCADReconciler, req ctrl.Request, mcadCustomResource *codeflarev1alpha1.MCAD) error { +func updateMCADReadyStatus(ctx context.Context, r *MCADReconciler, req ctrl.Request, mcadCustomResource *v1alpha1.MCAD) error { deployment := &appsv1.Deployment{} err := r.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("mcad-controller-%s", req.Name), Namespace: req.Namespace}, deployment) if err != nil { @@ -225,7 +227,7 @@ func (r *MCADReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil }) return ctrl.NewControllerManagedBy(mgr). - For(&codeflarev1alpha1.MCAD{}). + For(&v1alpha1.MCAD{}). Owns(&appsv1.Deployment{}). Owns(&corev1.ConfigMap{}). Owns(&corev1.Service{}). diff --git a/controllers/mcad_controller_test.go b/controllers/mcad_controller_test.go index 69247d3f1..ff1189c4c 100644 --- a/controllers/mcad_controller_test.go +++ b/controllers/mcad_controller_test.go @@ -3,11 +3,13 @@ package controllers import ( "context" - mfc "github.com/manifestival/controller-runtime-client" - mf "github.com/manifestival/manifestival" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + + mfc "github.com/manifestival/controller-runtime-client" + mf "github.com/manifestival/manifestival" + + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" ) const ( diff --git a/controllers/mcad_params.go b/controllers/mcad_params.go index ca56523db..cedbdecc7 100644 --- a/controllers/mcad_params.go +++ b/controllers/mcad_params.go @@ -1,8 +1,24 @@ +/* +Copyright 2023. + +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 controllers import ( mf "github.com/manifestival/manifestival" - mcadv1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + mcadv1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" ) type MCADParams struct { diff --git a/controllers/multi_cluster_app_dispatcher.go b/controllers/multi_cluster_app_dispatcher.go index b84ca6aaf..f49d9049e 100644 --- a/controllers/multi_cluster_app_dispatcher.go +++ b/controllers/multi_cluster_app_dispatcher.go @@ -1,7 +1,23 @@ +/* +Copyright 2023. + +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 controllers import ( - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" ) var multiClusterAppDispatcherTemplates = []string{ diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 67d6fa432..074422785 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -22,28 +22,30 @@ import ( "testing" "time" - "github.com/project-codeflare/codeflare-operator/controllers/util" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + mf "github.com/manifestival/manifestival" "go.uber.org/zap/zapcore" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/types" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - mf "github.com/manifestival/manifestival" - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/kubernetes/scheme" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - //+kubebuilder:scaffold:imports + + "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" + "github.com/project-codeflare/codeflare-operator/controllers/util" + // +kubebuilder:scaffold:imports ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -93,8 +95,8 @@ var _ = BeforeSuite(func() { // Register API objects utilruntime.Must(clientgoscheme.AddToScheme(scheme.Scheme)) - utilruntime.Must(codeflarev1alpha1.AddToScheme(scheme.Scheme)) - //+kubebuilder:scaffold:scheme + utilruntime.Must(v1alpha1.AddToScheme(scheme.Scheme)) + // +kubebuilder:scaffold:scheme // Initialize Kubernetes client k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) @@ -147,8 +149,8 @@ var _ = AfterSuite(func() { // Cleanup resources to not contaminate between tests var _ = AfterEach(func() { inNamespace := client.InNamespace(workingNamespace) - Expect(k8sClient.DeleteAllOf(context.TODO(), &codeflarev1alpha1.MCAD{}, inNamespace)).ToNot(HaveOccurred()) - Expect(k8sClient.DeleteAllOf(context.TODO(), &codeflarev1alpha1.InstaScale{}, inNamespace)).ToNot(HaveOccurred()) + Expect(k8sClient.DeleteAllOf(context.TODO(), &v1alpha1.MCAD{}, inNamespace)).ToNot(HaveOccurred()) + Expect(k8sClient.DeleteAllOf(context.TODO(), &v1alpha1.InstaScale{}, inNamespace)).ToNot(HaveOccurred()) }) @@ -181,7 +183,7 @@ func compareConfigMaps(path string, opts mf.Option) { Expect(util.ConfigMapsAreEqual(*expectedConfigMap, *actualConfigMap)).Should(BeTrue()) } -//func compareRoleBindings(path string, opts mf.Option) { +// func compareRoleBindings(path string, opts mf.Option) { // expectedRB := &k8srbacv1.RoleBinding{} // Expect(convertToStructuredResource(path, expectedRB, opts)).NotTo(HaveOccurred()) // expectedRB.Subjects[0].Namespace = workingNamespace @@ -193,7 +195,7 @@ func compareConfigMaps(path string, opts mf.Option) { // }, timeout, interval).ShouldNot(HaveOccurred()) // // Expect(util.RoleBindingsAreEqual(*expectedRB, *actualRB)).Should(BeTrue()) -//} +// } func compareServiceAccounts(path string, opts mf.Option) { expectedSA := &corev1.ServiceAccount{} diff --git a/go.mod b/go.mod index 5531c4777..b898acdef 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( k8s.io/apimachinery v0.26.3 k8s.io/client-go v0.26.3 sigs.k8s.io/controller-runtime v0.14.6 + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 ) require ( @@ -71,6 +72,5 @@ require ( k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/main.go b/main.go index ff7e6886a..5358e04bd 100644 --- a/main.go +++ b/main.go @@ -30,13 +30,14 @@ import ( "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/v1alpha1" + codeflarev1alpha1 "github.com/project-codeflare/codeflare-operator/api/codeflare/v1alpha1" "github.com/project-codeflare/codeflare-operator/controllers" - //+kubebuilder:scaffold:imports + // +kubebuilder:scaffold:imports ) var ( @@ -49,7 +50,7 @@ func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(codeflarev1alpha1.AddToScheme(scheme)) - //+kubebuilder:scaffold:scheme + // +kubebuilder:scaffold:scheme } func main() { @@ -101,7 +102,7 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "InstaScale") os.Exit(1) } - //+kubebuilder:scaffold:builder + // +kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { setupLog.Error(err, "unable to set up health check")