diff --git a/.gitignore b/.gitignore index b10bdb20..052c07c8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ go.work go.work.sum .idea +.DS_Store \ No newline at end of file diff --git a/api/autoscaling/v1alpha1/groupversion_info.go b/api/autoscaling/v1alpha1/groupversion_info.go index 7e788068..e52e216d 100644 --- a/api/autoscaling/v1alpha1/groupversion_info.go +++ b/api/autoscaling/v1alpha1/groupversion_info.go @@ -28,9 +28,16 @@ var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: "autoscaling.aibrix.ai", Version: "v1alpha1"} + // SchemeGroupVersion is group version used to register these objects. + SchemeGroupVersion = GroupVersion + // 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 ) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} diff --git a/api/autoscaling/v1alpha1/podautoscaler_types.go b/api/autoscaling/v1alpha1/podautoscaler_types.go index ff6c5b19..a804533a 100644 --- a/api/autoscaling/v1alpha1/podautoscaler_types.go +++ b/api/autoscaling/v1alpha1/podautoscaler_types.go @@ -26,8 +26,10 @@ import ( // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // PodAutoscaler is the Schema for the podautoscalers API, a resource to scale Kubernetes pods based on observed metrics. // The fields in the spec determine how the scaling behavior should be applied. @@ -118,7 +120,7 @@ type PodAutoscalerStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` } -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // PodAutoscalerList contains a list of PodAutoscaler type PodAutoscalerList struct { diff --git a/api/model/v1alpha1/groupversion_info.go b/api/model/v1alpha1/groupversion_info.go index c64443c6..55b70f6e 100644 --- a/api/model/v1alpha1/groupversion_info.go +++ b/api/model/v1alpha1/groupversion_info.go @@ -28,9 +28,16 @@ var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: "model.aibrix.ai", Version: "v1alpha1"} + // SchemeGroupVersion is group version used to register these objects. + SchemeGroupVersion = GroupVersion + // 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 ) + +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} diff --git a/api/model/v1alpha1/modeladapter_types.go b/api/model/v1alpha1/modeladapter_types.go index c9192788..dfc4817b 100644 --- a/api/model/v1alpha1/modeladapter_types.go +++ b/api/model/v1alpha1/modeladapter_types.go @@ -85,8 +85,10 @@ const ( ModelAdapterConditionCleanup ModelAdapterConditionType = "Cleanup" ) -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ModelAdapter is the Schema for the modeladapters API type ModelAdapter struct { @@ -97,7 +99,7 @@ type ModelAdapter struct { Status ModelAdapterStatus `json:"status,omitempty"` } -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // ModelAdapterList contains a list of ModelAdapter type ModelAdapterList struct { diff --git a/go.mod b/go.mod index f3274d2d..4197510a 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/controller-runtime v0.17.3 sigs.k8s.io/gateway-api v1.0.0 + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 ) require ( @@ -73,7 +74,6 @@ require ( k8s.io/component-base v0.29.2 // indirect k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh new file mode 100644 index 00000000..94b80604 --- /dev/null +++ b/hack/update-codegen.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# This shell is used to auto generate some useful tools for k8s, such as clientset, lister, informer and so on. +# We don't use this tool to generate deepcopy because kubebuilder (controller-tools) has coverred that part. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +ROOT_PKG=github.com/aibrix/aibrix + +# Grab code-generator version from go.sum +CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1) +CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}") + +if [[ ! -d ${CODEGEN_PKG} ]]; then + echo "${CODEGEN_PKG} is missing. Running 'go mod download'." + go mod download +fi + +echo ">> Using ${CODEGEN_PKG}" + +# code-generator does work with go.mod but makes assumptions about +# the project living in `$GOPATH/src`. To work around this and support +# any location; create a temporary directory, use this as an output +# base, and copy everything back once generated. +TEMP_DIR=$(mktemp -d) +cleanup() { + echo ">> Removing ${TEMP_DIR}" +# rm -rf ${TEMP_DIR} +} +trap "cleanup" EXIT SIGINT + +echo ">> Temporary output directory ${TEMP_DIR}" + +# Ensure we can execute. +chmod +x ${CODEGEN_PKG}/generate-groups.sh + +# generate the code with: +# --output-base because this script should also be able to run inside the vendor dir of +# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir +# instead of the $GOPATH directly. For normal projects this can be dropped. +# +cd ${SCRIPT_ROOT} +${CODEGEN_PKG}/generate-groups.sh all \ + github.com/aibrix/aibrix/pkg/client github.com/aibrix/aibrix/api \ + "model:v1alpha1 autoscaling:v1alpha1" \ + --output-base "${TEMP_DIR}" \ + --go-header-file hack/boilerplate.go.txt + +# Copy everything back. +cp -a "${TEMP_DIR}/${ROOT_PKG}/." "${SCRIPT_ROOT}/" diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh new file mode 100755 index 00000000..94b80604 --- /dev/null +++ b/hack/verify-codegen.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# This shell is used to auto generate some useful tools for k8s, such as clientset, lister, informer and so on. +# We don't use this tool to generate deepcopy because kubebuilder (controller-tools) has coverred that part. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +ROOT_PKG=github.com/aibrix/aibrix + +# Grab code-generator version from go.sum +CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1) +CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}") + +if [[ ! -d ${CODEGEN_PKG} ]]; then + echo "${CODEGEN_PKG} is missing. Running 'go mod download'." + go mod download +fi + +echo ">> Using ${CODEGEN_PKG}" + +# code-generator does work with go.mod but makes assumptions about +# the project living in `$GOPATH/src`. To work around this and support +# any location; create a temporary directory, use this as an output +# base, and copy everything back once generated. +TEMP_DIR=$(mktemp -d) +cleanup() { + echo ">> Removing ${TEMP_DIR}" +# rm -rf ${TEMP_DIR} +} +trap "cleanup" EXIT SIGINT + +echo ">> Temporary output directory ${TEMP_DIR}" + +# Ensure we can execute. +chmod +x ${CODEGEN_PKG}/generate-groups.sh + +# generate the code with: +# --output-base because this script should also be able to run inside the vendor dir of +# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir +# instead of the $GOPATH directly. For normal projects this can be dropped. +# +cd ${SCRIPT_ROOT} +${CODEGEN_PKG}/generate-groups.sh all \ + github.com/aibrix/aibrix/pkg/client github.com/aibrix/aibrix/api \ + "model:v1alpha1 autoscaling:v1alpha1" \ + --output-base "${TEMP_DIR}" \ + --go-header-file hack/boilerplate.go.txt + +# Copy everything back. +cp -a "${TEMP_DIR}/${ROOT_PKG}/." "${SCRIPT_ROOT}/" diff --git a/pkg/client/applyconfiguration/autoscaling/v1alpha1/metricsource.go b/pkg/client/applyconfiguration/autoscaling/v1alpha1/metricsource.go new file mode 100644 index 00000000..d35b6673 --- /dev/null +++ b/pkg/client/applyconfiguration/autoscaling/v1alpha1/metricsource.go @@ -0,0 +1,56 @@ +/* +Copyright 2024 The Aibrix Team. + +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 + +// MetricSourceApplyConfiguration represents an declarative configuration of the MetricSource type for use +// with apply. +type MetricSourceApplyConfiguration struct { + Endpoint *string `json:"endpoint,omitempty"` + Path *string `json:"path,omitempty"` + Name *string `json:"metric,omitempty"` +} + +// MetricSourceApplyConfiguration constructs an declarative configuration of the MetricSource type for use with +// apply. +func MetricSource() *MetricSourceApplyConfiguration { + return &MetricSourceApplyConfiguration{} +} + +// WithEndpoint sets the Endpoint 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 Endpoint field is set to the value of the last call. +func (b *MetricSourceApplyConfiguration) WithEndpoint(value string) *MetricSourceApplyConfiguration { + b.Endpoint = &value + return b +} + +// WithPath sets the Path 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 Path field is set to the value of the last call. +func (b *MetricSourceApplyConfiguration) WithPath(value string) *MetricSourceApplyConfiguration { + b.Path = &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 *MetricSourceApplyConfiguration) WithName(value string) *MetricSourceApplyConfiguration { + b.Name = &value + return b +} diff --git a/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscaler.go b/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000..af590461 --- /dev/null +++ b/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,218 @@ +/* +Copyright 2024 The Aibrix Team. + +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" +) + +// PodAutoscalerApplyConfiguration represents an declarative configuration of the PodAutoscaler type for use +// with apply. +type PodAutoscalerApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *PodAutoscalerSpecApplyConfiguration `json:"spec,omitempty"` + Status *PodAutoscalerStatusApplyConfiguration `json:"status,omitempty"` +} + +// PodAutoscaler constructs an declarative configuration of the PodAutoscaler type for use with +// apply. +func PodAutoscaler(name, namespace string) *PodAutoscalerApplyConfiguration { + b := &PodAutoscalerApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("PodAutoscaler") + b.WithAPIVersion("autoscaling/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 *PodAutoscalerApplyConfiguration) WithKind(value string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithAPIVersion(value string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithName(value string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithGenerateName(value string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithNamespace(value string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithUID(value types.UID) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithResourceVersion(value string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithGeneration(value int64) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithCreationTimestamp(value metav1.Time) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithLabels(entries map[string]string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithAnnotations(entries map[string]string) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithFinalizers(values ...string) *PodAutoscalerApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *PodAutoscalerApplyConfiguration) 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 *PodAutoscalerApplyConfiguration) WithSpec(value *PodAutoscalerSpecApplyConfiguration) *PodAutoscalerApplyConfiguration { + 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 *PodAutoscalerApplyConfiguration) WithStatus(value *PodAutoscalerStatusApplyConfiguration) *PodAutoscalerApplyConfiguration { + b.Status = value + return b +} diff --git a/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscalerspec.go b/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscalerspec.go new file mode 100644 index 00000000..38bfc6a5 --- /dev/null +++ b/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscalerspec.go @@ -0,0 +1,102 @@ +/* +Copyright 2024 The Aibrix Team. + +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 ( + autoscalingv1alpha1 "github.com/aibrix/aibrix/api/autoscaling/v1alpha1" + v1 "k8s.io/api/core/v1" +) + +// PodAutoscalerSpecApplyConfiguration represents an declarative configuration of the PodAutoscalerSpec type for use +// with apply. +type PodAutoscalerSpecApplyConfiguration struct { + ScaleTargetRef *v1.ObjectReference `json:"scaleTargetRef,omitempty"` + MinReplicas *int32 `json:"minReplicas,omitempty"` + MaxReplicas *int32 `json:"maxReplicas,omitempty"` + TargetMetric *string `json:"targetMetric,omitempty"` + TargetValue *string `json:"targetValue,omitempty"` + MetricsSources []MetricSourceApplyConfiguration `json:"metricsSources,omitempty"` + ScalingStrategy *autoscalingv1alpha1.ScalingStrategyType `json:"scalingStrategy,omitempty"` +} + +// PodAutoscalerSpecApplyConfiguration constructs an declarative configuration of the PodAutoscalerSpec type for use with +// apply. +func PodAutoscalerSpec() *PodAutoscalerSpecApplyConfiguration { + return &PodAutoscalerSpecApplyConfiguration{} +} + +// WithScaleTargetRef sets the ScaleTargetRef 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 ScaleTargetRef field is set to the value of the last call. +func (b *PodAutoscalerSpecApplyConfiguration) WithScaleTargetRef(value v1.ObjectReference) *PodAutoscalerSpecApplyConfiguration { + b.ScaleTargetRef = &value + return b +} + +// WithMinReplicas sets the MinReplicas 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 MinReplicas field is set to the value of the last call. +func (b *PodAutoscalerSpecApplyConfiguration) WithMinReplicas(value int32) *PodAutoscalerSpecApplyConfiguration { + b.MinReplicas = &value + return b +} + +// WithMaxReplicas sets the MaxReplicas 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 MaxReplicas field is set to the value of the last call. +func (b *PodAutoscalerSpecApplyConfiguration) WithMaxReplicas(value int32) *PodAutoscalerSpecApplyConfiguration { + b.MaxReplicas = &value + return b +} + +// WithTargetMetric sets the TargetMetric 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 TargetMetric field is set to the value of the last call. +func (b *PodAutoscalerSpecApplyConfiguration) WithTargetMetric(value string) *PodAutoscalerSpecApplyConfiguration { + b.TargetMetric = &value + return b +} + +// WithTargetValue sets the TargetValue 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 TargetValue field is set to the value of the last call. +func (b *PodAutoscalerSpecApplyConfiguration) WithTargetValue(value string) *PodAutoscalerSpecApplyConfiguration { + b.TargetValue = &value + return b +} + +// WithMetricsSources adds the given value to the MetricsSources 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 MetricsSources field. +func (b *PodAutoscalerSpecApplyConfiguration) WithMetricsSources(values ...*MetricSourceApplyConfiguration) *PodAutoscalerSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMetricsSources") + } + b.MetricsSources = append(b.MetricsSources, *values[i]) + } + return b +} + +// WithScalingStrategy sets the ScalingStrategy 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 ScalingStrategy field is set to the value of the last call. +func (b *PodAutoscalerSpecApplyConfiguration) WithScalingStrategy(value autoscalingv1alpha1.ScalingStrategyType) *PodAutoscalerSpecApplyConfiguration { + b.ScalingStrategy = &value + return b +} diff --git a/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscalerstatus.go b/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscalerstatus.go new file mode 100644 index 00000000..228fb6c9 --- /dev/null +++ b/pkg/client/applyconfiguration/autoscaling/v1alpha1/podautoscalerstatus.go @@ -0,0 +1,71 @@ +/* +Copyright 2024 The Aibrix Team. + +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/apimachinery/pkg/apis/meta/v1" +) + +// PodAutoscalerStatusApplyConfiguration represents an declarative configuration of the PodAutoscalerStatus type for use +// with apply. +type PodAutoscalerStatusApplyConfiguration struct { + LastScaleTime *v1.Time `json:"lastScaleTime,omitempty"` + DesiredScale *int32 `json:"desiredScale,omitempty"` + ActualScale *int32 `json:"actualScale,omitempty"` + Conditions []v1.Condition `json:"conditions,omitempty"` +} + +// PodAutoscalerStatusApplyConfiguration constructs an declarative configuration of the PodAutoscalerStatus type for use with +// apply. +func PodAutoscalerStatus() *PodAutoscalerStatusApplyConfiguration { + return &PodAutoscalerStatusApplyConfiguration{} +} + +// WithLastScaleTime sets the LastScaleTime 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 LastScaleTime field is set to the value of the last call. +func (b *PodAutoscalerStatusApplyConfiguration) WithLastScaleTime(value v1.Time) *PodAutoscalerStatusApplyConfiguration { + b.LastScaleTime = &value + return b +} + +// WithDesiredScale sets the DesiredScale 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 DesiredScale field is set to the value of the last call. +func (b *PodAutoscalerStatusApplyConfiguration) WithDesiredScale(value int32) *PodAutoscalerStatusApplyConfiguration { + b.DesiredScale = &value + return b +} + +// WithActualScale sets the ActualScale 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 ActualScale field is set to the value of the last call. +func (b *PodAutoscalerStatusApplyConfiguration) WithActualScale(value int32) *PodAutoscalerStatusApplyConfiguration { + b.ActualScale = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *PodAutoscalerStatusApplyConfiguration) WithConditions(values ...v1.Condition) *PodAutoscalerStatusApplyConfiguration { + for i := range values { + b.Conditions = append(b.Conditions, values[i]) + } + return b +} diff --git a/pkg/client/applyconfiguration/internal/internal.go b/pkg/client/applyconfiguration/internal/internal.go new file mode 100644 index 00000000..d033c562 --- /dev/null +++ b/pkg/client/applyconfiguration/internal/internal.go @@ -0,0 +1,61 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/applyconfiguration/model/v1alpha1/modeladapter.go b/pkg/client/applyconfiguration/model/v1alpha1/modeladapter.go new file mode 100644 index 00000000..0b9c61cd --- /dev/null +++ b/pkg/client/applyconfiguration/model/v1alpha1/modeladapter.go @@ -0,0 +1,218 @@ +/* +Copyright 2024 The Aibrix Team. + +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" +) + +// ModelAdapterApplyConfiguration represents an declarative configuration of the ModelAdapter type for use +// with apply. +type ModelAdapterApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ModelAdapterSpecApplyConfiguration `json:"spec,omitempty"` + Status *ModelAdapterStatusApplyConfiguration `json:"status,omitempty"` +} + +// ModelAdapter constructs an declarative configuration of the ModelAdapter type for use with +// apply. +func ModelAdapter(name, namespace string) *ModelAdapterApplyConfiguration { + b := &ModelAdapterApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("ModelAdapter") + b.WithAPIVersion("model/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 *ModelAdapterApplyConfiguration) WithKind(value string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithAPIVersion(value string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithName(value string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithGenerateName(value string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithNamespace(value string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithUID(value types.UID) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithResourceVersion(value string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithGeneration(value int64) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithLabels(entries map[string]string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithAnnotations(entries map[string]string) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithFinalizers(values ...string) *ModelAdapterApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *ModelAdapterApplyConfiguration) 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 *ModelAdapterApplyConfiguration) WithSpec(value *ModelAdapterSpecApplyConfiguration) *ModelAdapterApplyConfiguration { + 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 *ModelAdapterApplyConfiguration) WithStatus(value *ModelAdapterStatusApplyConfiguration) *ModelAdapterApplyConfiguration { + b.Status = value + return b +} diff --git a/pkg/client/applyconfiguration/model/v1alpha1/modeladapterspec.go b/pkg/client/applyconfiguration/model/v1alpha1/modeladapterspec.go new file mode 100644 index 00000000..23341803 --- /dev/null +++ b/pkg/client/applyconfiguration/model/v1alpha1/modeladapterspec.go @@ -0,0 +1,75 @@ +/* +Copyright 2024 The Aibrix Team. + +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/apimachinery/pkg/apis/meta/v1" +) + +// ModelAdapterSpecApplyConfiguration represents an declarative configuration of the ModelAdapterSpec type for use +// with apply. +type ModelAdapterSpecApplyConfiguration struct { + BaseModel *string `json:"baseModel,omitempty"` + PodSelector *v1.LabelSelector `json:"podSelector,omitempty"` + SchedulerName *string `json:"schedulerName,omitempty"` + AdditionalConfig map[string]string `json:"additionalConfig,omitempty"` +} + +// ModelAdapterSpecApplyConfiguration constructs an declarative configuration of the ModelAdapterSpec type for use with +// apply. +func ModelAdapterSpec() *ModelAdapterSpecApplyConfiguration { + return &ModelAdapterSpecApplyConfiguration{} +} + +// WithBaseModel sets the BaseModel 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 BaseModel field is set to the value of the last call. +func (b *ModelAdapterSpecApplyConfiguration) WithBaseModel(value string) *ModelAdapterSpecApplyConfiguration { + b.BaseModel = &value + return b +} + +// WithPodSelector sets the PodSelector 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 PodSelector field is set to the value of the last call. +func (b *ModelAdapterSpecApplyConfiguration) WithPodSelector(value v1.LabelSelector) *ModelAdapterSpecApplyConfiguration { + b.PodSelector = &value + return b +} + +// WithSchedulerName sets the SchedulerName 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 SchedulerName field is set to the value of the last call. +func (b *ModelAdapterSpecApplyConfiguration) WithSchedulerName(value string) *ModelAdapterSpecApplyConfiguration { + b.SchedulerName = &value + return b +} + +// WithAdditionalConfig puts the entries into the AdditionalConfig 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 AdditionalConfig field, +// overwriting an existing map entries in AdditionalConfig field with the same key. +func (b *ModelAdapterSpecApplyConfiguration) WithAdditionalConfig(entries map[string]string) *ModelAdapterSpecApplyConfiguration { + if b.AdditionalConfig == nil && len(entries) > 0 { + b.AdditionalConfig = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.AdditionalConfig[k] = v + } + return b +} diff --git a/pkg/client/applyconfiguration/model/v1alpha1/modeladapterstatus.go b/pkg/client/applyconfiguration/model/v1alpha1/modeladapterstatus.go new file mode 100644 index 00000000..b280a9fc --- /dev/null +++ b/pkg/client/applyconfiguration/model/v1alpha1/modeladapterstatus.go @@ -0,0 +1,65 @@ +/* +Copyright 2024 The Aibrix Team. + +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 ( + v1alpha1 "github.com/aibrix/aibrix/api/model/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ModelAdapterStatusApplyConfiguration represents an declarative configuration of the ModelAdapterStatus type for use +// with apply. +type ModelAdapterStatusApplyConfiguration struct { + Phase *v1alpha1.ModelAdapterPhase `json:"phase,omitempty"` + Conditions []v1.Condition `json:"conditions,omitempty"` + Instances []string `json:"instances,omitempty"` +} + +// ModelAdapterStatusApplyConfiguration constructs an declarative configuration of the ModelAdapterStatus type for use with +// apply. +func ModelAdapterStatus() *ModelAdapterStatusApplyConfiguration { + return &ModelAdapterStatusApplyConfiguration{} +} + +// WithPhase sets the Phase field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Phase field is set to the value of the last call. +func (b *ModelAdapterStatusApplyConfiguration) WithPhase(value v1alpha1.ModelAdapterPhase) *ModelAdapterStatusApplyConfiguration { + b.Phase = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *ModelAdapterStatusApplyConfiguration) WithConditions(values ...v1.Condition) *ModelAdapterStatusApplyConfiguration { + for i := range values { + b.Conditions = append(b.Conditions, values[i]) + } + return b +} + +// WithInstances adds the given value to the Instances 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 Instances field. +func (b *ModelAdapterStatusApplyConfiguration) WithInstances(values ...string) *ModelAdapterStatusApplyConfiguration { + for i := range values { + b.Instances = append(b.Instances, values[i]) + } + return b +} diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go new file mode 100644 index 00000000..5099a90f --- /dev/null +++ b/pkg/client/applyconfiguration/utils.go @@ -0,0 +1,52 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/autoscaling/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/api/model/v1alpha1" + autoscalingv1alpha1 "github.com/aibrix/aibrix/pkg/client/applyconfiguration/autoscaling/v1alpha1" + applyconfigurationmodelv1alpha1 "github.com/aibrix/aibrix/pkg/client/applyconfiguration/model/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=autoscaling, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("MetricSource"): + return &autoscalingv1alpha1.MetricSourceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PodAutoscaler"): + return &autoscalingv1alpha1.PodAutoscalerApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PodAutoscalerSpec"): + return &autoscalingv1alpha1.PodAutoscalerSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PodAutoscalerStatus"): + return &autoscalingv1alpha1.PodAutoscalerStatusApplyConfiguration{} + + // Group=model, Version=v1alpha1 + case modelv1alpha1.SchemeGroupVersion.WithKind("ModelAdapter"): + return &applyconfigurationmodelv1alpha1.ModelAdapterApplyConfiguration{} + case modelv1alpha1.SchemeGroupVersion.WithKind("ModelAdapterSpec"): + return &applyconfigurationmodelv1alpha1.ModelAdapterSpecApplyConfiguration{} + case modelv1alpha1.SchemeGroupVersion.WithKind("ModelAdapterStatus"): + return &applyconfigurationmodelv1alpha1.ModelAdapterStatusApplyConfiguration{} + + } + return nil +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 00000000..4f8d6017 --- /dev/null +++ b/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,132 @@ +/* +Copyright 2024 The Aibrix Team. + +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" + + autoscalingv1alpha1 "github.com/aibrix/aibrix/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/pkg/client/clientset/versioned/typed/model/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 + AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface + ModelV1alpha1() modelv1alpha1.ModelV1alpha1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client + modelV1alpha1 *modelv1alpha1.ModelV1alpha1Client +} + +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return c.autoscalingV1alpha1 +} + +// ModelV1alpha1 retrieves the ModelV1alpha1Client +func (c *Clientset) ModelV1alpha1() modelv1alpha1.ModelV1alpha1Interface { + return c.modelV1alpha1 +} + +// 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.autoscalingV1alpha1, err = autoscalingv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + cs.modelV1alpha1, err = modelv1alpha1.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.autoscalingV1alpha1 = autoscalingv1alpha1.New(c) + cs.modelV1alpha1 = modelv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 00000000..1608e5f1 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,91 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/client/clientset/versioned" + autoscalingv1alpha1 "github.com/aibrix/aibrix/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + fakeautoscalingv1alpha1 "github.com/aibrix/aibrix/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake" + modelv1alpha1 "github.com/aibrix/aibrix/pkg/client/clientset/versioned/typed/model/v1alpha1" + fakemodelv1alpha1 "github.com/aibrix/aibrix/pkg/client/clientset/versioned/typed/model/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{} +) + +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake} +} + +// ModelV1alpha1 retrieves the ModelV1alpha1Client +func (c *Clientset) ModelV1alpha1() modelv1alpha1.ModelV1alpha1Interface { + return &fakemodelv1alpha1.FakeModelV1alpha1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 00000000..e47add1d --- /dev/null +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 00000000..052c7d22 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2024 The Aibrix Team. + +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 ( + autoscalingv1alpha1 "github.com/aibrix/aibrix/api/autoscaling/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/api/model/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{ + autoscalingv1alpha1.AddToScheme, + modelv1alpha1.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/pkg/client/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 00000000..3cc1b5da --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 00000000..a27edc30 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2024 The Aibrix Team. + +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 ( + autoscalingv1alpha1 "github.com/aibrix/aibrix/api/autoscaling/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/api/model/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{ + autoscalingv1alpha1.AddToScheme, + modelv1alpha1.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/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go new file mode 100644 index 00000000..1291ae1a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go @@ -0,0 +1,106 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/autoscaling/v1alpha1" + "github.com/aibrix/aibrix/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type AutoscalingV1alpha1Interface interface { + RESTClient() rest.Interface + PodAutoscalersGetter +} + +// AutoscalingV1alpha1Client is used to interact with features provided by the autoscaling group. +type AutoscalingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *AutoscalingV1alpha1Client) PodAutoscalers(namespace string) PodAutoscalerInterface { + return newPodAutoscalers(c, namespace) +} + +// NewForConfig creates a new AutoscalingV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*AutoscalingV1alpha1Client, 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 AutoscalingV1alpha1Client 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) (*AutoscalingV1alpha1Client, 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 &AutoscalingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new AutoscalingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AutoscalingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AutoscalingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *AutoscalingV1alpha1Client { + return &AutoscalingV1alpha1Client{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 *AutoscalingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go new file mode 100644 index 00000000..446d7263 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go new file mode 100644 index 00000000..80e491a1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go new file mode 100644 index 00000000..0a5f2b73 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go @@ -0,0 +1,39 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAutoscalingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1alpha1) PodAutoscalers(namespace string) v1alpha1.PodAutoscalerInterface { + return &FakePodAutoscalers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go new file mode 100644 index 00000000..59726832 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go @@ -0,0 +1,188 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/autoscaling/v1alpha1" + autoscalingv1alpha1 "github.com/aibrix/aibrix/pkg/client/applyconfiguration/autoscaling/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" +) + +// FakePodAutoscalers implements PodAutoscalerInterface +type FakePodAutoscalers struct { + Fake *FakeAutoscalingV1alpha1 + ns string +} + +var podautoscalersResource = v1alpha1.SchemeGroupVersion.WithResource("podautoscalers") + +var podautoscalersKind = v1alpha1.SchemeGroupVersion.WithKind("PodAutoscaler") + +// Get takes name of the podAutoscaler, and returns the corresponding podAutoscaler object, and an error if there is any. +func (c *FakePodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(podautoscalersResource, c.ns, name), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of PodAutoscalers that match those selectors. +func (c *FakePodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(podautoscalersResource, podautoscalersKind, c.ns, opts), &v1alpha1.PodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PodAutoscalerList{ListMeta: obj.(*v1alpha1.PodAutoscalerList).ListMeta} + for _, item := range obj.(*v1alpha1.PodAutoscalerList).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 podAutoscalers. +func (c *FakePodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(podautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a podAutoscaler and creates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *FakePodAutoscalers) Create(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.CreateOptions) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(podautoscalersResource, c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Update takes the representation of a podAutoscaler and updates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *FakePodAutoscalers) Update(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(podautoscalersResource, c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), 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 *FakePodAutoscalers) UpdateStatus(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (*v1alpha1.PodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(podautoscalersResource, "status", c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Delete takes name of the podAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakePodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(podautoscalersResource, c.ns, name, opts), &v1alpha1.PodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(podautoscalersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched podAutoscaler. +func (c *FakePodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podautoscalersResource, c.ns, name, pt, data, subresources...), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied podAutoscaler. +func (c *FakePodAutoscalers) Apply(ctx context.Context, podAutoscaler *autoscalingv1alpha1.PodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PodAutoscaler, err error) { + if podAutoscaler == nil { + return nil, fmt.Errorf("podAutoscaler provided to Apply must not be nil") + } + data, err := json.Marshal(podAutoscaler) + if err != nil { + return nil, err + } + name := podAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("podAutoscaler.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podautoscalersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), 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 *FakePodAutoscalers) ApplyStatus(ctx context.Context, podAutoscaler *autoscalingv1alpha1.PodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PodAutoscaler, err error) { + if podAutoscaler == nil { + return nil, fmt.Errorf("podAutoscaler provided to Apply must not be nil") + } + data, err := json.Marshal(podAutoscaler) + if err != nil { + return nil, err + } + name := podAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("podAutoscaler.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podautoscalersResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go new file mode 100644 index 00000000..2ead6cab --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 The Aibrix Team. + +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 PodAutoscalerExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000..af7b2343 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,255 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/autoscaling/v1alpha1" + autoscalingv1alpha1 "github.com/aibrix/aibrix/pkg/client/applyconfiguration/autoscaling/v1alpha1" + scheme "github.com/aibrix/aibrix/pkg/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" +) + +// PodAutoscalersGetter has a method to return a PodAutoscalerInterface. +// A group's client should implement this interface. +type PodAutoscalersGetter interface { + PodAutoscalers(namespace string) PodAutoscalerInterface +} + +// PodAutoscalerInterface has methods to work with PodAutoscaler resources. +type PodAutoscalerInterface interface { + Create(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.CreateOptions) (*v1alpha1.PodAutoscaler, error) + Update(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (*v1alpha1.PodAutoscaler, error) + UpdateStatus(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (*v1alpha1.PodAutoscaler, 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.PodAutoscaler, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PodAutoscalerList, 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.PodAutoscaler, err error) + Apply(ctx context.Context, podAutoscaler *autoscalingv1alpha1.PodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PodAutoscaler, err error) + ApplyStatus(ctx context.Context, podAutoscaler *autoscalingv1alpha1.PodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PodAutoscaler, err error) + PodAutoscalerExpansion +} + +// podAutoscalers implements PodAutoscalerInterface +type podAutoscalers struct { + client rest.Interface + ns string +} + +// newPodAutoscalers returns a PodAutoscalers +func newPodAutoscalers(c *AutoscalingV1alpha1Client, namespace string) *podAutoscalers { + return &podAutoscalers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the podAutoscaler, and returns the corresponding podAutoscaler object, and an error if there is any. +func (c *podAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PodAutoscalers that match those selectors. +func (c *podAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podAutoscalers. +func (c *podAutoscalers) 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("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a podAutoscaler and creates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *podAutoscalers) Create(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.CreateOptions) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Post(). + Namespace(c.ns). + Resource("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(podAutoscaler). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a podAutoscaler and updates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *podAutoscalers) Update(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(podAutoscaler.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(podAutoscaler). + 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 *podAutoscalers) UpdateStatus(ctx context.Context, podAutoscaler *v1alpha1.PodAutoscaler, opts v1.UpdateOptions) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(podAutoscaler.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(podAutoscaler). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the podAutoscaler and deletes it. Returns an error if one occurs. +func (c *podAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *podAutoscalers) 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("podautoscalers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched podAutoscaler. +func (c *podAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("podautoscalers"). + 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 podAutoscaler. +func (c *podAutoscalers) Apply(ctx context.Context, podAutoscaler *autoscalingv1alpha1.PodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PodAutoscaler, err error) { + if podAutoscaler == nil { + return nil, fmt.Errorf("podAutoscaler provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(podAutoscaler) + if err != nil { + return nil, err + } + name := podAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("podAutoscaler.Name must be provided to Apply") + } + result = &v1alpha1.PodAutoscaler{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("podautoscalers"). + 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 *podAutoscalers) ApplyStatus(ctx context.Context, podAutoscaler *autoscalingv1alpha1.PodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PodAutoscaler, err error) { + if podAutoscaler == nil { + return nil, fmt.Errorf("podAutoscaler provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(podAutoscaler) + if err != nil { + return nil, err + } + + name := podAutoscaler.Name + if name == nil { + return nil, fmt.Errorf("podAutoscaler.Name must be provided to Apply") + } + + result = &v1alpha1.PodAutoscaler{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("podautoscalers"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/model/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/doc.go new file mode 100644 index 00000000..446d7263 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/doc.go new file mode 100644 index 00000000..80e491a1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024 The Aibrix Team. + +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/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/fake_model_client.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/fake_model_client.go new file mode 100644 index 00000000..5891e94e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/fake_model_client.go @@ -0,0 +1,39 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/client/clientset/versioned/typed/model/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeModelV1alpha1 struct { + *testing.Fake +} + +func (c *FakeModelV1alpha1) ModelAdapters(namespace string) v1alpha1.ModelAdapterInterface { + return &FakeModelAdapters{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeModelV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/fake_modeladapter.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/fake_modeladapter.go new file mode 100644 index 00000000..6da26bf0 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/fake/fake_modeladapter.go @@ -0,0 +1,188 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/model/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/pkg/client/applyconfiguration/model/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" +) + +// FakeModelAdapters implements ModelAdapterInterface +type FakeModelAdapters struct { + Fake *FakeModelV1alpha1 + ns string +} + +var modeladaptersResource = v1alpha1.SchemeGroupVersion.WithResource("modeladapters") + +var modeladaptersKind = v1alpha1.SchemeGroupVersion.WithKind("ModelAdapter") + +// Get takes name of the modelAdapter, and returns the corresponding modelAdapter object, and an error if there is any. +func (c *FakeModelAdapters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ModelAdapter, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(modeladaptersResource, c.ns, name), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), err +} + +// List takes label and field selectors, and returns the list of ModelAdapters that match those selectors. +func (c *FakeModelAdapters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ModelAdapterList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(modeladaptersResource, modeladaptersKind, c.ns, opts), &v1alpha1.ModelAdapterList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ModelAdapterList{ListMeta: obj.(*v1alpha1.ModelAdapterList).ListMeta} + for _, item := range obj.(*v1alpha1.ModelAdapterList).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 modelAdapters. +func (c *FakeModelAdapters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(modeladaptersResource, c.ns, opts)) + +} + +// Create takes the representation of a modelAdapter and creates it. Returns the server's representation of the modelAdapter, and an error, if there is any. +func (c *FakeModelAdapters) Create(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.CreateOptions) (result *v1alpha1.ModelAdapter, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(modeladaptersResource, c.ns, modelAdapter), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), err +} + +// Update takes the representation of a modelAdapter and updates it. Returns the server's representation of the modelAdapter, and an error, if there is any. +func (c *FakeModelAdapters) Update(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.UpdateOptions) (result *v1alpha1.ModelAdapter, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(modeladaptersResource, c.ns, modelAdapter), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), 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 *FakeModelAdapters) UpdateStatus(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.UpdateOptions) (*v1alpha1.ModelAdapter, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(modeladaptersResource, "status", c.ns, modelAdapter), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), err +} + +// Delete takes name of the modelAdapter and deletes it. Returns an error if one occurs. +func (c *FakeModelAdapters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(modeladaptersResource, c.ns, name, opts), &v1alpha1.ModelAdapter{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeModelAdapters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(modeladaptersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ModelAdapterList{}) + return err +} + +// Patch applies the patch and returns the patched modelAdapter. +func (c *FakeModelAdapters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ModelAdapter, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(modeladaptersResource, c.ns, name, pt, data, subresources...), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied modelAdapter. +func (c *FakeModelAdapters) Apply(ctx context.Context, modelAdapter *modelv1alpha1.ModelAdapterApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ModelAdapter, err error) { + if modelAdapter == nil { + return nil, fmt.Errorf("modelAdapter provided to Apply must not be nil") + } + data, err := json.Marshal(modelAdapter) + if err != nil { + return nil, err + } + name := modelAdapter.Name + if name == nil { + return nil, fmt.Errorf("modelAdapter.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(modeladaptersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), 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 *FakeModelAdapters) ApplyStatus(ctx context.Context, modelAdapter *modelv1alpha1.ModelAdapterApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ModelAdapter, err error) { + if modelAdapter == nil { + return nil, fmt.Errorf("modelAdapter provided to Apply must not be nil") + } + data, err := json.Marshal(modelAdapter) + if err != nil { + return nil, err + } + name := modelAdapter.Name + if name == nil { + return nil, fmt.Errorf("modelAdapter.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(modeladaptersResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.ModelAdapter{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ModelAdapter), err +} diff --git a/pkg/client/clientset/versioned/typed/model/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/generated_expansion.go new file mode 100644 index 00000000..6c7bd496 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/generated_expansion.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 The Aibrix Team. + +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 ModelAdapterExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/model/v1alpha1/model_client.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/model_client.go new file mode 100644 index 00000000..e3fcd4af --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/model_client.go @@ -0,0 +1,106 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/model/v1alpha1" + "github.com/aibrix/aibrix/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type ModelV1alpha1Interface interface { + RESTClient() rest.Interface + ModelAdaptersGetter +} + +// ModelV1alpha1Client is used to interact with features provided by the model group. +type ModelV1alpha1Client struct { + restClient rest.Interface +} + +func (c *ModelV1alpha1Client) ModelAdapters(namespace string) ModelAdapterInterface { + return newModelAdapters(c, namespace) +} + +// NewForConfig creates a new ModelV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*ModelV1alpha1Client, 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 ModelV1alpha1Client 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) (*ModelV1alpha1Client, 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 &ModelV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new ModelV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ModelV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ModelV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ModelV1alpha1Client { + return &ModelV1alpha1Client{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 *ModelV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/model/v1alpha1/modeladapter.go b/pkg/client/clientset/versioned/typed/model/v1alpha1/modeladapter.go new file mode 100644 index 00000000..a08310b8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/model/v1alpha1/modeladapter.go @@ -0,0 +1,255 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/model/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/pkg/client/applyconfiguration/model/v1alpha1" + scheme "github.com/aibrix/aibrix/pkg/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" +) + +// ModelAdaptersGetter has a method to return a ModelAdapterInterface. +// A group's client should implement this interface. +type ModelAdaptersGetter interface { + ModelAdapters(namespace string) ModelAdapterInterface +} + +// ModelAdapterInterface has methods to work with ModelAdapter resources. +type ModelAdapterInterface interface { + Create(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.CreateOptions) (*v1alpha1.ModelAdapter, error) + Update(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.UpdateOptions) (*v1alpha1.ModelAdapter, error) + UpdateStatus(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.UpdateOptions) (*v1alpha1.ModelAdapter, 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.ModelAdapter, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ModelAdapterList, 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.ModelAdapter, err error) + Apply(ctx context.Context, modelAdapter *modelv1alpha1.ModelAdapterApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ModelAdapter, err error) + ApplyStatus(ctx context.Context, modelAdapter *modelv1alpha1.ModelAdapterApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ModelAdapter, err error) + ModelAdapterExpansion +} + +// modelAdapters implements ModelAdapterInterface +type modelAdapters struct { + client rest.Interface + ns string +} + +// newModelAdapters returns a ModelAdapters +func newModelAdapters(c *ModelV1alpha1Client, namespace string) *modelAdapters { + return &modelAdapters{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the modelAdapter, and returns the corresponding modelAdapter object, and an error if there is any. +func (c *modelAdapters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ModelAdapter, err error) { + result = &v1alpha1.ModelAdapter{} + err = c.client.Get(). + Namespace(c.ns). + Resource("modeladapters"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ModelAdapters that match those selectors. +func (c *modelAdapters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ModelAdapterList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ModelAdapterList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("modeladapters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested modelAdapters. +func (c *modelAdapters) 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("modeladapters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a modelAdapter and creates it. Returns the server's representation of the modelAdapter, and an error, if there is any. +func (c *modelAdapters) Create(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.CreateOptions) (result *v1alpha1.ModelAdapter, err error) { + result = &v1alpha1.ModelAdapter{} + err = c.client.Post(). + Namespace(c.ns). + Resource("modeladapters"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(modelAdapter). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a modelAdapter and updates it. Returns the server's representation of the modelAdapter, and an error, if there is any. +func (c *modelAdapters) Update(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.UpdateOptions) (result *v1alpha1.ModelAdapter, err error) { + result = &v1alpha1.ModelAdapter{} + err = c.client.Put(). + Namespace(c.ns). + Resource("modeladapters"). + Name(modelAdapter.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(modelAdapter). + 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 *modelAdapters) UpdateStatus(ctx context.Context, modelAdapter *v1alpha1.ModelAdapter, opts v1.UpdateOptions) (result *v1alpha1.ModelAdapter, err error) { + result = &v1alpha1.ModelAdapter{} + err = c.client.Put(). + Namespace(c.ns). + Resource("modeladapters"). + Name(modelAdapter.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(modelAdapter). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the modelAdapter and deletes it. Returns an error if one occurs. +func (c *modelAdapters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("modeladapters"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *modelAdapters) 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("modeladapters"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched modelAdapter. +func (c *modelAdapters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ModelAdapter, err error) { + result = &v1alpha1.ModelAdapter{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("modeladapters"). + 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 modelAdapter. +func (c *modelAdapters) Apply(ctx context.Context, modelAdapter *modelv1alpha1.ModelAdapterApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ModelAdapter, err error) { + if modelAdapter == nil { + return nil, fmt.Errorf("modelAdapter provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(modelAdapter) + if err != nil { + return nil, err + } + name := modelAdapter.Name + if name == nil { + return nil, fmt.Errorf("modelAdapter.Name must be provided to Apply") + } + result = &v1alpha1.ModelAdapter{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("modeladapters"). + 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 *modelAdapters) ApplyStatus(ctx context.Context, modelAdapter *modelv1alpha1.ModelAdapterApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ModelAdapter, err error) { + if modelAdapter == nil { + return nil, fmt.Errorf("modelAdapter provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(modelAdapter) + if err != nil { + return nil, err + } + + name := modelAdapter.Name + if name == nil { + return nil, fmt.Errorf("modelAdapter.Name must be provided to Apply") + } + + result = &v1alpha1.ModelAdapter{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("modeladapters"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/autoscaling/interface.go b/pkg/client/informers/externalversions/autoscaling/interface.go new file mode 100644 index 00000000..7ea864f5 --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2024 The Aibrix Team. + +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 autoscaling + +import ( + v1alpha1 "github.com/aibrix/aibrix/pkg/client/informers/externalversions/autoscaling/v1alpha1" + internalinterfaces "github.com/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go b/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go new file mode 100644 index 00000000..a9c00d5d --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go @@ -0,0 +1,44 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // PodAutoscalers returns a PodAutoscalerInformer. + PodAutoscalers() PodAutoscalerInformer +} + +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} +} + +// PodAutoscalers returns a PodAutoscalerInformer. +func (v *version) PodAutoscalers() PodAutoscalerInformer { + return &podAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go b/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000..14680eed --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,89 @@ +/* +Copyright 2024 The Aibrix Team. + +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" + + autoscalingv1alpha1 "github.com/aibrix/aibrix/api/autoscaling/v1alpha1" + versioned "github.com/aibrix/aibrix/pkg/client/clientset/versioned" + internalinterfaces "github.com/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/aibrix/aibrix/pkg/client/listers/autoscaling/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" +) + +// PodAutoscalerInformer provides access to a shared informer and lister for +// PodAutoscalers. +type PodAutoscalerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PodAutoscalerLister +} + +type podAutoscalerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPodAutoscalerInformer constructs a new informer for PodAutoscaler 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 NewPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPodAutoscalerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPodAutoscalerInformer constructs a new informer for PodAutoscaler 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 NewFilteredPodAutoscalerInformer(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.AutoscalingV1alpha1().PodAutoscalers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().PodAutoscalers(namespace).Watch(context.TODO(), options) + }, + }, + &autoscalingv1alpha1.PodAutoscaler{}, + resyncPeriod, + indexers, + ) +} + +func (f *podAutoscalerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPodAutoscalerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *podAutoscalerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&autoscalingv1alpha1.PodAutoscaler{}, f.defaultInformer) +} + +func (f *podAutoscalerInformer) Lister() v1alpha1.PodAutoscalerLister { + return v1alpha1.NewPodAutoscalerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 00000000..626306c2 --- /dev/null +++ b/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,266 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/client/clientset/versioned" + autoscaling "github.com/aibrix/aibrix/pkg/client/informers/externalversions/autoscaling" + internalinterfaces "github.com/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" + model "github.com/aibrix/aibrix/pkg/client/informers/externalversions/model" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Autoscaling() autoscaling.Interface + Model() model.Interface +} + +func (f *sharedInformerFactory) Autoscaling() autoscaling.Interface { + return autoscaling.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Model() model.Interface { + return model.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go new file mode 100644 index 00000000..fc778d6b --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,66 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/autoscaling/v1alpha1" + modelv1alpha1 "github.com/aibrix/aibrix/api/model/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=autoscaling, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("podautoscalers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().PodAutoscalers().Informer()}, nil + + // Group=model, Version=v1alpha1 + case modelv1alpha1.SchemeGroupVersion.WithResource("modeladapters"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Model().V1alpha1().ModelAdapters().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 00000000..18136973 --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,39 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/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/pkg/client/informers/externalversions/model/interface.go b/pkg/client/informers/externalversions/model/interface.go new file mode 100644 index 00000000..091aab53 --- /dev/null +++ b/pkg/client/informers/externalversions/model/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2024 The Aibrix Team. + +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 model + +import ( + internalinterfaces "github.com/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/aibrix/aibrix/pkg/client/informers/externalversions/model/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/model/v1alpha1/interface.go b/pkg/client/informers/externalversions/model/v1alpha1/interface.go new file mode 100644 index 00000000..64590085 --- /dev/null +++ b/pkg/client/informers/externalversions/model/v1alpha1/interface.go @@ -0,0 +1,44 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ModelAdapters returns a ModelAdapterInformer. + ModelAdapters() ModelAdapterInformer +} + +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} +} + +// ModelAdapters returns a ModelAdapterInformer. +func (v *version) ModelAdapters() ModelAdapterInformer { + return &modelAdapterInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/model/v1alpha1/modeladapter.go b/pkg/client/informers/externalversions/model/v1alpha1/modeladapter.go new file mode 100644 index 00000000..4ecfd377 --- /dev/null +++ b/pkg/client/informers/externalversions/model/v1alpha1/modeladapter.go @@ -0,0 +1,89 @@ +/* +Copyright 2024 The Aibrix Team. + +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" + + modelv1alpha1 "github.com/aibrix/aibrix/api/model/v1alpha1" + versioned "github.com/aibrix/aibrix/pkg/client/clientset/versioned" + internalinterfaces "github.com/aibrix/aibrix/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/aibrix/aibrix/pkg/client/listers/model/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" +) + +// ModelAdapterInformer provides access to a shared informer and lister for +// ModelAdapters. +type ModelAdapterInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ModelAdapterLister +} + +type modelAdapterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewModelAdapterInformer constructs a new informer for ModelAdapter 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 NewModelAdapterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredModelAdapterInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredModelAdapterInformer constructs a new informer for ModelAdapter 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 NewFilteredModelAdapterInformer(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.ModelV1alpha1().ModelAdapters(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ModelV1alpha1().ModelAdapters(namespace).Watch(context.TODO(), options) + }, + }, + &modelv1alpha1.ModelAdapter{}, + resyncPeriod, + indexers, + ) +} + +func (f *modelAdapterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredModelAdapterInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *modelAdapterInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&modelv1alpha1.ModelAdapter{}, f.defaultInformer) +} + +func (f *modelAdapterInformer) Lister() v1alpha1.ModelAdapterLister { + return v1alpha1.NewModelAdapterLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go b/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go new file mode 100644 index 00000000..dc83de02 --- /dev/null +++ b/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go @@ -0,0 +1,26 @@ +/* +Copyright 2024 The Aibrix Team. + +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 + +// PodAutoscalerListerExpansion allows custom methods to be added to +// PodAutoscalerLister. +type PodAutoscalerListerExpansion interface{} + +// PodAutoscalerNamespaceListerExpansion allows custom methods to be added to +// PodAutoscalerNamespaceLister. +type PodAutoscalerNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go b/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000..ff35e2bf --- /dev/null +++ b/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,98 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/autoscaling/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PodAutoscalerLister helps list PodAutoscalers. +// All objects returned here must be treated as read-only. +type PodAutoscalerLister interface { + // List lists all PodAutoscalers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) + // PodAutoscalers returns an object that can list and get PodAutoscalers. + PodAutoscalers(namespace string) PodAutoscalerNamespaceLister + PodAutoscalerListerExpansion +} + +// podAutoscalerLister implements the PodAutoscalerLister interface. +type podAutoscalerLister struct { + indexer cache.Indexer +} + +// NewPodAutoscalerLister returns a new PodAutoscalerLister. +func NewPodAutoscalerLister(indexer cache.Indexer) PodAutoscalerLister { + return &podAutoscalerLister{indexer: indexer} +} + +// List lists all PodAutoscalers in the indexer. +func (s *podAutoscalerLister) List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodAutoscaler)) + }) + return ret, err +} + +// PodAutoscalers returns an object that can list and get PodAutoscalers. +func (s *podAutoscalerLister) PodAutoscalers(namespace string) PodAutoscalerNamespaceLister { + return podAutoscalerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PodAutoscalerNamespaceLister helps list and get PodAutoscalers. +// All objects returned here must be treated as read-only. +type PodAutoscalerNamespaceLister interface { + // List lists all PodAutoscalers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) + // Get retrieves the PodAutoscaler from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.PodAutoscaler, error) + PodAutoscalerNamespaceListerExpansion +} + +// podAutoscalerNamespaceLister implements the PodAutoscalerNamespaceLister +// interface. +type podAutoscalerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PodAutoscalers in the indexer for a given namespace. +func (s podAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodAutoscaler)) + }) + return ret, err +} + +// Get retrieves the PodAutoscaler from the indexer for a given namespace and name. +func (s podAutoscalerNamespaceLister) Get(name string) (*v1alpha1.PodAutoscaler, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("podautoscaler"), name) + } + return obj.(*v1alpha1.PodAutoscaler), nil +} diff --git a/pkg/client/listers/model/v1alpha1/expansion_generated.go b/pkg/client/listers/model/v1alpha1/expansion_generated.go new file mode 100644 index 00000000..f4fb0c00 --- /dev/null +++ b/pkg/client/listers/model/v1alpha1/expansion_generated.go @@ -0,0 +1,26 @@ +/* +Copyright 2024 The Aibrix Team. + +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 + +// ModelAdapterListerExpansion allows custom methods to be added to +// ModelAdapterLister. +type ModelAdapterListerExpansion interface{} + +// ModelAdapterNamespaceListerExpansion allows custom methods to be added to +// ModelAdapterNamespaceLister. +type ModelAdapterNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/model/v1alpha1/modeladapter.go b/pkg/client/listers/model/v1alpha1/modeladapter.go new file mode 100644 index 00000000..d2c7c93c --- /dev/null +++ b/pkg/client/listers/model/v1alpha1/modeladapter.go @@ -0,0 +1,98 @@ +/* +Copyright 2024 The Aibrix Team. + +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/aibrix/aibrix/api/model/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ModelAdapterLister helps list ModelAdapters. +// All objects returned here must be treated as read-only. +type ModelAdapterLister interface { + // List lists all ModelAdapters in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ModelAdapter, err error) + // ModelAdapters returns an object that can list and get ModelAdapters. + ModelAdapters(namespace string) ModelAdapterNamespaceLister + ModelAdapterListerExpansion +} + +// modelAdapterLister implements the ModelAdapterLister interface. +type modelAdapterLister struct { + indexer cache.Indexer +} + +// NewModelAdapterLister returns a new ModelAdapterLister. +func NewModelAdapterLister(indexer cache.Indexer) ModelAdapterLister { + return &modelAdapterLister{indexer: indexer} +} + +// List lists all ModelAdapters in the indexer. +func (s *modelAdapterLister) List(selector labels.Selector) (ret []*v1alpha1.ModelAdapter, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ModelAdapter)) + }) + return ret, err +} + +// ModelAdapters returns an object that can list and get ModelAdapters. +func (s *modelAdapterLister) ModelAdapters(namespace string) ModelAdapterNamespaceLister { + return modelAdapterNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ModelAdapterNamespaceLister helps list and get ModelAdapters. +// All objects returned here must be treated as read-only. +type ModelAdapterNamespaceLister interface { + // List lists all ModelAdapters in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ModelAdapter, err error) + // Get retrieves the ModelAdapter from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ModelAdapter, error) + ModelAdapterNamespaceListerExpansion +} + +// modelAdapterNamespaceLister implements the ModelAdapterNamespaceLister +// interface. +type modelAdapterNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ModelAdapters in the indexer for a given namespace. +func (s modelAdapterNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ModelAdapter, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ModelAdapter)) + }) + return ret, err +} + +// Get retrieves the ModelAdapter from the indexer for a given namespace and name. +func (s modelAdapterNamespaceLister) Get(name string) (*v1alpha1.ModelAdapter, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("modeladapter"), name) + } + return obj.(*v1alpha1.ModelAdapter), nil +} diff --git a/pkg/plugins/gateway/go.mod b/pkg/plugins/gateway/go.mod index a6ceace4..27358ad3 100644 --- a/pkg/plugins/gateway/go.mod +++ b/pkg/plugins/gateway/go.mod @@ -1,4 +1,4 @@ -module github.com/aibrix/aibrix/pkg/plugins/ratelimiter +module github.com/aibrix/aibrix/pkg/plugins/gateway go 1.22.0 diff --git a/pkg/plugins/gateway/main.go b/pkg/plugins/gateway/main.go index 2606e326..6c297bb7 100644 --- a/pkg/plugins/gateway/main.go +++ b/pkg/plugins/gateway/main.go @@ -30,8 +30,8 @@ import ( "syscall" "time" - ratelimiter "github.com/aibrix/aibrix/pkg/plugins/ratelimiter/rate_limiter" - routing "github.com/aibrix/aibrix/pkg/plugins/ratelimiter/routing_algorithms" + ratelimiter "github.com/aibrix/aibrix/pkg/plugins/gateway/rate_limiter" + routing "github.com/aibrix/aibrix/pkg/plugins/gateway/routing_algorithms" redis "github.com/redis/go-redis/v9" openai "github.com/sashabaranov/go-openai" "google.golang.org/grpc"