mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2026-07-16 09:35:06 +00:00
feat: add openapi schema and apply configurations
- Add OpenAPI schema generation for zalando.org/v1 API types - Generate apply configurations for client-side apply operations - Create models-schema tool for extracting OpenAPI definitions - Update code generation scripts to support applyconfiguration-gen - Add +k8s:openapi-gen=true annotations to API packages - Enhance client interfaces with Apply and ApplyStatus methods - Update fake clients to support field management - Modernize test clients with new NewClientset constructors This enables server-side apply functionality and improves API discoverability through proper OpenAPI schema definitions for ScalingSchedule and ClusterScalingSchedule resources. Signed-off-by: Markus Wyrsch <markus.wyrsch@zalando.de>
This commit is contained in:
@@ -46,6 +46,7 @@ $(OPENAPI): go.mod
|
||||
--output-pkg github.com/zalando-incubator/kube-metrics-adapter/pkg/api/generated/openapi \
|
||||
--output-file zz_generated.openapi.go \
|
||||
-r /dev/null \
|
||||
github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1 \
|
||||
k8s.io/metrics/pkg/apis/custom_metrics \
|
||||
k8s.io/metrics/pkg/apis/custom_metrics/v1beta1 \
|
||||
k8s.io/metrics/pkg/apis/custom_metrics/v1beta2 \
|
||||
|
||||
@@ -212,7 +212,9 @@ require (
|
||||
)
|
||||
|
||||
tool (
|
||||
github.com/zalando-incubator/kube-metrics-adapter/pkg/api/generated/openapi/cmd/models-schema
|
||||
k8s.io/code-generator
|
||||
k8s.io/code-generator/cmd/applyconfiguration-gen
|
||||
k8s.io/code-generator/cmd/client-gen
|
||||
k8s.io/code-generator/cmd/deepcopy-gen
|
||||
k8s.io/code-generator/cmd/informer-gen
|
||||
|
||||
+19
-1
@@ -37,6 +37,23 @@ go tool deepcopy-gen \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
"${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}"
|
||||
|
||||
APPLYCONFIG_PKG="${OUTPUT_PKG}/applyconfiguration"
|
||||
|
||||
echo "Generating apply configurations for ${GROUPS_WITH_VERSIONS} at ${APPLYCONFIG_PKG}"
|
||||
|
||||
# Generate the OpenAPI schema JSON to use for applyconfiguration-gen
|
||||
OPENAPI_SCHEMA_FILE=$(mktemp -t "openapi-schema-XXXXXX.json")
|
||||
trap 'rm -f ${OPENAPI_SCHEMA_FILE}' EXIT
|
||||
echo "Extracting OpenAPI schema to ${OPENAPI_SCHEMA_FILE}"
|
||||
go tool models-schema >"${OPENAPI_SCHEMA_FILE}"
|
||||
|
||||
go tool applyconfiguration-gen \
|
||||
--output-pkg "${APPLYCONFIG_PKG}" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-dir "${OUTPUT_DIR}/applyconfiguration" \
|
||||
--openapi-schema "${OPENAPI_SCHEMA_FILE}" \
|
||||
"${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}"
|
||||
|
||||
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}"
|
||||
go tool client-gen \
|
||||
--clientset-name versioned \
|
||||
@@ -44,7 +61,8 @@ go tool client-gen \
|
||||
--input "${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}" \
|
||||
--output-pkg "${OUTPUT_PKG}/clientset" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-dir "${OUTPUT_DIR}/clientset"
|
||||
--output-dir "${OUTPUT_DIR}/clientset" \
|
||||
--apply-configuration-package "${APPLYCONFIG_PKG}"
|
||||
|
||||
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
|
||||
go tool lister-gen \
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/zalando-incubator/kube-metrics-adapter/pkg/api/generated/openapi"
|
||||
"k8s.io/kube-openapi/pkg/common"
|
||||
"k8s.io/kube-openapi/pkg/validation/spec"
|
||||
)
|
||||
|
||||
// Outputs openAPI schema JSON containing the schema definitions in zz_generated.openapi.go.
|
||||
func main() {
|
||||
err := output()
|
||||
if err != nil {
|
||||
os.Stderr.WriteString(fmt.Sprintf("Failed: %v", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func output() error {
|
||||
refFunc := func(name string) spec.Ref {
|
||||
return spec.MustCreateRef(fmt.Sprintf("#/definitions/%s", name))
|
||||
}
|
||||
defs := openapi.GetOpenAPIDefinitions(refFunc)
|
||||
schemaDefs := make(map[string]spec.Schema, len(defs))
|
||||
for k, v := range defs {
|
||||
// Replace top-level schema with v2 if a v2 schema is embedded
|
||||
// so that the output of this program is always in OpenAPI v2.
|
||||
// This is done by looking up an extension that marks the embedded v2
|
||||
// schema, and, if the v2 schema is found, make it the resulting schema for
|
||||
// the type.
|
||||
if schema, ok := v.Schema.Extensions[common.ExtensionV2Schema]; ok {
|
||||
if v2Schema, isOpenAPISchema := schema.(spec.Schema); isOpenAPISchema {
|
||||
schemaDefs[k] = v2Schema
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
schemaDefs[k] = v.Schema
|
||||
}
|
||||
data, err := json.Marshal(&spec.Swagger{
|
||||
SwaggerProps: spec.SwaggerProps{
|
||||
Definitions: schemaDefs,
|
||||
Info: &spec.Info{
|
||||
InfoProps: spec.InfoProps{
|
||||
Title: "Kube Metrics Adapter",
|
||||
Version: "unversioned",
|
||||
},
|
||||
},
|
||||
Swagger: "2.0",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error serializing api definitions: %w", err)
|
||||
}
|
||||
os.Stdout.Write(data)
|
||||
return nil
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
|
||||
package v1
|
||||
@@ -1,5 +1,6 @@
|
||||
// Package v1 contains API Schema definitions for the zalando v1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=zalando.org
|
||||
package v1
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package v1
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
sync "sync"
|
||||
|
||||
typed "sigs.k8s.io/structured-merge-diff/v6/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: com.github.zalando-incubator.kube-metrics-adapter.pkg.apis.zalando.org.v1.ClusterScalingSchedule
|
||||
scalar: untyped
|
||||
list:
|
||||
elementType:
|
||||
namedType: __untyped_atomic_
|
||||
elementRelationship: atomic
|
||||
map:
|
||||
elementType:
|
||||
namedType: __untyped_deduced_
|
||||
elementRelationship: separable
|
||||
- name: com.github.zalando-incubator.kube-metrics-adapter.pkg.apis.zalando.org.v1.ScalingSchedule
|
||||
scalar: untyped
|
||||
list:
|
||||
elementType:
|
||||
namedType: __untyped_atomic_
|
||||
elementRelationship: atomic
|
||||
map:
|
||||
elementType:
|
||||
namedType: __untyped_deduced_
|
||||
elementRelationship: separable
|
||||
- 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
|
||||
`)
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package applyconfiguration
|
||||
|
||||
import (
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
internal "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/internal"
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/zalando.org/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
|
||||
)
|
||||
|
||||
// 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=zalando.org, Version=v1
|
||||
case v1.SchemeGroupVersion.WithKind("ClusterScalingSchedule"):
|
||||
return &zalandoorgv1.ClusterScalingScheduleApplyConfiguration{}
|
||||
case v1.SchemeGroupVersion.WithKind("ScalingSchedule"):
|
||||
return &zalandoorgv1.ScalingScheduleApplyConfiguration{}
|
||||
case v1.SchemeGroupVersion.WithKind("ScalingScheduleSpec"):
|
||||
return &zalandoorgv1.ScalingScheduleSpecApplyConfiguration{}
|
||||
case v1.SchemeGroupVersion.WithKind("ScalingScheduleStatus"):
|
||||
return &zalandoorgv1.ScalingScheduleStatusApplyConfiguration{}
|
||||
case v1.SchemeGroupVersion.WithKind("Schedule"):
|
||||
return &zalandoorgv1.ScheduleApplyConfiguration{}
|
||||
case v1.SchemeGroupVersion.WithKind("SchedulePeriod"):
|
||||
return &zalandoorgv1.SchedulePeriodApplyConfiguration{}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewTypeConverter(scheme *runtime.Scheme) managedfields.TypeConverter {
|
||||
return managedfields.NewSchemeTypeConverter(scheme, internal.Parser())
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
internal "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/internal"
|
||||
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
|
||||
metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
)
|
||||
|
||||
// ClusterScalingScheduleApplyConfiguration represents a declarative configuration of the ClusterScalingSchedule type for use
|
||||
// with apply.
|
||||
//
|
||||
// ClusterScalingSchedule describes a cluster scoped time based metric
|
||||
// to be used in autoscaling operations.
|
||||
type ClusterScalingScheduleApplyConfiguration struct {
|
||||
metav1.TypeMetaApplyConfiguration `json:",inline"`
|
||||
*metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||
Spec *ScalingScheduleSpecApplyConfiguration `json:"spec,omitempty"`
|
||||
Status *ScalingScheduleStatusApplyConfiguration `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// ClusterScalingSchedule constructs a declarative configuration of the ClusterScalingSchedule type for use with
|
||||
// apply.
|
||||
func ClusterScalingSchedule(name string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b := &ClusterScalingScheduleApplyConfiguration{}
|
||||
b.WithName(name)
|
||||
b.WithKind("ClusterScalingSchedule")
|
||||
b.WithAPIVersion("zalando.org/v1")
|
||||
return b
|
||||
}
|
||||
|
||||
// ExtractClusterScalingScheduleFrom extracts the applied configuration owned by fieldManager from
|
||||
// clusterScalingSchedule for the specified subresource. Pass an empty string for subresource to extract
|
||||
// the main resource. Common subresources include "status", "scale", etc.
|
||||
// clusterScalingSchedule must be a unmodified ClusterScalingSchedule API object that was retrieved from the Kubernetes API.
|
||||
// ExtractClusterScalingScheduleFrom provides a way to perform a extract/modify-in-place/apply workflow.
|
||||
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
|
||||
// applied if another fieldManager has updated or force applied any of the previously applied fields.
|
||||
func ExtractClusterScalingScheduleFrom(clusterScalingSchedule *zalandoorgv1.ClusterScalingSchedule, fieldManager string, subresource string) (*ClusterScalingScheduleApplyConfiguration, error) {
|
||||
b := &ClusterScalingScheduleApplyConfiguration{}
|
||||
err := managedfields.ExtractInto(clusterScalingSchedule, internal.Parser().Type("com.github.zalando-incubator.kube-metrics-adapter.pkg.apis.zalando.org.v1.ClusterScalingSchedule"), fieldManager, b, subresource)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.WithName(clusterScalingSchedule.Name)
|
||||
|
||||
b.WithKind("ClusterScalingSchedule")
|
||||
b.WithAPIVersion("zalando.org/v1")
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// ExtractClusterScalingSchedule extracts the applied configuration owned by fieldManager from
|
||||
// clusterScalingSchedule. If no managedFields are found in clusterScalingSchedule for fieldManager, a
|
||||
// ClusterScalingScheduleApplyConfiguration is returned with only the Name, Namespace (if applicable),
|
||||
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
|
||||
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
|
||||
// the fieldManager never owned fields any fields.
|
||||
// clusterScalingSchedule must be a unmodified ClusterScalingSchedule API object that was retrieved from the Kubernetes API.
|
||||
// ExtractClusterScalingSchedule provides a way to perform a extract/modify-in-place/apply workflow.
|
||||
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
|
||||
// applied if another fieldManager has updated or force applied any of the previously applied fields.
|
||||
func ExtractClusterScalingSchedule(clusterScalingSchedule *zalandoorgv1.ClusterScalingSchedule, fieldManager string) (*ClusterScalingScheduleApplyConfiguration, error) {
|
||||
return ExtractClusterScalingScheduleFrom(clusterScalingSchedule, fieldManager, "")
|
||||
}
|
||||
|
||||
// ExtractClusterScalingScheduleStatus extracts the applied configuration owned by fieldManager from
|
||||
// clusterScalingSchedule for the status subresource.
|
||||
func ExtractClusterScalingScheduleStatus(clusterScalingSchedule *zalandoorgv1.ClusterScalingSchedule, fieldManager string) (*ClusterScalingScheduleApplyConfiguration, error) {
|
||||
return ExtractClusterScalingScheduleFrom(clusterScalingSchedule, fieldManager, "status")
|
||||
}
|
||||
|
||||
func (b ClusterScalingScheduleApplyConfiguration) IsApplyConfiguration() {}
|
||||
|
||||
// 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 *ClusterScalingScheduleApplyConfiguration) WithKind(value string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithAPIVersion(value string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithName(value string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithGenerateName(value string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithNamespace(value string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithUID(value types.UID) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithResourceVersion(value string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithGeneration(value int64) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithLabels(entries map[string]string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithAnnotations(entries map[string]string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithOwnerReferences")
|
||||
}
|
||||
b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.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 *ClusterScalingScheduleApplyConfiguration) WithFinalizers(values ...string) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *ClusterScalingScheduleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||
if b.ObjectMetaApplyConfiguration == nil {
|
||||
b.ObjectMetaApplyConfiguration = &metav1.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 *ClusterScalingScheduleApplyConfiguration) WithSpec(value *ScalingScheduleSpecApplyConfiguration) *ClusterScalingScheduleApplyConfiguration {
|
||||
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 *ClusterScalingScheduleApplyConfiguration) WithStatus(value *ScalingScheduleStatusApplyConfiguration) *ClusterScalingScheduleApplyConfiguration {
|
||||
b.Status = value
|
||||
return b
|
||||
}
|
||||
|
||||
// GetKind retrieves the value of the Kind field in the declarative configuration.
|
||||
func (b *ClusterScalingScheduleApplyConfiguration) GetKind() *string {
|
||||
return b.TypeMetaApplyConfiguration.Kind
|
||||
}
|
||||
|
||||
// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration.
|
||||
func (b *ClusterScalingScheduleApplyConfiguration) GetAPIVersion() *string {
|
||||
return b.TypeMetaApplyConfiguration.APIVersion
|
||||
}
|
||||
|
||||
// GetName retrieves the value of the Name field in the declarative configuration.
|
||||
func (b *ClusterScalingScheduleApplyConfiguration) GetName() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Name
|
||||
}
|
||||
|
||||
// GetNamespace retrieves the value of the Namespace field in the declarative configuration.
|
||||
func (b *ClusterScalingScheduleApplyConfiguration) GetNamespace() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Namespace
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
internal "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/internal"
|
||||
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
|
||||
metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
)
|
||||
|
||||
// ScalingScheduleApplyConfiguration represents a declarative configuration of the ScalingSchedule type for use
|
||||
// with apply.
|
||||
//
|
||||
// ScalingSchedule describes a namespaced time based metric to be used
|
||||
// in autoscaling operations.
|
||||
type ScalingScheduleApplyConfiguration struct {
|
||||
metav1.TypeMetaApplyConfiguration `json:",inline"`
|
||||
*metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||
Spec *ScalingScheduleSpecApplyConfiguration `json:"spec,omitempty"`
|
||||
Status *ScalingScheduleStatusApplyConfiguration `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// ScalingSchedule constructs a declarative configuration of the ScalingSchedule type for use with
|
||||
// apply.
|
||||
func ScalingSchedule(name, namespace string) *ScalingScheduleApplyConfiguration {
|
||||
b := &ScalingScheduleApplyConfiguration{}
|
||||
b.WithName(name)
|
||||
b.WithNamespace(namespace)
|
||||
b.WithKind("ScalingSchedule")
|
||||
b.WithAPIVersion("zalando.org/v1")
|
||||
return b
|
||||
}
|
||||
|
||||
// ExtractScalingScheduleFrom extracts the applied configuration owned by fieldManager from
|
||||
// scalingSchedule for the specified subresource. Pass an empty string for subresource to extract
|
||||
// the main resource. Common subresources include "status", "scale", etc.
|
||||
// scalingSchedule must be a unmodified ScalingSchedule API object that was retrieved from the Kubernetes API.
|
||||
// ExtractScalingScheduleFrom provides a way to perform a extract/modify-in-place/apply workflow.
|
||||
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
|
||||
// applied if another fieldManager has updated or force applied any of the previously applied fields.
|
||||
func ExtractScalingScheduleFrom(scalingSchedule *zalandoorgv1.ScalingSchedule, fieldManager string, subresource string) (*ScalingScheduleApplyConfiguration, error) {
|
||||
b := &ScalingScheduleApplyConfiguration{}
|
||||
err := managedfields.ExtractInto(scalingSchedule, internal.Parser().Type("com.github.zalando-incubator.kube-metrics-adapter.pkg.apis.zalando.org.v1.ScalingSchedule"), fieldManager, b, subresource)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.WithName(scalingSchedule.Name)
|
||||
b.WithNamespace(scalingSchedule.Namespace)
|
||||
|
||||
b.WithKind("ScalingSchedule")
|
||||
b.WithAPIVersion("zalando.org/v1")
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// ExtractScalingSchedule extracts the applied configuration owned by fieldManager from
|
||||
// scalingSchedule. If no managedFields are found in scalingSchedule for fieldManager, a
|
||||
// ScalingScheduleApplyConfiguration is returned with only the Name, Namespace (if applicable),
|
||||
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
|
||||
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
|
||||
// the fieldManager never owned fields any fields.
|
||||
// scalingSchedule must be a unmodified ScalingSchedule API object that was retrieved from the Kubernetes API.
|
||||
// ExtractScalingSchedule provides a way to perform a extract/modify-in-place/apply workflow.
|
||||
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
|
||||
// applied if another fieldManager has updated or force applied any of the previously applied fields.
|
||||
func ExtractScalingSchedule(scalingSchedule *zalandoorgv1.ScalingSchedule, fieldManager string) (*ScalingScheduleApplyConfiguration, error) {
|
||||
return ExtractScalingScheduleFrom(scalingSchedule, fieldManager, "")
|
||||
}
|
||||
|
||||
// ExtractScalingScheduleStatus extracts the applied configuration owned by fieldManager from
|
||||
// scalingSchedule for the status subresource.
|
||||
func ExtractScalingScheduleStatus(scalingSchedule *zalandoorgv1.ScalingSchedule, fieldManager string) (*ScalingScheduleApplyConfiguration, error) {
|
||||
return ExtractScalingScheduleFrom(scalingSchedule, fieldManager, "status")
|
||||
}
|
||||
|
||||
func (b ScalingScheduleApplyConfiguration) IsApplyConfiguration() {}
|
||||
|
||||
// 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 *ScalingScheduleApplyConfiguration) WithKind(value string) *ScalingScheduleApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithAPIVersion(value string) *ScalingScheduleApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithName(value string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithGenerateName(value string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithNamespace(value string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithUID(value types.UID) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithResourceVersion(value string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithGeneration(value int64) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithLabels(entries map[string]string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithAnnotations(entries map[string]string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithOwnerReferences")
|
||||
}
|
||||
b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.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 *ScalingScheduleApplyConfiguration) WithFinalizers(values ...string) *ScalingScheduleApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *ScalingScheduleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||
if b.ObjectMetaApplyConfiguration == nil {
|
||||
b.ObjectMetaApplyConfiguration = &metav1.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 *ScalingScheduleApplyConfiguration) WithSpec(value *ScalingScheduleSpecApplyConfiguration) *ScalingScheduleApplyConfiguration {
|
||||
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 *ScalingScheduleApplyConfiguration) WithStatus(value *ScalingScheduleStatusApplyConfiguration) *ScalingScheduleApplyConfiguration {
|
||||
b.Status = value
|
||||
return b
|
||||
}
|
||||
|
||||
// GetKind retrieves the value of the Kind field in the declarative configuration.
|
||||
func (b *ScalingScheduleApplyConfiguration) GetKind() *string {
|
||||
return b.TypeMetaApplyConfiguration.Kind
|
||||
}
|
||||
|
||||
// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration.
|
||||
func (b *ScalingScheduleApplyConfiguration) GetAPIVersion() *string {
|
||||
return b.TypeMetaApplyConfiguration.APIVersion
|
||||
}
|
||||
|
||||
// GetName retrieves the value of the Name field in the declarative configuration.
|
||||
func (b *ScalingScheduleApplyConfiguration) GetName() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Name
|
||||
}
|
||||
|
||||
// GetNamespace retrieves the value of the Namespace field in the declarative configuration.
|
||||
func (b *ScalingScheduleApplyConfiguration) GetNamespace() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Namespace
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
// ScalingScheduleSpecApplyConfiguration represents a declarative configuration of the ScalingScheduleSpec type for use
|
||||
// with apply.
|
||||
//
|
||||
// ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
type ScalingScheduleSpecApplyConfiguration struct {
|
||||
// Fade the scheduled values in and out over this many minutes. If unset, the default per-cluster value will be used.
|
||||
ScalingWindowDurationMinutes *int64 `json:"scalingWindowDurationMinutes,omitempty"`
|
||||
// Schedules is the list of schedules for this ScalingSchedule
|
||||
// resource. All the schedules defined here will result on the value
|
||||
// to the same metric. New metrics require a new ScalingSchedule
|
||||
// resource.
|
||||
Schedules []ScheduleApplyConfiguration `json:"schedules,omitempty"`
|
||||
}
|
||||
|
||||
// ScalingScheduleSpecApplyConfiguration constructs a declarative configuration of the ScalingScheduleSpec type for use with
|
||||
// apply.
|
||||
func ScalingScheduleSpec() *ScalingScheduleSpecApplyConfiguration {
|
||||
return &ScalingScheduleSpecApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithScalingWindowDurationMinutes sets the ScalingWindowDurationMinutes 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 ScalingWindowDurationMinutes field is set to the value of the last call.
|
||||
func (b *ScalingScheduleSpecApplyConfiguration) WithScalingWindowDurationMinutes(value int64) *ScalingScheduleSpecApplyConfiguration {
|
||||
b.ScalingWindowDurationMinutes = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithSchedules adds the given value to the Schedules 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 Schedules field.
|
||||
func (b *ScalingScheduleSpecApplyConfiguration) WithSchedules(values ...*ScheduleApplyConfiguration) *ScalingScheduleSpecApplyConfiguration {
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithSchedules")
|
||||
}
|
||||
b.Schedules = append(b.Schedules, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
// ScalingScheduleStatusApplyConfiguration represents a declarative configuration of the ScalingScheduleStatus type for use
|
||||
// with apply.
|
||||
//
|
||||
// ScalingScheduleStatus is the status section of the ScalingSchedule.
|
||||
type ScalingScheduleStatusApplyConfiguration struct {
|
||||
// Active is true if at least one of the schedules defined in the
|
||||
// scaling schedule is currently active.
|
||||
Active *bool `json:"active,omitempty"`
|
||||
}
|
||||
|
||||
// ScalingScheduleStatusApplyConfiguration constructs a declarative configuration of the ScalingScheduleStatus type for use with
|
||||
// apply.
|
||||
func ScalingScheduleStatus() *ScalingScheduleStatusApplyConfiguration {
|
||||
return &ScalingScheduleStatusApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithActive sets the Active 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 Active field is set to the value of the last call.
|
||||
func (b *ScalingScheduleStatusApplyConfiguration) WithActive(value bool) *ScalingScheduleStatusApplyConfiguration {
|
||||
b.Active = &value
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
)
|
||||
|
||||
// ScheduleApplyConfiguration represents a declarative configuration of the Schedule type for use
|
||||
// with apply.
|
||||
//
|
||||
// Schedule is the schedule details to be used inside a ScalingSchedule.
|
||||
type ScheduleApplyConfiguration struct {
|
||||
Type *zalandoorgv1.ScheduleType `json:"type,omitempty"`
|
||||
// Defines the details of a Repeating schedule.
|
||||
Period *SchedulePeriodApplyConfiguration `json:"period,omitempty"`
|
||||
// Defines the starting date of a OneTime schedule. It has to
|
||||
// be a RFC3339 formatted date.
|
||||
Date *zalandoorgv1.ScheduleDate `json:"date,omitempty"`
|
||||
// Defines the ending date of a OneTime schedule. It must be
|
||||
// a RFC3339 formatted date.
|
||||
EndDate *zalandoorgv1.ScheduleDate `json:"endDate,omitempty"`
|
||||
// The duration in minutes (default 0) that the configured value will be
|
||||
// returned for the defined schedule.
|
||||
DurationMinutes *int `json:"durationMinutes,omitempty"`
|
||||
// The metric value that will be returned for the defined schedule.
|
||||
Value *int64 `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ScheduleApplyConfiguration constructs a declarative configuration of the Schedule type for use with
|
||||
// apply.
|
||||
func Schedule() *ScheduleApplyConfiguration {
|
||||
return &ScheduleApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithType sets the Type field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Type field is set to the value of the last call.
|
||||
func (b *ScheduleApplyConfiguration) WithType(value zalandoorgv1.ScheduleType) *ScheduleApplyConfiguration {
|
||||
b.Type = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithPeriod sets the Period 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 Period field is set to the value of the last call.
|
||||
func (b *ScheduleApplyConfiguration) WithPeriod(value *SchedulePeriodApplyConfiguration) *ScheduleApplyConfiguration {
|
||||
b.Period = value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDate sets the Date 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 Date field is set to the value of the last call.
|
||||
func (b *ScheduleApplyConfiguration) WithDate(value zalandoorgv1.ScheduleDate) *ScheduleApplyConfiguration {
|
||||
b.Date = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithEndDate sets the EndDate 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 EndDate field is set to the value of the last call.
|
||||
func (b *ScheduleApplyConfiguration) WithEndDate(value zalandoorgv1.ScheduleDate) *ScheduleApplyConfiguration {
|
||||
b.EndDate = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDurationMinutes sets the DurationMinutes 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 DurationMinutes field is set to the value of the last call.
|
||||
func (b *ScheduleApplyConfiguration) WithDurationMinutes(value int) *ScheduleApplyConfiguration {
|
||||
b.DurationMinutes = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithValue sets the Value 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 Value field is set to the value of the last call.
|
||||
func (b *ScheduleApplyConfiguration) WithValue(value int64) *ScheduleApplyConfiguration {
|
||||
b.Value = &value
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
)
|
||||
|
||||
// SchedulePeriodApplyConfiguration represents a declarative configuration of the SchedulePeriod type for use
|
||||
// with apply.
|
||||
//
|
||||
// SchedulePeriod is the details to be used for a Schedule of the
|
||||
// Repeating type.
|
||||
type SchedulePeriodApplyConfiguration struct {
|
||||
// The startTime has the format HH:MM
|
||||
StartTime *string `json:"startTime,omitempty"`
|
||||
// The endTime has the format HH:MM
|
||||
EndTime *string `json:"endTime,omitempty"`
|
||||
// The days that this schedule will be active.
|
||||
Days []zalandoorgv1.ScheduleDay `json:"days,omitempty"`
|
||||
// The location name corresponding to a file in the IANA
|
||||
// Time Zone database, like Europe/Berlin.
|
||||
Timezone *string `json:"timezone,omitempty"`
|
||||
}
|
||||
|
||||
// SchedulePeriodApplyConfiguration constructs a declarative configuration of the SchedulePeriod type for use with
|
||||
// apply.
|
||||
func SchedulePeriod() *SchedulePeriodApplyConfiguration {
|
||||
return &SchedulePeriodApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithStartTime sets the StartTime 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 StartTime field is set to the value of the last call.
|
||||
func (b *SchedulePeriodApplyConfiguration) WithStartTime(value string) *SchedulePeriodApplyConfiguration {
|
||||
b.StartTime = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithEndTime sets the EndTime 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 EndTime field is set to the value of the last call.
|
||||
func (b *SchedulePeriodApplyConfiguration) WithEndTime(value string) *SchedulePeriodApplyConfiguration {
|
||||
b.EndTime = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDays adds the given value to the Days 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 Days field.
|
||||
func (b *SchedulePeriodApplyConfiguration) WithDays(values ...zalandoorgv1.ScheduleDay) *SchedulePeriodApplyConfiguration {
|
||||
for i := range values {
|
||||
b.Days = append(b.Days, values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithTimezone sets the Timezone 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 Timezone field is set to the value of the last call.
|
||||
func (b *SchedulePeriodApplyConfiguration) WithTimezone(value string) *SchedulePeriodApplyConfiguration {
|
||||
b.Timezone = &value
|
||||
return b
|
||||
}
|
||||
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
package fake
|
||||
|
||||
import (
|
||||
applyconfiguration "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration"
|
||||
clientset "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned"
|
||||
zalandov1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1"
|
||||
fakezalandov1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1/fake"
|
||||
@@ -94,6 +95,42 @@ func (c *Clientset) IsWatchListSemanticsUnSupported() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// NewClientset 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 NewClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewFieldManagedObjectTracker(
|
||||
scheme,
|
||||
codecs.UniversalDecoder(),
|
||||
applyconfiguration.NewTypeConverter(scheme),
|
||||
)
|
||||
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) {
|
||||
var opts metav1.ListOptions
|
||||
if watchAction, ok := action.(testing.WatchActionImpl); ok {
|
||||
opts = watchAction.ListOptions
|
||||
}
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns, opts)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return cs
|
||||
}
|
||||
|
||||
var (
|
||||
_ clientset.Interface = &Clientset{}
|
||||
_ testing.FakeClient = &Clientset{}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
context "context"
|
||||
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
applyconfigurationzalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/zalando.org/v1"
|
||||
scheme "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/scheme"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
@@ -47,18 +48,21 @@ type ClusterScalingScheduleInterface interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*zalandoorgv1.ClusterScalingScheduleList, error)
|
||||
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
|
||||
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *zalandoorgv1.ClusterScalingSchedule, err error)
|
||||
Apply(ctx context.Context, clusterScalingSchedule *applyconfigurationzalandoorgv1.ClusterScalingScheduleApplyConfiguration, opts metav1.ApplyOptions) (result *zalandoorgv1.ClusterScalingSchedule, err error)
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
ApplyStatus(ctx context.Context, clusterScalingSchedule *applyconfigurationzalandoorgv1.ClusterScalingScheduleApplyConfiguration, opts metav1.ApplyOptions) (result *zalandoorgv1.ClusterScalingSchedule, err error)
|
||||
ClusterScalingScheduleExpansion
|
||||
}
|
||||
|
||||
// clusterScalingSchedules implements ClusterScalingScheduleInterface
|
||||
type clusterScalingSchedules struct {
|
||||
*gentype.ClientWithList[*zalandoorgv1.ClusterScalingSchedule, *zalandoorgv1.ClusterScalingScheduleList]
|
||||
*gentype.ClientWithListAndApply[*zalandoorgv1.ClusterScalingSchedule, *zalandoorgv1.ClusterScalingScheduleList, *applyconfigurationzalandoorgv1.ClusterScalingScheduleApplyConfiguration]
|
||||
}
|
||||
|
||||
// newClusterScalingSchedules returns a ClusterScalingSchedules
|
||||
func newClusterScalingSchedules(c *ZalandoV1Client) *clusterScalingSchedules {
|
||||
return &clusterScalingSchedules{
|
||||
gentype.NewClientWithList[*zalandoorgv1.ClusterScalingSchedule, *zalandoorgv1.ClusterScalingScheduleList](
|
||||
gentype.NewClientWithListAndApply[*zalandoorgv1.ClusterScalingSchedule, *zalandoorgv1.ClusterScalingScheduleList, *applyconfigurationzalandoorgv1.ClusterScalingScheduleApplyConfiguration](
|
||||
"clusterscalingschedules",
|
||||
c.RESTClient(),
|
||||
scheme.ParameterCodec,
|
||||
|
||||
+5
-4
@@ -20,19 +20,20 @@ package fake
|
||||
|
||||
import (
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1"
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/zalando.org/v1"
|
||||
typedzalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
)
|
||||
|
||||
// fakeClusterScalingSchedules implements ClusterScalingScheduleInterface
|
||||
type fakeClusterScalingSchedules struct {
|
||||
*gentype.FakeClientWithList[*v1.ClusterScalingSchedule, *v1.ClusterScalingScheduleList]
|
||||
*gentype.FakeClientWithListAndApply[*v1.ClusterScalingSchedule, *v1.ClusterScalingScheduleList, *zalandoorgv1.ClusterScalingScheduleApplyConfiguration]
|
||||
Fake *FakeZalandoV1
|
||||
}
|
||||
|
||||
func newFakeClusterScalingSchedules(fake *FakeZalandoV1) zalandoorgv1.ClusterScalingScheduleInterface {
|
||||
func newFakeClusterScalingSchedules(fake *FakeZalandoV1) typedzalandoorgv1.ClusterScalingScheduleInterface {
|
||||
return &fakeClusterScalingSchedules{
|
||||
gentype.NewFakeClientWithList[*v1.ClusterScalingSchedule, *v1.ClusterScalingScheduleList](
|
||||
gentype.NewFakeClientWithListAndApply[*v1.ClusterScalingSchedule, *v1.ClusterScalingScheduleList, *zalandoorgv1.ClusterScalingScheduleApplyConfiguration](
|
||||
fake.Fake,
|
||||
"",
|
||||
v1.SchemeGroupVersion.WithResource("clusterscalingschedules"),
|
||||
|
||||
@@ -20,19 +20,20 @@ package fake
|
||||
|
||||
import (
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1"
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/zalando.org/v1"
|
||||
typedzalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
)
|
||||
|
||||
// fakeScalingSchedules implements ScalingScheduleInterface
|
||||
type fakeScalingSchedules struct {
|
||||
*gentype.FakeClientWithList[*v1.ScalingSchedule, *v1.ScalingScheduleList]
|
||||
*gentype.FakeClientWithListAndApply[*v1.ScalingSchedule, *v1.ScalingScheduleList, *zalandoorgv1.ScalingScheduleApplyConfiguration]
|
||||
Fake *FakeZalandoV1
|
||||
}
|
||||
|
||||
func newFakeScalingSchedules(fake *FakeZalandoV1, namespace string) zalandoorgv1.ScalingScheduleInterface {
|
||||
func newFakeScalingSchedules(fake *FakeZalandoV1, namespace string) typedzalandoorgv1.ScalingScheduleInterface {
|
||||
return &fakeScalingSchedules{
|
||||
gentype.NewFakeClientWithList[*v1.ScalingSchedule, *v1.ScalingScheduleList](
|
||||
gentype.NewFakeClientWithListAndApply[*v1.ScalingSchedule, *v1.ScalingScheduleList, *zalandoorgv1.ScalingScheduleApplyConfiguration](
|
||||
fake.Fake,
|
||||
namespace,
|
||||
v1.SchemeGroupVersion.WithResource("scalingschedules"),
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
context "context"
|
||||
|
||||
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
applyconfigurationzalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/applyconfiguration/zalando.org/v1"
|
||||
scheme "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/scheme"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
@@ -47,18 +48,21 @@ type ScalingScheduleInterface interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*zalandoorgv1.ScalingScheduleList, error)
|
||||
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
|
||||
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *zalandoorgv1.ScalingSchedule, err error)
|
||||
Apply(ctx context.Context, scalingSchedule *applyconfigurationzalandoorgv1.ScalingScheduleApplyConfiguration, opts metav1.ApplyOptions) (result *zalandoorgv1.ScalingSchedule, err error)
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
ApplyStatus(ctx context.Context, scalingSchedule *applyconfigurationzalandoorgv1.ScalingScheduleApplyConfiguration, opts metav1.ApplyOptions) (result *zalandoorgv1.ScalingSchedule, err error)
|
||||
ScalingScheduleExpansion
|
||||
}
|
||||
|
||||
// scalingSchedules implements ScalingScheduleInterface
|
||||
type scalingSchedules struct {
|
||||
*gentype.ClientWithList[*zalandoorgv1.ScalingSchedule, *zalandoorgv1.ScalingScheduleList]
|
||||
*gentype.ClientWithListAndApply[*zalandoorgv1.ScalingSchedule, *zalandoorgv1.ScalingScheduleList, *applyconfigurationzalandoorgv1.ScalingScheduleApplyConfiguration]
|
||||
}
|
||||
|
||||
// newScalingSchedules returns a ScalingSchedules
|
||||
func newScalingSchedules(c *ZalandoV1Client, namespace string) *scalingSchedules {
|
||||
return &scalingSchedules{
|
||||
gentype.NewClientWithList[*zalandoorgv1.ScalingSchedule, *zalandoorgv1.ScalingScheduleList](
|
||||
gentype.NewClientWithListAndApply[*zalandoorgv1.ScalingSchedule, *zalandoorgv1.ScalingScheduleList, *applyconfigurationzalandoorgv1.ScalingScheduleApplyConfiguration](
|
||||
"scalingschedules",
|
||||
c.RESTClient(),
|
||||
scheme.ParameterCodec,
|
||||
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
)
|
||||
|
||||
func TestTargetRefReplicasDeployments(t *testing.T) {
|
||||
client := fake.NewSimpleClientset()
|
||||
client := fake.NewClientset()
|
||||
name := "some-app"
|
||||
defaultNamespace := "default"
|
||||
deployment, err := newDeployment(client, defaultNamespace, name, 2, 1)
|
||||
@@ -44,7 +44,7 @@ func TestTargetRefReplicasDeployments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTargetRefReplicasStatefulSets(t *testing.T) {
|
||||
client := fake.NewSimpleClientset()
|
||||
client := fake.NewClientset()
|
||||
name := "some-app"
|
||||
defaultNamespace := "default"
|
||||
statefulSet, err := newStatefulSet(client, defaultNamespace, name)
|
||||
@@ -330,7 +330,7 @@ func TestSkipperCollectorIngress(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.msg, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset()
|
||||
client := fake.NewClientset()
|
||||
err := makeIngress(client, tc.namespace, tc.resourceName, tc.backend, tc.hostnames, tc.backendWeights)
|
||||
require.NoError(t, err)
|
||||
hpa := makeIngressHPA(tc.namespace, tc.resourceName, tc.backend)
|
||||
@@ -502,7 +502,7 @@ func TestSkipperCollector(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.msg, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset()
|
||||
client := fake.NewClientset()
|
||||
backendWeights := make(map[string]map[string]float64)
|
||||
if len(tc.backendWeights) > 0 {
|
||||
backendWeights = map[string]map[string]float64{testBackendWeightsAnnotation: tc.backendWeights}
|
||||
|
||||
@@ -217,7 +217,7 @@ func TestRunOnce(t *testing.T) {
|
||||
} {
|
||||
t.Run(tc.msg, func(t *testing.T) {
|
||||
// setup fake client and cache
|
||||
client := scalingschedulefake.NewSimpleClientset()
|
||||
client := scalingschedulefake.NewClientset()
|
||||
|
||||
clusterScalingSchedulesStore := fakeClusterScalingScheduleStore{
|
||||
client: client.ZalandoV1(),
|
||||
@@ -231,7 +231,7 @@ func TestRunOnce(t *testing.T) {
|
||||
err := applySchedules(client.ZalandoV1(), tc.schedules)
|
||||
require.NoError(t, err)
|
||||
|
||||
controller := NewController(client.ZalandoV1(), fake.NewSimpleClientset(), nil, scalingSchedulesStore, clusterScalingSchedulesStore, now, 0, "Europe/Berlin", 0.10)
|
||||
controller := NewController(client.ZalandoV1(), fake.NewClientset(), nil, scalingSchedulesStore, clusterScalingSchedulesStore, now, 0, "Europe/Berlin", 0.10)
|
||||
|
||||
err = controller.runOnce(context.Background())
|
||||
require.NoError(t, err)
|
||||
@@ -376,8 +376,8 @@ func TestAdjustScaling(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.msg, func(t *testing.T) {
|
||||
kubeClient := fake.NewSimpleClientset()
|
||||
scalingScheduleClient := zfake.NewSimpleClientset()
|
||||
kubeClient := fake.NewClientset()
|
||||
scalingScheduleClient := zfake.NewClientset()
|
||||
controller := NewController(
|
||||
scalingScheduleClient.ZalandoV1(),
|
||||
kubeClient,
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestUpdateHPAs(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fakeClient := fake.NewSimpleClientset()
|
||||
fakeClient := fake.NewClientset()
|
||||
|
||||
var err error
|
||||
hpa, err = fakeClient.AutoscalingV2().HorizontalPodAutoscalers("default").Create(context.TODO(), hpa, metav1.CreateOptions{})
|
||||
@@ -160,7 +160,7 @@ func TestUpdateHPAsDisregardingIncompatibleHPA(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fakeClient := fake.NewSimpleClientset()
|
||||
fakeClient := fake.NewClientset()
|
||||
|
||||
var err error
|
||||
_, err = fakeClient.AutoscalingV2().HorizontalPodAutoscalers("default").Create(context.TODO(), hpa, metav1.CreateOptions{})
|
||||
|
||||
Reference in New Issue
Block a user