diff --git a/pkg/generated/openapi/cmd/models-schema/main.go b/pkg/generated/openapi/cmd/models-schema/main.go index e3ca808c8e4..b20af94271d 100644 --- a/pkg/generated/openapi/cmd/models-schema/main.go +++ b/pkg/generated/openapi/cmd/models-schema/main.go @@ -30,7 +30,7 @@ import ( func main() { err := output() if err != nil { - os.Stderr.WriteString(fmt.Sprintf("Failed: %v", err)) + os.Stderr.WriteString(fmt.Sprintf("Failed: %v", err)) // nolint:errcheck os.Exit(1) } } @@ -71,6 +71,6 @@ func output() error { if err != nil { return fmt.Errorf("error serializing api definitions: %w", err) } - os.Stdout.Write(data) + os.Stdout.Write(data) // nolint:errcheck return nil } diff --git a/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh b/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh index ff703db8c9c..2604260c8fe 100755 --- a/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh +++ b/staging/src/k8s.io/kube-aggregator/hack/update-codegen.sh @@ -47,6 +47,8 @@ kube::codegen::gen_openapi \ kube::codegen::gen_client \ --with-watch \ + --with-applyconfig \ + --applyconfig-openapi-schema <(go run k8s.io/kube-aggregator/pkg/generated/openapi/cmd/models-schema) \ --output-dir "${SCRIPT_ROOT}/pkg/client" \ --output-pkg "${THIS_PKG}/pkg/client" \ --clientset-name "clientset_generated" \ diff --git a/staging/src/k8s.io/kube-aggregator/hack/verify-codegen.sh b/staging/src/k8s.io/kube-aggregator/hack/verify-codegen.sh index e462569bac0..305cf506de5 100755 --- a/staging/src/k8s.io/kube-aggregator/hack/verify-codegen.sh +++ b/staging/src/k8s.io/kube-aggregator/hack/verify-codegen.sh @@ -29,6 +29,19 @@ trap "cleanup" EXIT SIGINT cleanup +# Ensure model-schema generator matches the version from +# k8s.io/kubernetes/pkg/generated/openapi/cmd/models-schema/main.go +echo "Ensuring models-schema is up-to-date" +K8S_MODELS_SCHEMA="${SCRIPT_ROOT}/../../../../pkg/generated/openapi/cmd/models-schema/main.go" +KUBE_AGGREGATOR_MODELS_SCHEMA="${SCRIPT_ROOT}/pkg/generated/openapi/cmd/models-schema/main.go" +# these two files will only differ in the imported lines for generated openapi +if ! diff -I "k8s.io/kubernetes/pkg/generated/openapi" \ + -I "k8s.io/kube-aggregator/pkg/generated/openapi" \ + "${K8S_MODELS_SCHEMA}" "${KUBE_AGGREGATOR_MODELS_SCHEMA}"; then + echo "${KUBE_AGGREGATOR_MODELS_SCHEMA} is out of date. Compare changes with ${K8S_MODELS_SCHEMA}" + exit 1 +fi + mkdir -p "${TMP_DIFFROOT}" cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservice.go new file mode 100644 index 00000000000..7ed5fa11333 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservice.go @@ -0,0 +1,292 @@ +/* +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 ( + 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" + apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" + internal "k8s.io/kube-aggregator/pkg/client/applyconfiguration/internal" +) + +// APIServiceApplyConfiguration represents a declarative configuration of the APIService type for use +// with apply. +// +// APIService represents a server for a particular GroupVersion. +// Name must be "version.group". +type APIServiceApplyConfiguration struct { + metav1.TypeMetaApplyConfiguration `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + // Spec contains information for locating and communicating with a server + Spec *APIServiceSpecApplyConfiguration `json:"spec,omitempty"` + // Status contains derived information about an API server + Status *APIServiceStatusApplyConfiguration `json:"status,omitempty"` +} + +// APIService constructs a declarative configuration of the APIService type for use with +// apply. +func APIService(name string) *APIServiceApplyConfiguration { + b := &APIServiceApplyConfiguration{} + b.WithName(name) + b.WithKind("APIService") + b.WithAPIVersion("apiregistration.k8s.io/v1") + return b +} + +// ExtractAPIServiceFrom extracts the applied configuration owned by fieldManager from +// aPIService for the specified subresource. Pass an empty string for subresource to extract +// the main resource. Common subresources include "status", "scale", etc. +// aPIService must be a unmodified APIService API object that was retrieved from the Kubernetes API. +// ExtractAPIServiceFrom 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 ExtractAPIServiceFrom(aPIService *apiregistrationv1.APIService, fieldManager string, subresource string) (*APIServiceApplyConfiguration, error) { + b := &APIServiceApplyConfiguration{} + err := managedfields.ExtractInto(aPIService, internal.Parser().Type("io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIService"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(aPIService.Name) + + b.WithKind("APIService") + b.WithAPIVersion("apiregistration.k8s.io/v1") + return b, nil +} + +// ExtractAPIService extracts the applied configuration owned by fieldManager from +// aPIService. If no managedFields are found in aPIService for fieldManager, a +// APIServiceApplyConfiguration 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. +// aPIService must be a unmodified APIService API object that was retrieved from the Kubernetes API. +// ExtractAPIService 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 ExtractAPIService(aPIService *apiregistrationv1.APIService, fieldManager string) (*APIServiceApplyConfiguration, error) { + return ExtractAPIServiceFrom(aPIService, fieldManager, "") +} + +// ExtractAPIServiceStatus extracts the applied configuration owned by fieldManager from +// aPIService for the status subresource. +func ExtractAPIServiceStatus(aPIService *apiregistrationv1.APIService, fieldManager string) (*APIServiceApplyConfiguration, error) { + return ExtractAPIServiceFrom(aPIService, fieldManager, "status") +} + +func (b APIServiceApplyConfiguration) 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 *APIServiceApplyConfiguration) WithKind(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithAPIVersion(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithName(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithGenerateName(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithNamespace(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithUID(value types.UID) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithResourceVersion(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithGeneration(value int64) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithLabels(entries map[string]string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithAnnotations(entries map[string]string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithFinalizers(values ...string) *APIServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *APIServiceApplyConfiguration) 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 *APIServiceApplyConfiguration) WithSpec(value *APIServiceSpecApplyConfiguration) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithStatus(value *APIServiceStatusApplyConfiguration) *APIServiceApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicecondition.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicecondition.go new file mode 100644 index 00000000000..e7255009b8c --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicecondition.go @@ -0,0 +1,88 @@ +/* +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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" +) + +// APIServiceConditionApplyConfiguration represents a declarative configuration of the APIServiceCondition type for use +// with apply. +// +// APIServiceCondition describes the state of an APIService at a particular point +type APIServiceConditionApplyConfiguration struct { + // Type is the type of the condition. + Type *apiregistrationv1.APIServiceConditionType `json:"type,omitempty"` + // Status is the status of the condition. + // Can be True, False, Unknown. + Status *apiregistrationv1.ConditionStatus `json:"status,omitempty"` + // Last time the condition transitioned from one status to another. + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` + // Unique, one-word, CamelCase reason for the condition's last transition. + Reason *string `json:"reason,omitempty"` + // Human-readable message indicating details about last transition. + Message *string `json:"message,omitempty"` +} + +// APIServiceConditionApplyConfiguration constructs a declarative configuration of the APIServiceCondition type for use with +// apply. +func APIServiceCondition() *APIServiceConditionApplyConfiguration { + return &APIServiceConditionApplyConfiguration{} +} + +// 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 *APIServiceConditionApplyConfiguration) WithType(value apiregistrationv1.APIServiceConditionType) *APIServiceConditionApplyConfiguration { + b.Type = &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 *APIServiceConditionApplyConfiguration) WithStatus(value apiregistrationv1.ConditionStatus) *APIServiceConditionApplyConfiguration { + b.Status = &value + return b +} + +// WithLastTransitionTime sets the LastTransitionTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastTransitionTime field is set to the value of the last call. +func (b *APIServiceConditionApplyConfiguration) WithLastTransitionTime(value metav1.Time) *APIServiceConditionApplyConfiguration { + b.LastTransitionTime = &value + return b +} + +// WithReason sets the Reason field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Reason field is set to the value of the last call. +func (b *APIServiceConditionApplyConfiguration) WithReason(value string) *APIServiceConditionApplyConfiguration { + b.Reason = &value + return b +} + +// WithMessage sets the Message field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Message field is set to the value of the last call. +func (b *APIServiceConditionApplyConfiguration) WithMessage(value string) *APIServiceConditionApplyConfiguration { + b.Message = &value + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicespec.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicespec.go new file mode 100644 index 00000000000..074ff08f851 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicespec.go @@ -0,0 +1,124 @@ +/* +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 + +// APIServiceSpecApplyConfiguration represents a declarative configuration of the APIServiceSpec type for use +// with apply. +// +// APIServiceSpec contains information for locating and communicating with a server. +// Only https is supported, though you are able to disable certificate verification. +type APIServiceSpecApplyConfiguration struct { + // Service is a reference to the service for this API server. It must communicate + // on port 443. + // If the Service is nil, that means the handling for the API groupversion is handled locally on this server. + // The call will simply delegate to the normal handler chain to be fulfilled. + Service *ServiceReferenceApplyConfiguration `json:"service,omitempty"` + // Group is the API group name this server hosts + Group *string `json:"group,omitempty"` + // Version is the API version this server hosts. For example, "v1" + Version *string `json:"version,omitempty"` + // InsecureSkipTLSVerify disables TLS certificate verification when communicating with this server. + // This is strongly discouraged. You should use the CABundle instead. + InsecureSkipTLSVerify *bool `json:"insecureSkipTLSVerify,omitempty"` + // CABundle is a PEM encoded CA bundle which will be used to validate an API server's serving certificate. + // If unspecified, system trust roots on the apiserver are used. + CABundle []byte `json:"caBundle,omitempty"` + // GroupPriorityMinimum is the priority this group should have at least. Higher priority means that the group is preferred by clients over lower priority ones. + // Note that other versions of this group might specify even higher GroupPriorityMinimum values such that the whole group gets a higher priority. + // The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10). + // The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo) + // We'd recommend something like: *.k8s.io (except extensions) at 18000 and + // PaaSes (OpenShift, Deis) are recommended to be in the 2000s + GroupPriorityMinimum *int32 `json:"groupPriorityMinimum,omitempty"` + // VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero. + // The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10). + // Since it's inside of a group, the number can be small, probably in the 10s. + // In case of equal version priorities, the version string will be used to compute the order inside a group. + // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered + // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), + // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first + // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing major + // version, then minor version. An example sorted list of versions: + // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. + VersionPriority *int32 `json:"versionPriority,omitempty"` +} + +// APIServiceSpecApplyConfiguration constructs a declarative configuration of the APIServiceSpec type for use with +// apply. +func APIServiceSpec() *APIServiceSpecApplyConfiguration { + return &APIServiceSpecApplyConfiguration{} +} + +// WithService sets the Service field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Service field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithService(value *ServiceReferenceApplyConfiguration) *APIServiceSpecApplyConfiguration { + b.Service = value + return b +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithGroup(value string) *APIServiceSpecApplyConfiguration { + b.Group = &value + return b +} + +// WithVersion sets the Version field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Version field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithVersion(value string) *APIServiceSpecApplyConfiguration { + b.Version = &value + return b +} + +// WithInsecureSkipTLSVerify sets the InsecureSkipTLSVerify field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InsecureSkipTLSVerify field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithInsecureSkipTLSVerify(value bool) *APIServiceSpecApplyConfiguration { + b.InsecureSkipTLSVerify = &value + return b +} + +// WithCABundle adds the given value to the CABundle field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the CABundle field. +func (b *APIServiceSpecApplyConfiguration) WithCABundle(values ...byte) *APIServiceSpecApplyConfiguration { + for i := range values { + b.CABundle = append(b.CABundle, values[i]) + } + return b +} + +// WithGroupPriorityMinimum sets the GroupPriorityMinimum field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GroupPriorityMinimum field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithGroupPriorityMinimum(value int32) *APIServiceSpecApplyConfiguration { + b.GroupPriorityMinimum = &value + return b +} + +// WithVersionPriority sets the VersionPriority field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the VersionPriority field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithVersionPriority(value int32) *APIServiceSpecApplyConfiguration { + b.VersionPriority = &value + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicestatus.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicestatus.go new file mode 100644 index 00000000000..900e2834c24 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/apiservicestatus.go @@ -0,0 +1,47 @@ +/* +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 + +// APIServiceStatusApplyConfiguration represents a declarative configuration of the APIServiceStatus type for use +// with apply. +// +// APIServiceStatus contains derived information about an API server +type APIServiceStatusApplyConfiguration struct { + // Current service state of apiService. + Conditions []APIServiceConditionApplyConfiguration `json:"conditions,omitempty"` +} + +// APIServiceStatusApplyConfiguration constructs a declarative configuration of the APIServiceStatus type for use with +// apply. +func APIServiceStatus() *APIServiceStatusApplyConfiguration { + return &APIServiceStatusApplyConfiguration{} +} + +// 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 *APIServiceStatusApplyConfiguration) WithConditions(values ...*APIServiceConditionApplyConfiguration) *APIServiceStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/servicereference.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/servicereference.go new file mode 100644 index 00000000000..0b333f0cf2b --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1/servicereference.go @@ -0,0 +1,64 @@ +/* +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 + +// ServiceReferenceApplyConfiguration represents a declarative configuration of the ServiceReference type for use +// with apply. +// +// ServiceReference holds a reference to Service.legacy.k8s.io +type ServiceReferenceApplyConfiguration struct { + // Namespace is the namespace of the service + Namespace *string `json:"namespace,omitempty"` + // Name is the name of the service + Name *string `json:"name,omitempty"` + // If specified, the port on the service that hosting webhook. + // Default to 443 for backward compatibility. + // `port` should be a valid port number (1-65535, inclusive). + Port *int32 `json:"port,omitempty"` +} + +// ServiceReferenceApplyConfiguration constructs a declarative configuration of the ServiceReference type for use with +// apply. +func ServiceReference() *ServiceReferenceApplyConfiguration { + return &ServiceReferenceApplyConfiguration{} +} + +// 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 *ServiceReferenceApplyConfiguration) WithNamespace(value string) *ServiceReferenceApplyConfiguration { + b.Namespace = &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 *ServiceReferenceApplyConfiguration) WithName(value string) *ServiceReferenceApplyConfiguration { + b.Name = &value + return b +} + +// WithPort sets the Port field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Port field is set to the value of the last call. +func (b *ServiceReferenceApplyConfiguration) WithPort(value int32) *ServiceReferenceApplyConfiguration { + b.Port = &value + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservice.go new file mode 100644 index 00000000000..162ed8e9914 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservice.go @@ -0,0 +1,292 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" + apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" + internal "k8s.io/kube-aggregator/pkg/client/applyconfiguration/internal" +) + +// APIServiceApplyConfiguration represents a declarative configuration of the APIService type for use +// with apply. +// +// APIService represents a server for a particular GroupVersion. +// Name must be "version.group". +type APIServiceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + // Spec contains information for locating and communicating with a server + Spec *APIServiceSpecApplyConfiguration `json:"spec,omitempty"` + // Status contains derived information about an API server + Status *APIServiceStatusApplyConfiguration `json:"status,omitempty"` +} + +// APIService constructs a declarative configuration of the APIService type for use with +// apply. +func APIService(name string) *APIServiceApplyConfiguration { + b := &APIServiceApplyConfiguration{} + b.WithName(name) + b.WithKind("APIService") + b.WithAPIVersion("apiregistration.k8s.io/v1beta1") + return b +} + +// ExtractAPIServiceFrom extracts the applied configuration owned by fieldManager from +// aPIService for the specified subresource. Pass an empty string for subresource to extract +// the main resource. Common subresources include "status", "scale", etc. +// aPIService must be a unmodified APIService API object that was retrieved from the Kubernetes API. +// ExtractAPIServiceFrom 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 ExtractAPIServiceFrom(aPIService *apiregistrationv1beta1.APIService, fieldManager string, subresource string) (*APIServiceApplyConfiguration, error) { + b := &APIServiceApplyConfiguration{} + err := managedfields.ExtractInto(aPIService, internal.Parser().Type("io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIService"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(aPIService.Name) + + b.WithKind("APIService") + b.WithAPIVersion("apiregistration.k8s.io/v1beta1") + return b, nil +} + +// ExtractAPIService extracts the applied configuration owned by fieldManager from +// aPIService. If no managedFields are found in aPIService for fieldManager, a +// APIServiceApplyConfiguration 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. +// aPIService must be a unmodified APIService API object that was retrieved from the Kubernetes API. +// ExtractAPIService 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 ExtractAPIService(aPIService *apiregistrationv1beta1.APIService, fieldManager string) (*APIServiceApplyConfiguration, error) { + return ExtractAPIServiceFrom(aPIService, fieldManager, "") +} + +// ExtractAPIServiceStatus extracts the applied configuration owned by fieldManager from +// aPIService for the status subresource. +func ExtractAPIServiceStatus(aPIService *apiregistrationv1beta1.APIService, fieldManager string) (*APIServiceApplyConfiguration, error) { + return ExtractAPIServiceFrom(aPIService, fieldManager, "status") +} + +func (b APIServiceApplyConfiguration) 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 *APIServiceApplyConfiguration) WithKind(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithAPIVersion(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithName(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithGenerateName(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithNamespace(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithUID(value types.UID) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithResourceVersion(value string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithGeneration(value int64) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithLabels(entries map[string]string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithAnnotations(entries map[string]string) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithFinalizers(values ...string) *APIServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *APIServiceApplyConfiguration) 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 *APIServiceApplyConfiguration) WithSpec(value *APIServiceSpecApplyConfiguration) *APIServiceApplyConfiguration { + 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 *APIServiceApplyConfiguration) WithStatus(value *APIServiceStatusApplyConfiguration) *APIServiceApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *APIServiceApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicecondition.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicecondition.go new file mode 100644 index 00000000000..93c43fafa27 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicecondition.go @@ -0,0 +1,88 @@ +/* +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 v1beta1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" +) + +// APIServiceConditionApplyConfiguration represents a declarative configuration of the APIServiceCondition type for use +// with apply. +// +// APIServiceCondition describes the state of an APIService at a particular point +type APIServiceConditionApplyConfiguration struct { + // Type is the type of the condition. + Type *apiregistrationv1beta1.APIServiceConditionType `json:"type,omitempty"` + // Status is the status of the condition. + // Can be True, False, Unknown. + Status *apiregistrationv1beta1.ConditionStatus `json:"status,omitempty"` + // Last time the condition transitioned from one status to another. + LastTransitionTime *v1.Time `json:"lastTransitionTime,omitempty"` + // Unique, one-word, CamelCase reason for the condition's last transition. + Reason *string `json:"reason,omitempty"` + // Human-readable message indicating details about last transition. + Message *string `json:"message,omitempty"` +} + +// APIServiceConditionApplyConfiguration constructs a declarative configuration of the APIServiceCondition type for use with +// apply. +func APIServiceCondition() *APIServiceConditionApplyConfiguration { + return &APIServiceConditionApplyConfiguration{} +} + +// 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 *APIServiceConditionApplyConfiguration) WithType(value apiregistrationv1beta1.APIServiceConditionType) *APIServiceConditionApplyConfiguration { + b.Type = &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 *APIServiceConditionApplyConfiguration) WithStatus(value apiregistrationv1beta1.ConditionStatus) *APIServiceConditionApplyConfiguration { + b.Status = &value + return b +} + +// WithLastTransitionTime sets the LastTransitionTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastTransitionTime field is set to the value of the last call. +func (b *APIServiceConditionApplyConfiguration) WithLastTransitionTime(value v1.Time) *APIServiceConditionApplyConfiguration { + b.LastTransitionTime = &value + return b +} + +// WithReason sets the Reason field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Reason field is set to the value of the last call. +func (b *APIServiceConditionApplyConfiguration) WithReason(value string) *APIServiceConditionApplyConfiguration { + b.Reason = &value + return b +} + +// WithMessage sets the Message field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Message field is set to the value of the last call. +func (b *APIServiceConditionApplyConfiguration) WithMessage(value string) *APIServiceConditionApplyConfiguration { + b.Message = &value + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicespec.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicespec.go new file mode 100644 index 00000000000..e778e725d67 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicespec.go @@ -0,0 +1,124 @@ +/* +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 v1beta1 + +// APIServiceSpecApplyConfiguration represents a declarative configuration of the APIServiceSpec type for use +// with apply. +// +// APIServiceSpec contains information for locating and communicating with a server. +// Only https is supported, though you are able to disable certificate verification. +type APIServiceSpecApplyConfiguration struct { + // Service is a reference to the service for this API server. It must communicate + // on port 443. + // If the Service is nil, that means the handling for the API groupversion is handled locally on this server. + // The call will simply delegate to the normal handler chain to be fulfilled. + Service *ServiceReferenceApplyConfiguration `json:"service,omitempty"` + // Group is the API group name this server hosts + Group *string `json:"group,omitempty"` + // Version is the API version this server hosts. For example, "v1" + Version *string `json:"version,omitempty"` + // InsecureSkipTLSVerify disables TLS certificate verification when communicating with this server. + // This is strongly discouraged. You should use the CABundle instead. + InsecureSkipTLSVerify *bool `json:"insecureSkipTLSVerify,omitempty"` + // CABundle is a PEM encoded CA bundle which will be used to validate an API server's serving certificate. + // If unspecified, system trust roots on the apiserver are used. + CABundle []byte `json:"caBundle,omitempty"` + // GroupPriorityMinimum is the priority this group should have at least. Higher priority means that the group is preferred by clients over lower priority ones. + // Note that other versions of this group might specify even higher GroupPriorityMinimum values such that the whole group gets a higher priority. + // The primary sort is based on GroupPriorityMinimum, ordered highest number to lowest (20 before 10). + // The secondary sort is based on the alphabetical comparison of the name of the object. (v1.bar before v1.foo) + // We'd recommend something like: *.k8s.io (except extensions) at 18000 and + // PaaSes (OpenShift, Deis) are recommended to be in the 2000s + GroupPriorityMinimum *int32 `json:"groupPriorityMinimum,omitempty"` + // VersionPriority controls the ordering of this API version inside of its group. Must be greater than zero. + // The primary sort is based on VersionPriority, ordered highest to lowest (20 before 10). + // Since it's inside of a group, the number can be small, probably in the 10s. + // In case of equal version priorities, the version string will be used to compute the order inside a group. + // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered + // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), + // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first + // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing major + // version, then minor version. An example sorted list of versions: + // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. + VersionPriority *int32 `json:"versionPriority,omitempty"` +} + +// APIServiceSpecApplyConfiguration constructs a declarative configuration of the APIServiceSpec type for use with +// apply. +func APIServiceSpec() *APIServiceSpecApplyConfiguration { + return &APIServiceSpecApplyConfiguration{} +} + +// WithService sets the Service field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Service field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithService(value *ServiceReferenceApplyConfiguration) *APIServiceSpecApplyConfiguration { + b.Service = value + return b +} + +// WithGroup sets the Group field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Group field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithGroup(value string) *APIServiceSpecApplyConfiguration { + b.Group = &value + return b +} + +// WithVersion sets the Version field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Version field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithVersion(value string) *APIServiceSpecApplyConfiguration { + b.Version = &value + return b +} + +// WithInsecureSkipTLSVerify sets the InsecureSkipTLSVerify field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the InsecureSkipTLSVerify field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithInsecureSkipTLSVerify(value bool) *APIServiceSpecApplyConfiguration { + b.InsecureSkipTLSVerify = &value + return b +} + +// WithCABundle adds the given value to the CABundle field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the CABundle field. +func (b *APIServiceSpecApplyConfiguration) WithCABundle(values ...byte) *APIServiceSpecApplyConfiguration { + for i := range values { + b.CABundle = append(b.CABundle, values[i]) + } + return b +} + +// WithGroupPriorityMinimum sets the GroupPriorityMinimum field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GroupPriorityMinimum field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithGroupPriorityMinimum(value int32) *APIServiceSpecApplyConfiguration { + b.GroupPriorityMinimum = &value + return b +} + +// WithVersionPriority sets the VersionPriority field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the VersionPriority field is set to the value of the last call. +func (b *APIServiceSpecApplyConfiguration) WithVersionPriority(value int32) *APIServiceSpecApplyConfiguration { + b.VersionPriority = &value + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicestatus.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicestatus.go new file mode 100644 index 00000000000..8c73c7cb05b --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/apiservicestatus.go @@ -0,0 +1,47 @@ +/* +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 v1beta1 + +// APIServiceStatusApplyConfiguration represents a declarative configuration of the APIServiceStatus type for use +// with apply. +// +// APIServiceStatus contains derived information about an API server +type APIServiceStatusApplyConfiguration struct { + // Current service state of apiService. + Conditions []APIServiceConditionApplyConfiguration `json:"conditions,omitempty"` +} + +// APIServiceStatusApplyConfiguration constructs a declarative configuration of the APIServiceStatus type for use with +// apply. +func APIServiceStatus() *APIServiceStatusApplyConfiguration { + return &APIServiceStatusApplyConfiguration{} +} + +// 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 *APIServiceStatusApplyConfiguration) WithConditions(values ...*APIServiceConditionApplyConfiguration) *APIServiceStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/servicereference.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/servicereference.go new file mode 100644 index 00000000000..1564845e580 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1/servicereference.go @@ -0,0 +1,64 @@ +/* +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 v1beta1 + +// ServiceReferenceApplyConfiguration represents a declarative configuration of the ServiceReference type for use +// with apply. +// +// ServiceReference holds a reference to Service.legacy.k8s.io +type ServiceReferenceApplyConfiguration struct { + // Namespace is the namespace of the service + Namespace *string `json:"namespace,omitempty"` + // Name is the name of the service + Name *string `json:"name,omitempty"` + // If specified, the port on the service that hosting webhook. + // Default to 443 for backward compatibility. + // `port` should be a valid port number (1-65535, inclusive). + Port *int32 `json:"port,omitempty"` +} + +// ServiceReferenceApplyConfiguration constructs a declarative configuration of the ServiceReference type for use with +// apply. +func ServiceReference() *ServiceReferenceApplyConfiguration { + return &ServiceReferenceApplyConfiguration{} +} + +// 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 *ServiceReferenceApplyConfiguration) WithNamespace(value string) *ServiceReferenceApplyConfiguration { + b.Namespace = &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 *ServiceReferenceApplyConfiguration) WithName(value string) *ServiceReferenceApplyConfiguration { + b.Name = &value + return b +} + +// WithPort sets the Port field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Port field is set to the value of the last call. +func (b *ServiceReferenceApplyConfiguration) WithPort(value int32) *ServiceReferenceApplyConfiguration { + b.Port = &value + return b +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/internal/internal.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/internal/internal.go new file mode 100644 index 00000000000..5cde85e8d74 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/internal/internal.go @@ -0,0 +1,369 @@ +/* +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: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + map: + fields: + - name: apiVersion + type: + scalar: string + - name: fieldsType + type: + scalar: string + - name: fieldsV1 + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + - name: manager + type: + scalar: string + - name: operation + type: + scalar: string + - name: subresource + type: + scalar: string + - name: time + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + map: + fields: + - name: annotations + type: + map: + elementType: + scalar: string + - name: creationTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: deletionGracePeriodSeconds + type: + scalar: numeric + - name: deletionTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: finalizers + type: + list: + elementType: + scalar: string + elementRelationship: associative + - name: generateName + type: + scalar: string + - name: generation + type: + scalar: numeric + - name: labels + type: + map: + elementType: + scalar: string + - name: managedFields + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + elementRelationship: atomic + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: ownerReferences + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + elementRelationship: associative + keys: + - uid + - name: resourceVersion + type: + scalar: string + - name: selfLink + type: + scalar: string + - name: uid + type: + scalar: string +- name: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: blockOwnerDeletion + type: + scalar: boolean + - name: controller + type: + scalar: boolean + - name: kind + type: + scalar: string + default: "" + - name: name + type: + scalar: string + default: "" + - name: uid + type: + scalar: string + default: "" + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.Time + scalar: untyped +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIService + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceSpec + default: {} + - name: status + type: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceStatus + default: {} +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceCondition + map: + fields: + - name: lastTransitionTime + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: message + type: + scalar: string + - name: reason + type: + scalar: string + - name: status + type: + scalar: string + default: "" + - name: type + type: + scalar: string + default: "" +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceSpec + map: + fields: + - name: caBundle + type: + scalar: string + - name: group + type: + scalar: string + - name: groupPriorityMinimum + type: + scalar: numeric + default: 0 + - name: insecureSkipTLSVerify + type: + scalar: boolean + - name: service + type: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.ServiceReference + - name: version + type: + scalar: string + - name: versionPriority + type: + scalar: numeric + default: 0 +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceStatus + map: + fields: + - name: conditions + type: + list: + elementType: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.APIServiceCondition + elementRelationship: associative + keys: + - type +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.ServiceReference + map: + fields: + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: port + type: + scalar: numeric +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIService + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceSpec + default: {} + - name: status + type: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceStatus + default: {} +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceCondition + map: + fields: + - name: lastTransitionTime + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: message + type: + scalar: string + - name: reason + type: + scalar: string + - name: status + type: + scalar: string + default: "" + - name: type + type: + scalar: string + default: "" +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceSpec + map: + fields: + - name: caBundle + type: + scalar: string + - name: group + type: + scalar: string + - name: groupPriorityMinimum + type: + scalar: numeric + default: 0 + - name: insecureSkipTLSVerify + type: + scalar: boolean + - name: service + type: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.ServiceReference + - name: version + type: + scalar: string + - name: versionPriority + type: + scalar: numeric + default: 0 +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceStatus + map: + fields: + - name: conditions + type: + list: + elementType: + namedType: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.APIServiceCondition + elementRelationship: associative + keys: + - type +- name: io.k8s.kube-aggregator.pkg.apis.apiregistration.v1beta1.ServiceReference + map: + fields: + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: port + type: + scalar: numeric +- 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/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/utils.go b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/utils.go new file mode 100644 index 00000000000..7481ba7da35 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/applyconfiguration/utils.go @@ -0,0 +1,66 @@ +/* +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 ( + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" + v1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" + apiregistrationv1 "k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1" + apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1" + internal "k8s.io/kube-aggregator/pkg/client/applyconfiguration/internal" +) + +// 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=apiregistration.k8s.io, Version=v1 + case v1.SchemeGroupVersion.WithKind("APIService"): + return &apiregistrationv1.APIServiceApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("APIServiceCondition"): + return &apiregistrationv1.APIServiceConditionApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("APIServiceSpec"): + return &apiregistrationv1.APIServiceSpecApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("APIServiceStatus"): + return &apiregistrationv1.APIServiceStatusApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ServiceReference"): + return &apiregistrationv1.ServiceReferenceApplyConfiguration{} + + // Group=apiregistration.k8s.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithKind("APIService"): + return &apiregistrationv1beta1.APIServiceApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("APIServiceCondition"): + return &apiregistrationv1beta1.APIServiceConditionApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("APIServiceSpec"): + return &apiregistrationv1beta1.APIServiceSpecApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("APIServiceStatus"): + return &apiregistrationv1beta1.APIServiceStatusApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("ServiceReference"): + return &apiregistrationv1beta1.ServiceReferenceApplyConfiguration{} + + } + return nil +} + +func NewTypeConverter(scheme *runtime.Scheme) managedfields.TypeConverter { + return managedfields.NewSchemeTypeConverter(scheme, internal.Parser()) +} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake/clientset_generated.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake/clientset_generated.go index 534d62d1195..51c1bccb6ab 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake/clientset_generated.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake/clientset_generated.go @@ -25,6 +25,7 @@ import ( "k8s.io/client-go/discovery" fakediscovery "k8s.io/client-go/discovery/fake" "k8s.io/client-go/testing" + applyconfiguration "k8s.io/kube-aggregator/pkg/client/applyconfiguration" clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset" apiregistrationv1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1" fakeapiregistrationv1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/fake" @@ -96,6 +97,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{} diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go index a27b9848d8c..dc48ba62a50 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go @@ -26,6 +26,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" gentype "k8s.io/client-go/gentype" apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" + applyconfigurationapiregistrationv1 "k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1" scheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" ) @@ -47,18 +48,21 @@ type APIServiceInterface interface { List(ctx context.Context, opts metav1.ListOptions) (*apiregistrationv1.APIServiceList, 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 *apiregistrationv1.APIService, err error) + Apply(ctx context.Context, aPIService *applyconfigurationapiregistrationv1.APIServiceApplyConfiguration, opts metav1.ApplyOptions) (result *apiregistrationv1.APIService, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, aPIService *applyconfigurationapiregistrationv1.APIServiceApplyConfiguration, opts metav1.ApplyOptions) (result *apiregistrationv1.APIService, err error) APIServiceExpansion } // aPIServices implements APIServiceInterface type aPIServices struct { - *gentype.ClientWithList[*apiregistrationv1.APIService, *apiregistrationv1.APIServiceList] + *gentype.ClientWithListAndApply[*apiregistrationv1.APIService, *apiregistrationv1.APIServiceList, *applyconfigurationapiregistrationv1.APIServiceApplyConfiguration] } // newAPIServices returns a APIServices func newAPIServices(c *ApiregistrationV1Client) *aPIServices { return &aPIServices{ - gentype.NewClientWithList[*apiregistrationv1.APIService, *apiregistrationv1.APIServiceList]( + gentype.NewClientWithListAndApply[*apiregistrationv1.APIService, *apiregistrationv1.APIServiceList, *applyconfigurationapiregistrationv1.APIServiceApplyConfiguration]( "apiservices", c.RESTClient(), scheme.ParameterCodec, diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/fake/fake_apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/fake/fake_apiservice.go index fcac99fb757..4edd50a7b8f 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/fake/fake_apiservice.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/fake/fake_apiservice.go @@ -21,18 +21,19 @@ package fake import ( gentype "k8s.io/client-go/gentype" v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" - apiregistrationv1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1" + apiregistrationv1 "k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1" + typedapiregistrationv1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1" ) // fakeAPIServices implements APIServiceInterface type fakeAPIServices struct { - *gentype.FakeClientWithList[*v1.APIService, *v1.APIServiceList] + *gentype.FakeClientWithListAndApply[*v1.APIService, *v1.APIServiceList, *apiregistrationv1.APIServiceApplyConfiguration] Fake *FakeApiregistrationV1 } -func newFakeAPIServices(fake *FakeApiregistrationV1) apiregistrationv1.APIServiceInterface { +func newFakeAPIServices(fake *FakeApiregistrationV1) typedapiregistrationv1.APIServiceInterface { return &fakeAPIServices{ - gentype.NewFakeClientWithList[*v1.APIService, *v1.APIServiceList]( + gentype.NewFakeClientWithListAndApply[*v1.APIService, *v1.APIServiceList, *apiregistrationv1.APIServiceApplyConfiguration]( fake.Fake, "", v1.SchemeGroupVersion.WithResource("apiservices"), diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go index 33321982e76..8227160d963 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go @@ -26,6 +26,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" gentype "k8s.io/client-go/gentype" apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" + applyconfigurationapiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1" scheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" ) @@ -47,18 +48,21 @@ type APIServiceInterface interface { List(ctx context.Context, opts v1.ListOptions) (*apiregistrationv1beta1.APIServiceList, 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 *apiregistrationv1beta1.APIService, err error) + Apply(ctx context.Context, aPIService *applyconfigurationapiregistrationv1beta1.APIServiceApplyConfiguration, opts v1.ApplyOptions) (result *apiregistrationv1beta1.APIService, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, aPIService *applyconfigurationapiregistrationv1beta1.APIServiceApplyConfiguration, opts v1.ApplyOptions) (result *apiregistrationv1beta1.APIService, err error) APIServiceExpansion } // aPIServices implements APIServiceInterface type aPIServices struct { - *gentype.ClientWithList[*apiregistrationv1beta1.APIService, *apiregistrationv1beta1.APIServiceList] + *gentype.ClientWithListAndApply[*apiregistrationv1beta1.APIService, *apiregistrationv1beta1.APIServiceList, *applyconfigurationapiregistrationv1beta1.APIServiceApplyConfiguration] } // newAPIServices returns a APIServices func newAPIServices(c *ApiregistrationV1beta1Client) *aPIServices { return &aPIServices{ - gentype.NewClientWithList[*apiregistrationv1beta1.APIService, *apiregistrationv1beta1.APIServiceList]( + gentype.NewClientWithListAndApply[*apiregistrationv1beta1.APIService, *apiregistrationv1beta1.APIServiceList, *applyconfigurationapiregistrationv1beta1.APIServiceApplyConfiguration]( "apiservices", c.RESTClient(), scheme.ParameterCodec, diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/fake/fake_apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/fake/fake_apiservice.go index 4c77ea5d2b2..6fc4a180c9e 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/fake/fake_apiservice.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/fake/fake_apiservice.go @@ -21,18 +21,19 @@ package fake import ( gentype "k8s.io/client-go/gentype" v1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" - apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1" + apiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/client/applyconfiguration/apiregistration/v1beta1" + typedapiregistrationv1beta1 "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1" ) // fakeAPIServices implements APIServiceInterface type fakeAPIServices struct { - *gentype.FakeClientWithList[*v1beta1.APIService, *v1beta1.APIServiceList] + *gentype.FakeClientWithListAndApply[*v1beta1.APIService, *v1beta1.APIServiceList, *apiregistrationv1beta1.APIServiceApplyConfiguration] Fake *FakeApiregistrationV1beta1 } -func newFakeAPIServices(fake *FakeApiregistrationV1beta1) apiregistrationv1beta1.APIServiceInterface { +func newFakeAPIServices(fake *FakeApiregistrationV1beta1) typedapiregistrationv1beta1.APIServiceInterface { return &fakeAPIServices{ - gentype.NewFakeClientWithList[*v1beta1.APIService, *v1beta1.APIServiceList]( + gentype.NewFakeClientWithListAndApply[*v1beta1.APIService, *v1beta1.APIServiceList, *apiregistrationv1beta1.APIServiceApplyConfiguration]( fake.Fake, "", v1beta1.SchemeGroupVersion.WithResource("apiservices"), diff --git a/staging/src/k8s.io/kube-aggregator/pkg/generated/openapi/cmd/models-schema/main.go b/staging/src/k8s.io/kube-aggregator/pkg/generated/openapi/cmd/models-schema/main.go new file mode 100644 index 00000000000..cd412be30c7 --- /dev/null +++ b/staging/src/k8s.io/kube-aggregator/pkg/generated/openapi/cmd/models-schema/main.go @@ -0,0 +1,76 @@ +/* +Copyright 2021 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" + + "k8s.io/kube-aggregator/pkg/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)) // nolint:errcheck + 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: "Kubernetes", + Version: "unversioned", + }, + }, + Swagger: "2.0", + }, + }) + if err != nil { + return fmt.Errorf("error serializing api definitions: %w", err) + } + os.Stdout.Write(data) // nolint:errcheck + return nil +} diff --git a/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh b/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh index 39fb34890d3..352bf0913b1 100755 --- a/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh +++ b/staging/src/k8s.io/sample-apiserver/hack/update-codegen.sh @@ -48,6 +48,7 @@ kube::codegen::gen_openapi \ kube::codegen::gen_client \ --with-watch \ --with-applyconfig \ + --applyconfig-openapi-schema <(go run k8s.io/sample-apiserver/pkg/generated/openapi/cmd/models-schema) \ --output-dir "${SCRIPT_ROOT}/pkg/generated" \ --output-pkg "${THIS_PKG}/pkg/generated" \ --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ diff --git a/staging/src/k8s.io/sample-apiserver/hack/verify-codegen.sh b/staging/src/k8s.io/sample-apiserver/hack/verify-codegen.sh index a51a33dd527..c801150c00f 100755 --- a/staging/src/k8s.io/sample-apiserver/hack/verify-codegen.sh +++ b/staging/src/k8s.io/sample-apiserver/hack/verify-codegen.sh @@ -29,6 +29,19 @@ trap "cleanup" EXIT SIGINT cleanup +# Ensure model-schema generator matches the version from +# k8s.io/kubernetes/pkg/generated/openapi/cmd/models-schema/main.go +echo "Ensuring models-schema is up-to-date" +K8S_MODELS_SCHEMA="${SCRIPT_ROOT}/../../../../pkg/generated/openapi/cmd/models-schema/main.go" +SAMPLE_APISERVER_MODELS_SCHEMA="${SCRIPT_ROOT}/pkg/generated/openapi/cmd/models-schema/main.go" +# these two files will only differ in the imported lines for generated openapi +if ! diff -I "k8s.io/kubernetes/pkg/generated/openapi" \ + -I "k8s.io/sample-apiserver/pkg/generated/openapi" \ + "${K8S_MODELS_SCHEMA}" "${SAMPLE_APISERVER_MODELS_SCHEMA}"; then + echo "${SAMPLE_APISERVER_MODELS_SCHEMA} is out of date. Compare changes with ${K8S_MODELS_SCHEMA}" + exit 1 +fi + mkdir -p "${TMP_DIFFROOT}" cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go index c482faa5c20..e73edc749cb 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal/internal.go @@ -39,6 +39,239 @@ func Parser() *typed.Parser { var parserOnce sync.Once var parser *typed.Parser var schemaYAML = typed.YAMLObject(`types: +- name: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + map: + fields: + - name: apiVersion + type: + scalar: string + - name: fieldsType + type: + scalar: string + - name: fieldsV1 + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + - name: manager + type: + scalar: string + - name: operation + type: + scalar: string + - name: subresource + type: + scalar: string + - name: time + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + map: + fields: + - name: annotations + type: + map: + elementType: + scalar: string + - name: creationTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: deletionGracePeriodSeconds + type: + scalar: numeric + - name: deletionTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: finalizers + type: + list: + elementType: + scalar: string + elementRelationship: associative + - name: generateName + type: + scalar: string + - name: generation + type: + scalar: numeric + - name: labels + type: + map: + elementType: + scalar: string + - name: managedFields + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + elementRelationship: atomic + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: ownerReferences + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + elementRelationship: associative + keys: + - uid + - name: resourceVersion + type: + scalar: string + - name: selfLink + type: + scalar: string + - name: uid + type: + scalar: string +- name: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: blockOwnerDeletion + type: + scalar: boolean + - name: controller + type: + scalar: boolean + - name: kind + type: + scalar: string + default: "" + - name: name + type: + scalar: string + default: "" + - name: uid + type: + scalar: string + default: "" + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.Time + scalar: untyped +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.Fischer + map: + fields: + - name: apiVersion + type: + scalar: string + - name: disallowedFlunders + type: + list: + elementType: + scalar: string + elementRelationship: atomic + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.Flunder + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.FlunderSpec + default: {} + - name: status + type: + namedType: io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.FlunderStatus + default: {} +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.FlunderSpec + map: + fields: + - name: reference + type: + scalar: string + - name: referenceType + type: + scalar: string +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.FlunderStatus + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1beta1.Flunder + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: io.k8s.sample-apiserver.pkg.apis.wardle.v1beta1.FlunderSpec + default: {} + - name: status + type: + namedType: io.k8s.sample-apiserver.pkg.apis.wardle.v1beta1.FlunderStatus + default: {} +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1beta1.FlunderSpec + map: + fields: + - name: fischerReference + type: + scalar: string + - name: flunderReference + type: + scalar: string + - name: referenceType + type: + scalar: string +- name: io.k8s.sample-apiserver.pkg.apis.wardle.v1beta1.FlunderStatus + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable - name: __untyped_atomic_ scalar: untyped list: diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go index e7080028712..748de276088 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/fischer.go @@ -21,7 +21,10 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" v1 "k8s.io/client-go/applyconfigurations/meta/v1" + wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + internal "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal" ) // FischerApplyConfiguration represents a declarative configuration of the Fischer type for use @@ -43,6 +46,40 @@ func Fischer(name string) *FischerApplyConfiguration { return b } +// ExtractFischerFrom extracts the applied configuration owned by fieldManager from +// fischer for the specified subresource. Pass an empty string for subresource to extract +// the main resource. Common subresources include "status", "scale", etc. +// fischer must be a unmodified Fischer API object that was retrieved from the Kubernetes API. +// ExtractFischerFrom 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 ExtractFischerFrom(fischer *wardlev1alpha1.Fischer, fieldManager string, subresource string) (*FischerApplyConfiguration, error) { + b := &FischerApplyConfiguration{} + err := managedfields.ExtractInto(fischer, internal.Parser().Type("io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.Fischer"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(fischer.Name) + + b.WithKind("Fischer") + b.WithAPIVersion("wardle.example.com/v1alpha1") + return b, nil +} + +// ExtractFischer extracts the applied configuration owned by fieldManager from +// fischer. If no managedFields are found in fischer for fieldManager, a +// FischerApplyConfiguration 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. +// fischer must be a unmodified Fischer API object that was retrieved from the Kubernetes API. +// ExtractFischer 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 ExtractFischer(fischer *wardlev1alpha1.Fischer, fieldManager string) (*FischerApplyConfiguration, error) { + return ExtractFischerFrom(fischer, fieldManager, "") +} + func (b FischerApplyConfiguration) IsApplyConfiguration() {} // WithKind sets the Kind field in the declarative configuration to the given value diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go index f524ac18b97..7965c2cf9af 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1/flunder.go @@ -21,8 +21,10 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" v1 "k8s.io/client-go/applyconfigurations/meta/v1" wardlev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + internal "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal" ) // FlunderApplyConfiguration represents a declarative configuration of the Flunder type for use @@ -45,6 +47,47 @@ func Flunder(name, namespace string) *FlunderApplyConfiguration { return b } +// ExtractFlunderFrom extracts the applied configuration owned by fieldManager from +// flunder for the specified subresource. Pass an empty string for subresource to extract +// the main resource. Common subresources include "status", "scale", etc. +// flunder must be a unmodified Flunder API object that was retrieved from the Kubernetes API. +// ExtractFlunderFrom 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 ExtractFlunderFrom(flunder *wardlev1alpha1.Flunder, fieldManager string, subresource string) (*FlunderApplyConfiguration, error) { + b := &FlunderApplyConfiguration{} + err := managedfields.ExtractInto(flunder, internal.Parser().Type("io.k8s.sample-apiserver.pkg.apis.wardle.v1alpha1.Flunder"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(flunder.Name) + b.WithNamespace(flunder.Namespace) + + b.WithKind("Flunder") + b.WithAPIVersion("wardle.example.com/v1alpha1") + return b, nil +} + +// ExtractFlunder extracts the applied configuration owned by fieldManager from +// flunder. If no managedFields are found in flunder for fieldManager, a +// FlunderApplyConfiguration 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. +// flunder must be a unmodified Flunder API object that was retrieved from the Kubernetes API. +// ExtractFlunder 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 ExtractFlunder(flunder *wardlev1alpha1.Flunder, fieldManager string) (*FlunderApplyConfiguration, error) { + return ExtractFlunderFrom(flunder, fieldManager, "") +} + +// ExtractFlunderStatus extracts the applied configuration owned by fieldManager from +// flunder for the status subresource. +func ExtractFlunderStatus(flunder *wardlev1alpha1.Flunder, fieldManager string) (*FlunderApplyConfiguration, error) { + return ExtractFlunderFrom(flunder, fieldManager, "status") +} + func (b FlunderApplyConfiguration) IsApplyConfiguration() {} // WithKind sets the Kind field in the declarative configuration to the given value diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go index 645f3b675f4..8ac26afc7b7 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1/flunder.go @@ -21,8 +21,10 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" v1 "k8s.io/client-go/applyconfigurations/meta/v1" wardlev1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" + internal "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/internal" ) // FlunderApplyConfiguration represents a declarative configuration of the Flunder type for use @@ -47,6 +49,47 @@ func Flunder(name, namespace string) *FlunderApplyConfiguration { return b } +// ExtractFlunderFrom extracts the applied configuration owned by fieldManager from +// flunder for the specified subresource. Pass an empty string for subresource to extract +// the main resource. Common subresources include "status", "scale", etc. +// flunder must be a unmodified Flunder API object that was retrieved from the Kubernetes API. +// ExtractFlunderFrom 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 ExtractFlunderFrom(flunder *wardlev1beta1.Flunder, fieldManager string, subresource string) (*FlunderApplyConfiguration, error) { + b := &FlunderApplyConfiguration{} + err := managedfields.ExtractInto(flunder, internal.Parser().Type("io.k8s.sample-apiserver.pkg.apis.wardle.v1beta1.Flunder"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(flunder.Name) + b.WithNamespace(flunder.Namespace) + + b.WithKind("Flunder") + b.WithAPIVersion("wardle.example.com/v1beta1") + return b, nil +} + +// ExtractFlunder extracts the applied configuration owned by fieldManager from +// flunder. If no managedFields are found in flunder for fieldManager, a +// FlunderApplyConfiguration 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. +// flunder must be a unmodified Flunder API object that was retrieved from the Kubernetes API. +// ExtractFlunder 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 ExtractFlunder(flunder *wardlev1beta1.Flunder, fieldManager string) (*FlunderApplyConfiguration, error) { + return ExtractFlunderFrom(flunder, fieldManager, "") +} + +// ExtractFlunderStatus extracts the applied configuration owned by fieldManager from +// flunder for the status subresource. +func ExtractFlunderStatus(flunder *wardlev1beta1.Flunder, fieldManager string) (*FlunderApplyConfiguration, error) { + return ExtractFlunderFrom(flunder, fieldManager, "status") +} + func (b FlunderApplyConfiguration) IsApplyConfiguration() {} // WithKind sets the Kind field in the declarative configuration to the given value diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/openapi/cmd/models-schema/main.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/openapi/cmd/models-schema/main.go new file mode 100644 index 00000000000..be85afe7e74 --- /dev/null +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/openapi/cmd/models-schema/main.go @@ -0,0 +1,76 @@ +/* +Copyright 2021 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" + + "k8s.io/kube-openapi/pkg/common" + "k8s.io/kube-openapi/pkg/validation/spec" + "k8s.io/sample-apiserver/pkg/generated/openapi" +) + +// 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)) // nolint:errcheck + 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: "Kubernetes", + Version: "unversioned", + }, + }, + Swagger: "2.0", + }, + }) + if err != nil { + return fmt.Errorf("error serializing api definitions: %w", err) + } + os.Stdout.Write(data) // nolint:errcheck + return nil +}