From a2ad36f1e564f81fae4f65c9ac8aa193d6b0662d Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 26 Feb 2020 23:56:07 -0800 Subject: [PATCH 1/2] Add the StorageVersion API --- hack/.golint_failures | 2 + .../pkg/apis/apiserverinternal/doc.go | 22 ++ .../pkg/apis/apiserverinternal/fuzzer/BUILD | 24 ++ .../apis/apiserverinternal/fuzzer/fuzzer.go | 26 ++ .../pkg/apis/apiserverinternal/install/BUILD | 43 +++ .../apis/apiserverinternal/install/install.go | 33 ++ .../install/roundtrip_test.go | 29 ++ .../pkg/apis/apiserverinternal/register.go | 53 ++++ .../pkg/apis/apiserverinternal/types.go | 120 ++++++++ .../apis/apiserverinternal/v1alpha1/doc.go | 27 ++ .../apiserverinternal/v1alpha1/register.go | 56 ++++ .../apis/apiserverinternal/v1alpha1/types.go | 127 ++++++++ .../apis/apiserverinternal/validation/BUILD | 27 ++ .../validation/validation.go | 128 ++++++++ .../validation/validation_test.go | 286 ++++++++++++++++++ 15 files changed, 1003 insertions(+) create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/doc.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/BUILD create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/fuzzer.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/BUILD create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/install.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/roundtrip_test.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/register.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/types.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/doc.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/register.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/types.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation_test.go diff --git a/hack/.golint_failures b/hack/.golint_failures index ea1de427e9df..dc29d3cb9ec9 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -309,6 +309,8 @@ staging/src/k8s.io/apiserver/pkg/apis/apiserver staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1 staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1alpha1 staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1beta1 +staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal +staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1 staging/src/k8s.io/apiserver/pkg/apis/audit staging/src/k8s.io/apiserver/pkg/apis/audit/v1 staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1 diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/doc.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/doc.go new file mode 100644 index 000000000000..df3193a924a4 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +groupName=internal.apiserver.k8s.io + +// Package apiserverinternal contains the "internal" version of the API used by +// the apiservers themselves. +package apiserverinternal // import "k8s.io/apiserver/pkg/apis/apiserverinternal" diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/BUILD new file mode 100644 index 000000000000..469c0f18f1b0 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/BUILD @@ -0,0 +1,24 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["fuzzer.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer", + importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer", + visibility = ["//visibility:public"], + deps = ["//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library"], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/fuzzer.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/fuzzer.go new file mode 100644 index 000000000000..e054abd144d1 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer/fuzzer.go @@ -0,0 +1,26 @@ +/* +Copyright 2019 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 fuzzer + +import ( + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" +) + +// Funcs returns the fuzzer functions for the apiserverinternal api group. +func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { + return []interface{}{} +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/BUILD new file mode 100644 index 000000000000..38bbeed23488 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/BUILD @@ -0,0 +1,43 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", + "go_test", +) + +go_library( + name = "go_default_library", + srcs = ["install.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/install", + importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/install", + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) + +go_test( + name = "go_default_test", + srcs = ["roundtrip_test.go"], + embed = [":go_default_library"], + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer:go_default_library", + ], +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/install.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/install.go new file mode 100644 index 000000000000..0ecd186949f5 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/install.go @@ -0,0 +1,33 @@ +/* +Copyright 2019 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 install installs the experimental API group, making it available as +// an option to all of the API encoding/decoding machinery. +package install + +import ( + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apiserver/pkg/apis/apiserverinternal" + "k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1" +) + +// Install registers the API group and adds types to a scheme +func Install(scheme *runtime.Scheme) { + utilruntime.Must(apiserverinternal.AddToScheme(scheme)) + utilruntime.Must(v1alpha1.AddToScheme(scheme)) + utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion)) +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/roundtrip_test.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/roundtrip_test.go new file mode 100644 index 000000000000..3f48ab06310f --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install/roundtrip_test.go @@ -0,0 +1,29 @@ +/* +Copyright 2019 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 install + +import ( + "testing" + + "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" + "k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer" +) + +func TestRoundTrip(t *testing.T) { + roundtrip.RoundTripTestForAPIGroup(t, Install, fuzzer.Funcs) + roundtrip.RoundTripProtobufTestForAPIGroup(t, Install, fuzzer.Funcs) +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/register.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/register.go new file mode 100644 index 000000000000..1958c8242232 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/register.go @@ -0,0 +1,53 @@ +/* +Copyright 2019 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 apiserverinternal + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "internal.apiserver.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} + +// Kind takes an unqualified kind and returns a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder is the scheme builder with scheme init functions to run for this API package. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &StorageVersion{}, + &StorageVersionList{}, + ) + return nil +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/types.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/types.go new file mode 100644 index 000000000000..54142205a2d4 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/types.go @@ -0,0 +1,120 @@ +/* +Copyright 2019 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 apiserverinternal + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Storage version of a specific resource. +type StorageVersion struct { + metav1.TypeMeta + // The name is .. + metav1.ObjectMeta + + // Spec is an empty spec. It is here to comply with Kubernetes API style. + Spec StorageVersionSpec + + // API server instances report the version they can decode and the version they + // encode objects to when persisting objects in the backend. + Status StorageVersionStatus +} + +// StorageVersionSpec is an empty spec. +type StorageVersionSpec struct{} + +// API server instances report the versions they can decode and the version they +// encode objects to when persisting objects in the backend. +type StorageVersionStatus struct { + // The reported versions per API server instance. + // +optional + StorageVersions []ServerStorageVersion + // If all API server instances agree on the same encoding storage version, + // then this field is set to that version. Otherwise this field is left empty. + // API servers should finish updating its storageVersionStatus entry before + // serving write operations, so that this field will be in sync with the reality. + // +optional + CommonEncodingVersion *string + + // The latest available observations of the storageVersion's state. + // +optional + Conditions []StorageVersionCondition +} + +// An API server instance reports the version it can decode and the version it +// encodes objects to when persisting objects in the backend. +type ServerStorageVersion struct { + // The ID of the reporting API server. + APIServerID string + + // The API server encodes the object to this version when persisting it in + // the backend (e.g., etcd). + EncodingVersion string + + // The API server can decode objects encoded in these versions. + // The encodingVersion must be included in the decodableVersions. + DecodableVersions []string +} + +type StorageVersionConditionType string + +const ( + // Indicates that encoding storage versions reported by all servers are equal. + AllEncodingVersionsEqual StorageVersionConditionType = "AllEncodingVersionsEqual" +) + +type ConditionStatus string + +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// Describes the state of the storageVersion at a certain point. +type StorageVersionCondition struct { + // Type of the condition. + // +optional + Type StorageVersionConditionType + // Status of the condition, one of True, False, Unknown. + // +required + Status ConditionStatus + // If set, this represents the .metadata.generation that the condition was set based upon. + // +optional + ObservedGeneration int64 + // Last time the condition transitioned from one status to another. + // +required + LastTransitionTime metav1.Time + // The reason for the condition's last transition. + // +required + Reason string + // A human readable message indicating details about the transition. + // +required + Message string +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// A list of StorageVersions. +type StorageVersionList struct { + metav1.TypeMeta + // +optional + metav1.ListMeta + Items []StorageVersion +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/doc.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/doc.go new file mode 100644 index 000000000000..9e8ec0cfc5db --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/doc.go @@ -0,0 +1,27 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:protobuf-gen=package +// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/apiserverinternal +// +k8s:openapi-gen=true +// +k8s:defaulter-gen=TypeMeta + +// +groupName=internal.apiserver.k8s.io + +// Package v1alpha1 contains the v1alpha1 version of the API used by the +// apiservers themselves. +package v1alpha1 // import "k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1" diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/register.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/register.go new file mode 100644 index 000000000000..e510140fa83f --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "internal.apiserver.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &StorageVersion{}, + &StorageVersionList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/types.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/types.go new file mode 100644 index 000000000000..0d80fcfb9fba --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/types.go @@ -0,0 +1,127 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Storage version of a specific resource. +type StorageVersion struct { + metav1.TypeMeta `json:",inline"` + // The name is .. + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Spec is an empty spec. It is here to comply with Kubernetes API style. + Spec StorageVersionSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` + + // API server instances report the version they can decode and the version they + // encode objects to when persisting objects in the backend. + Status StorageVersionStatus `json:"status" protobuf:"bytes,3,opt,name=status"` +} + +// StorageVersionSpec is an empty spec. +type StorageVersionSpec struct{} + +// API server instances report the versions they can decode and the version they +// encode objects to when persisting objects in the backend. +type StorageVersionStatus struct { + // The reported versions per API server instance. + // +optional + // +listType=map + // +listMapKey=apiserverID + StorageVersions []ServerStorageVersion `json:"storageVersions,omitempty" protobuf:"bytes,1,opt,name=storageVersions"` + // If all API server instances agree on the same encoding storage version, + // then this field is set to that version. Otherwise this field is left empty. + // API servers should finish updating its storageVersionStatus entry before + // serving write operations, so that this field will be in sync with the reality. + // +optional + CommonEncodingVersion *string `json:"commonEncodingVersion,omitempty" protobuf:"bytes,2,opt,name=commonEncodingVersion"` + + // The latest available observations of the storageVersion's state. + // +optional + // +listType=map + // +listMapKey=type + Conditions []StorageVersionCondition `json:"conditions,omitempty" protobuf:"bytes,3,opt,name=conditions"` +} + +// An API server instance reports the version it can decode and the version it +// encodes objects to when persisting objects in the backend. +type ServerStorageVersion struct { + // The ID of the reporting API server. + APIServerID string `json:"apiServerID,omitempty" protobuf:"bytes,1,opt,name=apiServerID"` + + // The API server encodes the object to this version when persisting it in + // the backend (e.g., etcd). + EncodingVersion string `json:"encodingVersion,omitempty" protobuf:"bytes,2,opt,name=encodingVersion"` + + // The API server can decode objects encoded in these versions. + // The encodingVersion must be included in the decodableVersions. + // +listType=set + DecodableVersions []string `json:"decodableVersions,omitempty" protobuf:"bytes,3,opt,name=decodableVersions"` +} + +type StorageVersionConditionType string + +const ( + // Indicates that encoding storage versions reported by all servers are equal. + AllEncodingVersionsEqual StorageVersionConditionType = "AllEncodingVersionsEqual" +) + +type ConditionStatus string + +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// Describes the state of the storageVersion at a certain point. +type StorageVersionCondition struct { + // Type of the condition. + // +required + Type StorageVersionConditionType `json:"type" protobuf:"bytes,1,opt,name=type"` + // Status of the condition, one of True, False, Unknown. + // +required + Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"` + // If set, this represents the .metadata.generation that the condition was set based upon. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"` + // Last time the condition transitioned from one status to another. + // +required + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"` + // The reason for the condition's last transition. + // +required + Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"` + // A human readable message indicating details about the transition. + // +required + Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// A list of StorageVersions. +type StorageVersionList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + Items []StorageVersion `json:"items" protobuf:"bytes,2,rep,name=items"` +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD new file mode 100644 index 000000000000..27e5d8ce21a8 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD @@ -0,0 +1,27 @@ +package(default_visibility = ["//visibility:public"]) + +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["validation.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/validation", + importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/validation", + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation.go new file mode 100644 index 000000000000..d1886af99b40 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation.go @@ -0,0 +1,128 @@ +/* +Copyright 2020 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 validation + +import ( + "fmt" + "strings" + + apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" + "k8s.io/apimachinery/pkg/util/validation" + utilvalidation "k8s.io/apimachinery/pkg/util/validation" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/apis/apiserverinternal" +) + +// ValidateStorageVersion validate the storage version object. +func ValidateStorageVersion(sv *apiserverinternal.StorageVersion) field.ErrorList { + var allErrs field.ErrorList + allErrs = append(allErrs, validateStorageVersionStatus(sv.Status, field.NewPath("status"))...) + return allErrs +} + +func validateStorageVersionStatus(ss apiserverinternal.StorageVersionStatus, fldPath *field.Path) field.ErrorList { + var allErrs field.ErrorList + for i, ssv := range ss.StorageVersions { + allErrs = append(allErrs, validateServerStorageVersion(ssv, fldPath.Child("storageVersions").Index(i))...) + } + if err := validateCommonVersion(ss, fldPath); err != nil { + allErrs = append(allErrs, err) + } + allErrs = append(allErrs, validateStorageVersionCondition(ss.Conditions, fldPath)...) + return allErrs +} + +func validateServerStorageVersion(ssv apiserverinternal.ServerStorageVersion, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + for _, msg := range apimachineryvalidation.NameIsDNSSubdomain(ssv.APIServerID, false) { + allErrs = append(allErrs, field.Invalid(fldPath.Child("apiServerID"), ssv.APIServerID, msg)) + } + if errs := utilvalidation.IsDNS1035Label(ssv.EncodingVersion); len(errs) > 0 { + allErrs = append(allErrs, field.Invalid(fldPath.Child("encodingVersion"), ssv.EncodingVersion, strings.Join(errs, ","))) + } + + found := false + for i, dv := range ssv.DecodableVersions { + if errs := utilvalidation.IsDNS1035Label(dv); len(errs) > 0 { + allErrs = append(allErrs, field.Invalid(fldPath.Child("decodableVersions").Index(i), dv, strings.Join(errs, ","))) + } + if dv == ssv.EncodingVersion { + found = true + } + } + if !found { + allErrs = append(allErrs, field.Invalid(fldPath.Child("decodableVersions"), ssv.DecodableVersions, fmt.Sprintf("decodableVersions must include encodingVersion %s", ssv.EncodingVersion))) + } + return allErrs +} + +func commonVersion(ssv []apiserverinternal.ServerStorageVersion) *string { + if len(ssv) == 0 { + return nil + } + commonVersion := ssv[0].EncodingVersion + for _, v := range ssv[1:] { + if v.EncodingVersion != commonVersion { + return nil + } + } + return &commonVersion +} + +func validateCommonVersion(svs apiserverinternal.StorageVersionStatus, fldPath *field.Path) *field.Error { + actualCommonVersion := commonVersion(svs.StorageVersions) + if actualCommonVersion == nil && svs.CommonEncodingVersion == nil { + return nil + } + if actualCommonVersion == nil && svs.CommonEncodingVersion != nil { + return field.Invalid(fldPath.Child("commonEncodingVersion"), *svs.CommonEncodingVersion, "should be nil if servers do not agree on the same encoding version, or if there is no server reporting the supported versions yet") + } + if actualCommonVersion != nil && svs.CommonEncodingVersion == nil { + return field.Invalid(fldPath.Child("commonEncodingVersion"), svs.CommonEncodingVersion, fmt.Sprintf("the common encoding version is %s", *actualCommonVersion)) + } + if actualCommonVersion != nil && svs.CommonEncodingVersion != nil && *actualCommonVersion != *svs.CommonEncodingVersion { + return field.Invalid(fldPath.Child("commonEncodingVersion"), *svs.CommonEncodingVersion, fmt.Sprintf("the actual common encoding version is %s", *actualCommonVersion)) + } + return nil +} + +func validateStorageVersionCondition(conditions []apiserverinternal.StorageVersionCondition, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + // We do not verify that the condition type or the condition status is + // a predefined one because we might add more type or status later. + seenType := make(map[apiserverinternal.StorageVersionConditionType]int) + for i, condition := range conditions { + if ii, ok := seenType[condition.Type]; ok { + allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("type"), string(condition.Type), + fmt.Sprintf("the type of the condition is not unique, it also appears in conditions[%d]", ii))) + } + seenType[condition.Type] = i + for _, msg := range validation.IsQualifiedName(string(condition.Type)) { + allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("type"), string(condition.Type), msg)) + } + for _, msg := range validation.IsQualifiedName(string(condition.Status)) { + allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("status"), string(condition.Type), msg)) + } + if condition.Reason == "" { + allErrs = append(allErrs, field.Required(fldPath.Index(i).Child("reason"), "reason cannot be empty")) + } + if condition.Message == "" { + allErrs = append(allErrs, field.Required(fldPath.Index(i).Child("message"), "message cannot be empty")) + } + } + return allErrs +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation_test.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation_test.go new file mode 100644 index 000000000000..d0d70611f223 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/validation_test.go @@ -0,0 +1,286 @@ +/* +Copyright 2020 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 validation + +import ( + "strings" + "testing" + + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/apiserver/pkg/apis/apiserverinternal" +) + +func TestValidateServerStorageVersion(t *testing.T) { + cases := []struct { + ssv apiserverinternal.ServerStorageVersion + expectedErr string + }{ + { + ssv: apiserverinternal.ServerStorageVersion{ + APIServerID: "-fea", + EncodingVersion: "v1alpha1", + DecodableVersions: []string{"v1alpha1", "v1"}, + }, + expectedErr: "apiServerID: Invalid value", + }, + { + ssv: apiserverinternal.ServerStorageVersion{ + APIServerID: "fea", + EncodingVersion: "v1alpha1", + DecodableVersions: []string{"v1beta1", "v1"}, + }, + expectedErr: "decodableVersions must include encodingVersion", + }, + { + ssv: apiserverinternal.ServerStorageVersion{ + APIServerID: "fea", + EncodingVersion: "v1alpha1", + DecodableVersions: []string{"v1alpha1", "v1", "-fea"}, + }, + expectedErr: "decodableVersions[2]: Invalid value", + }, + { + ssv: apiserverinternal.ServerStorageVersion{ + APIServerID: "fea", + EncodingVersion: "v1alpha1", + DecodableVersions: []string{"v1alpha1", "v1"}, + }, + expectedErr: "", + }, + } + + for _, tc := range cases { + err := validateServerStorageVersion(tc.ssv, field.NewPath("")).ToAggregate() + if err == nil && len(tc.expectedErr) == 0 { + continue + } + if err != nil && len(tc.expectedErr) == 0 { + t.Errorf("unexpected error %v", err) + continue + } + if err == nil && len(tc.expectedErr) != 0 { + t.Errorf("unexpected empty error") + continue + } + if !strings.Contains(err.Error(), tc.expectedErr) { + t.Errorf("expected error to contain %s, got %s", tc.expectedErr, err) + } + } +} + +func TestValidateCommonVersion(t *testing.T) { + cases := []struct { + status apiserverinternal.StorageVersionStatus + expectedErr string + }{ + { + status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{}, + CommonEncodingVersion: func() *string { a := "v1alpha1"; return &a }(), + }, + expectedErr: "should be nil if servers do not agree on the same encoding version, or if there is no server reporting the supported versions yet", + }, + { + status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1alpha1", + }, + { + APIServerID: "2", + EncodingVersion: "v1", + }, + }, + CommonEncodingVersion: func() *string { a := "v1alpha1"; return &a }(), + }, + expectedErr: "should be nil if servers do not agree on the same encoding version, or if there is no server reporting the supported versions yet", + }, + { + status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1alpha1", + }, + { + APIServerID: "2", + EncodingVersion: "v1alpha1", + }, + }, + CommonEncodingVersion: nil, + }, + expectedErr: "Invalid value: \"null\": the common encoding version is v1alpha1", + }, + { + status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1alpha1", + }, + { + APIServerID: "2", + EncodingVersion: "v1alpha1", + }, + }, + CommonEncodingVersion: func() *string { a := "v1"; return &a }(), + }, + expectedErr: "Invalid value: \"v1\": the actual common encoding version is v1alpha1", + }, + { + status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1alpha1", + }, + { + APIServerID: "2", + EncodingVersion: "v1alpha1", + }, + }, + CommonEncodingVersion: func() *string { a := "v1alpha1"; return &a }(), + }, + expectedErr: "", + }, + { + status: apiserverinternal.StorageVersionStatus{ + StorageVersions: []apiserverinternal.ServerStorageVersion{ + { + APIServerID: "1", + EncodingVersion: "v1alpha1", + }, + }, + CommonEncodingVersion: func() *string { a := "v1alpha1"; return &a }(), + }, + expectedErr: "", + }, + } + for _, tc := range cases { + err := validateCommonVersion(tc.status, field.NewPath("")) + if err == nil && len(tc.expectedErr) == 0 { + continue + } + if err != nil && len(tc.expectedErr) == 0 { + t.Errorf("unexpected error %v", err) + continue + } + if err == nil && len(tc.expectedErr) != 0 { + t.Errorf("unexpected empty error") + continue + } + if !strings.Contains(err.Error(), tc.expectedErr) { + t.Errorf("expected error to contain %s, got %s", tc.expectedErr, err) + } + } +} + +func TestValidateStorageVersionCondition(t *testing.T) { + cases := []struct { + conditions []apiserverinternal.StorageVersionCondition + expectedErr string + }{ + { + conditions: []apiserverinternal.StorageVersionCondition{ + { + Type: "-fea", + Status: "True", + Reason: "unknown", + Message: "unknown", + }, + }, + expectedErr: "type: Invalid value", + }, + { + conditions: []apiserverinternal.StorageVersionCondition{ + { + Type: "fea", + Status: "-True", + Reason: "unknown", + Message: "unknown", + }, + }, + expectedErr: "status: Invalid value", + }, + { + conditions: []apiserverinternal.StorageVersionCondition{ + { + Type: "fea", + Status: "True", + Message: "unknown", + }, + }, + expectedErr: "Required value: reason cannot be empty", + }, + { + conditions: []apiserverinternal.StorageVersionCondition{ + { + Type: "fea", + Status: "True", + Reason: "unknown", + }, + }, + expectedErr: "Required value: message cannot be empty", + }, + { + conditions: []apiserverinternal.StorageVersionCondition{ + { + Type: "fea", + Status: "True", + Reason: "unknown", + Message: "unknown", + }, + { + Type: "fea", + Status: "True", + Reason: "unknown", + Message: "unknown", + }, + }, + expectedErr: `"fea": the type of the condition is not unique, it also appears in conditions[0]`, + }, + { + conditions: []apiserverinternal.StorageVersionCondition{ + { + Type: "fea", + Status: "True", + Reason: "unknown", + Message: "unknown", + }, + }, + expectedErr: "", + }, + } + for _, tc := range cases { + err := validateStorageVersionCondition(tc.conditions, field.NewPath("")).ToAggregate() + if err == nil && len(tc.expectedErr) == 0 { + continue + } + if err != nil && len(tc.expectedErr) == 0 { + t.Errorf("unexpected error %v", err) + continue + } + if err == nil && len(tc.expectedErr) != 0 { + t.Errorf("unexpected empty error") + continue + } + if !strings.Contains(err.Error(), tc.expectedErr) { + t.Errorf("expected error to contain %s, got %s", tc.expectedErr, err) + } + } +} From 5f3838b906628f907939080bac967ef8f105e92f Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 26 Feb 2020 23:56:24 -0800 Subject: [PATCH 2/2] generated --- build/kazel_generated.bzl | 2 + staging/src/k8s.io/apiserver/BUILD | 1 + .../pkg/apis/apiserverinternal/BUILD | 42 + .../pkg/apis/apiserverinternal/v1alpha1/BUILD | 39 + .../v1alpha1/generated.pb.go | 1718 +++++++++++++++++ .../v1alpha1/generated.proto | 121 ++ .../v1alpha1/zz_generated.conversion.go | 249 +++ .../v1alpha1/zz_generated.deepcopy.go | 175 ++ .../v1alpha1/zz_generated.defaults.go | 32 + .../apis/apiserverinternal/validation/BUILD | 14 +- .../zz_generated.deepcopy.go | 175 ++ 11 files changed, 2567 insertions(+), 1 deletion(-) create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/BUILD create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/BUILD create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.pb.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.proto create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.conversion.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.deepcopy.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.defaults.go create mode 100644 staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/zz_generated.deepcopy.go diff --git a/build/kazel_generated.bzl b/build/kazel_generated.bzl index ae13c60516fe..4dd5a6e8a53c 100644 --- a/build/kazel_generated.bzl +++ b/build/kazel_generated.bzl @@ -86,6 +86,7 @@ tags_values_pkgs = {"openapi-gen": { "staging/src/k8s.io/apimachinery/pkg/runtime", "staging/src/k8s.io/apimachinery/pkg/util/intstr", "staging/src/k8s.io/apimachinery/pkg/version", + "staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1", "staging/src/k8s.io/apiserver/pkg/apis/audit/v1", "staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1", "staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1", @@ -168,6 +169,7 @@ tags_pkgs_values = {"openapi-gen": { "staging/src/k8s.io/apimachinery/pkg/runtime": ["true"], "staging/src/k8s.io/apimachinery/pkg/util/intstr": ["true"], "staging/src/k8s.io/apimachinery/pkg/version": ["true"], + "staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1": ["true"], "staging/src/k8s.io/apiserver/pkg/apis/audit/v1": ["true"], "staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1": ["true"], "staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1": ["true"], diff --git a/staging/src/k8s.io/apiserver/BUILD b/staging/src/k8s.io/apiserver/BUILD index 70935be995f3..acd7f6583362 100644 --- a/staging/src/k8s.io/apiserver/BUILD +++ b/staging/src/k8s.io/apiserver/BUILD @@ -11,6 +11,7 @@ filegroup( ":package-srcs", "//staging/src/k8s.io/apiserver/pkg/admission:all-srcs", "//staging/src/k8s.io/apiserver/pkg/apis/apiserver:all-srcs", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:all-srcs", "//staging/src/k8s.io/apiserver/pkg/apis/audit:all-srcs", "//staging/src/k8s.io/apiserver/pkg/apis/config:all-srcs", "//staging/src/k8s.io/apiserver/pkg/apis/example:all-srcs", diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/BUILD new file mode 100644 index 000000000000..a5ef7013bac9 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/BUILD @@ -0,0 +1,42 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "register.go", + "types.go", + "zz_generated.deepcopy.go", + ], + importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal", + importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal", + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer:all-srcs", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install:all-srcs", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1:all-srcs", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/BUILD new file mode 100644 index 000000000000..10f3ff4275f0 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/BUILD @@ -0,0 +1,39 @@ +package(default_visibility = ["//visibility:public"]) + +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "generated.pb.go", + "register.go", + "types.go", + "zz_generated.conversion.go", + "zz_generated.deepcopy.go", + "zz_generated.defaults.go", + ], + importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1", + importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1", + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:go_default_library", + "//vendor/github.com/gogo/protobuf/proto:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.pb.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.pb.go new file mode 100644 index 000000000000..1adf8a3d6fbc --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.pb.go @@ -0,0 +1,1718 @@ +/* +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 protoc-gen-gogo. DO NOT EDIT. +// source: k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.proto + +package v1alpha1 + +import ( + fmt "fmt" + + io "io" + + proto "github.com/gogo/protobuf/proto" + + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func (m *ServerStorageVersion) Reset() { *m = ServerStorageVersion{} } +func (*ServerStorageVersion) ProtoMessage() {} +func (*ServerStorageVersion) Descriptor() ([]byte, []int) { + return fileDescriptor_e78b74fcffb22985, []int{0} +} +func (m *ServerStorageVersion) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServerStorageVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *ServerStorageVersion) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerStorageVersion.Merge(m, src) +} +func (m *ServerStorageVersion) XXX_Size() int { + return m.Size() +} +func (m *ServerStorageVersion) XXX_DiscardUnknown() { + xxx_messageInfo_ServerStorageVersion.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerStorageVersion proto.InternalMessageInfo + +func (m *StorageVersion) Reset() { *m = StorageVersion{} } +func (*StorageVersion) ProtoMessage() {} +func (*StorageVersion) Descriptor() ([]byte, []int) { + return fileDescriptor_e78b74fcffb22985, []int{1} +} +func (m *StorageVersion) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StorageVersion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *StorageVersion) XXX_Merge(src proto.Message) { + xxx_messageInfo_StorageVersion.Merge(m, src) +} +func (m *StorageVersion) XXX_Size() int { + return m.Size() +} +func (m *StorageVersion) XXX_DiscardUnknown() { + xxx_messageInfo_StorageVersion.DiscardUnknown(m) +} + +var xxx_messageInfo_StorageVersion proto.InternalMessageInfo + +func (m *StorageVersionCondition) Reset() { *m = StorageVersionCondition{} } +func (*StorageVersionCondition) ProtoMessage() {} +func (*StorageVersionCondition) Descriptor() ([]byte, []int) { + return fileDescriptor_e78b74fcffb22985, []int{2} +} +func (m *StorageVersionCondition) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StorageVersionCondition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *StorageVersionCondition) XXX_Merge(src proto.Message) { + xxx_messageInfo_StorageVersionCondition.Merge(m, src) +} +func (m *StorageVersionCondition) XXX_Size() int { + return m.Size() +} +func (m *StorageVersionCondition) XXX_DiscardUnknown() { + xxx_messageInfo_StorageVersionCondition.DiscardUnknown(m) +} + +var xxx_messageInfo_StorageVersionCondition proto.InternalMessageInfo + +func (m *StorageVersionList) Reset() { *m = StorageVersionList{} } +func (*StorageVersionList) ProtoMessage() {} +func (*StorageVersionList) Descriptor() ([]byte, []int) { + return fileDescriptor_e78b74fcffb22985, []int{3} +} +func (m *StorageVersionList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StorageVersionList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *StorageVersionList) XXX_Merge(src proto.Message) { + xxx_messageInfo_StorageVersionList.Merge(m, src) +} +func (m *StorageVersionList) XXX_Size() int { + return m.Size() +} +func (m *StorageVersionList) XXX_DiscardUnknown() { + xxx_messageInfo_StorageVersionList.DiscardUnknown(m) +} + +var xxx_messageInfo_StorageVersionList proto.InternalMessageInfo + +func (m *StorageVersionSpec) Reset() { *m = StorageVersionSpec{} } +func (*StorageVersionSpec) ProtoMessage() {} +func (*StorageVersionSpec) Descriptor() ([]byte, []int) { + return fileDescriptor_e78b74fcffb22985, []int{4} +} +func (m *StorageVersionSpec) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StorageVersionSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *StorageVersionSpec) XXX_Merge(src proto.Message) { + xxx_messageInfo_StorageVersionSpec.Merge(m, src) +} +func (m *StorageVersionSpec) XXX_Size() int { + return m.Size() +} +func (m *StorageVersionSpec) XXX_DiscardUnknown() { + xxx_messageInfo_StorageVersionSpec.DiscardUnknown(m) +} + +var xxx_messageInfo_StorageVersionSpec proto.InternalMessageInfo + +func (m *StorageVersionStatus) Reset() { *m = StorageVersionStatus{} } +func (*StorageVersionStatus) ProtoMessage() {} +func (*StorageVersionStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_e78b74fcffb22985, []int{5} +} +func (m *StorageVersionStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StorageVersionStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *StorageVersionStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_StorageVersionStatus.Merge(m, src) +} +func (m *StorageVersionStatus) XXX_Size() int { + return m.Size() +} +func (m *StorageVersionStatus) XXX_DiscardUnknown() { + xxx_messageInfo_StorageVersionStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_StorageVersionStatus proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ServerStorageVersion)(nil), "k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1.ServerStorageVersion") + proto.RegisterType((*StorageVersion)(nil), "k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1.StorageVersion") + proto.RegisterType((*StorageVersionCondition)(nil), "k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1.StorageVersionCondition") + proto.RegisterType((*StorageVersionList)(nil), "k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1.StorageVersionList") + proto.RegisterType((*StorageVersionSpec)(nil), "k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1.StorageVersionSpec") + proto.RegisterType((*StorageVersionStatus)(nil), "k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1.StorageVersionStatus") +} + +func init() { + proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.proto", fileDescriptor_e78b74fcffb22985) +} + +var fileDescriptor_e78b74fcffb22985 = []byte{ + // 767 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x5d, 0x4f, 0x13, 0x4d, + 0x14, 0xee, 0xd2, 0x52, 0x60, 0xfa, 0xbe, 0xf4, 0x65, 0x5e, 0x08, 0xb5, 0x26, 0x5b, 0xec, 0x85, + 0x41, 0x8d, 0xbb, 0xd2, 0xa0, 0xd1, 0x2b, 0xc3, 0x02, 0x51, 0x08, 0x04, 0x33, 0x10, 0x2f, 0x8c, + 0x26, 0x4e, 0x77, 0xc7, 0xed, 0xd2, 0xee, 0xce, 0x66, 0x67, 0xda, 0x84, 0x3b, 0xfd, 0x01, 0x26, + 0xfe, 0x10, 0x7f, 0x08, 0x97, 0xc4, 0xc4, 0x84, 0x1b, 0x1b, 0x59, 0xff, 0x05, 0xde, 0x98, 0x9d, + 0xfd, 0x62, 0xdb, 0x25, 0x12, 0xc2, 0xdd, 0x9e, 0x8f, 0xe7, 0x3c, 0xe7, 0x9c, 0x7d, 0xce, 0x80, + 0x77, 0xdd, 0xa7, 0x4c, 0xb1, 0xa8, 0xda, 0xed, 0xb7, 0x89, 0xe7, 0x10, 0x4e, 0x98, 0x3a, 0x20, + 0x8e, 0x41, 0x3d, 0x35, 0x0a, 0x60, 0xd7, 0x62, 0xc4, 0x1b, 0x10, 0x4f, 0x75, 0xbb, 0xa6, 0xb0, + 0x52, 0x97, 0xe5, 0x70, 0xe2, 0x39, 0xb8, 0xa7, 0x0e, 0x56, 0x70, 0xcf, 0xed, 0xe0, 0x15, 0xd5, + 0x24, 0x0e, 0xf1, 0x30, 0x27, 0x86, 0xe2, 0x7a, 0x94, 0x53, 0xb8, 0x1a, 0x56, 0x51, 0x12, 0x88, + 0xe2, 0x76, 0x4d, 0x61, 0x29, 0x63, 0x55, 0x94, 0xb8, 0x4a, 0xfd, 0xa1, 0x69, 0xf1, 0x4e, 0xbf, + 0xad, 0xe8, 0xd4, 0x56, 0x4d, 0x6a, 0x52, 0x55, 0x14, 0x6b, 0xf7, 0x3f, 0x08, 0x4b, 0x18, 0xe2, + 0x2b, 0x24, 0xa9, 0xaf, 0xa6, 0xad, 0xda, 0x58, 0xef, 0x58, 0x0e, 0xf1, 0x8e, 0xd2, 0x6e, 0x6d, + 0xc2, 0xb1, 0x3a, 0x18, 0x6b, 0xad, 0xae, 0x5e, 0x86, 0xf2, 0xfa, 0x0e, 0xb7, 0x6c, 0x32, 0x06, + 0x78, 0xf2, 0x37, 0x00, 0xd3, 0x3b, 0xc4, 0xc6, 0xa3, 0xb8, 0xe6, 0x77, 0x09, 0xcc, 0xef, 0x8b, + 0x49, 0xf7, 0x39, 0xf5, 0xb0, 0x49, 0x5e, 0x13, 0x8f, 0x59, 0xd4, 0x81, 0x8f, 0x41, 0x05, 0xbb, + 0x56, 0x18, 0xda, 0xda, 0xa8, 0x49, 0x4b, 0xd2, 0xf2, 0x8c, 0xf6, 0xff, 0xf1, 0xb0, 0x51, 0xf0, + 0x87, 0x8d, 0xca, 0xda, 0xab, 0xad, 0x38, 0x84, 0x2e, 0xe6, 0xc1, 0x35, 0x50, 0x25, 0x8e, 0x4e, + 0x0d, 0xcb, 0x31, 0xa3, 0x4a, 0xb5, 0x09, 0x01, 0x5d, 0x8c, 0xa0, 0xd5, 0xcd, 0x6c, 0x18, 0x8d, + 0xe6, 0xc3, 0x75, 0x30, 0x67, 0x10, 0x9d, 0x1a, 0xb8, 0xdd, 0x8b, 0xbb, 0x61, 0xb5, 0xe2, 0x52, + 0x71, 0x79, 0x46, 0x5b, 0xf0, 0x87, 0x8d, 0xb9, 0x8d, 0xd1, 0x20, 0x1a, 0xcf, 0x6f, 0x7e, 0x9b, + 0x00, 0xb3, 0x23, 0x13, 0xbd, 0x07, 0xd3, 0xc1, 0xba, 0x0d, 0xcc, 0xb1, 0x18, 0xa7, 0xd2, 0x7a, + 0xa4, 0xa4, 0x0a, 0x48, 0xb6, 0x96, 0x8a, 0x20, 0xc8, 0x56, 0x06, 0x2b, 0xca, 0x5e, 0xfb, 0x90, + 0xe8, 0x7c, 0x97, 0x70, 0xac, 0xc1, 0x68, 0x0a, 0x90, 0xfa, 0x50, 0x52, 0x15, 0x1e, 0x82, 0x12, + 0x73, 0x89, 0x2e, 0x26, 0xae, 0xb4, 0x5e, 0x2a, 0xd7, 0xd1, 0x97, 0x92, 0xed, 0x7a, 0xdf, 0x25, + 0xba, 0xf6, 0x4f, 0xc4, 0x5a, 0x0a, 0x2c, 0x24, 0x38, 0xa0, 0x07, 0xca, 0x8c, 0x63, 0xde, 0x0f, + 0x56, 0x13, 0xb0, 0x6d, 0xdf, 0x08, 0x9b, 0xa8, 0xa8, 0xcd, 0x46, 0x7c, 0xe5, 0xd0, 0x46, 0x11, + 0x53, 0xf3, 0x6b, 0x11, 0x2c, 0x66, 0x01, 0xeb, 0xd4, 0x31, 0x2c, 0x1e, 0x6c, 0xf7, 0x39, 0x28, + 0xf1, 0x23, 0x97, 0x44, 0x42, 0x79, 0x10, 0x77, 0x7c, 0x70, 0xe4, 0x92, 0xf3, 0x61, 0xe3, 0xf6, + 0x25, 0xb0, 0x20, 0x8c, 0x04, 0x10, 0x3e, 0x4b, 0x06, 0x0a, 0x05, 0x73, 0x27, 0xdb, 0xc4, 0xf9, + 0xb0, 0x51, 0x4d, 0x60, 0xd9, 0xbe, 0xe0, 0x36, 0x80, 0xb4, 0x2d, 0x26, 0x34, 0x5e, 0x84, 0xfa, + 0x0e, 0x74, 0x17, 0xec, 0xa5, 0xa8, 0xd5, 0xa3, 0x32, 0x70, 0x6f, 0x2c, 0x03, 0xe5, 0xa0, 0xe0, + 0x00, 0xc0, 0x1e, 0x66, 0xfc, 0xc0, 0xc3, 0x0e, 0x0b, 0x5b, 0xb4, 0x6c, 0x52, 0x2b, 0x89, 0x1d, + 0xdf, 0xbf, 0x9a, 0x5e, 0x02, 0x44, 0xca, 0xbb, 0x33, 0x56, 0x0d, 0xe5, 0x30, 0xc0, 0xbb, 0xa0, + 0xec, 0x11, 0xcc, 0xa8, 0x53, 0x9b, 0x14, 0xe3, 0x27, 0xff, 0x00, 0x09, 0x2f, 0x8a, 0xa2, 0xf0, + 0x1e, 0x98, 0xb2, 0x09, 0x63, 0xd8, 0x24, 0xb5, 0xb2, 0x48, 0xac, 0x46, 0x89, 0x53, 0xbb, 0xa1, + 0x1b, 0xc5, 0xf1, 0xe6, 0x0f, 0x09, 0xc0, 0xec, 0xde, 0x77, 0x2c, 0xc6, 0xe1, 0xdb, 0xb1, 0x3b, + 0x50, 0xae, 0x36, 0x57, 0x80, 0x16, 0x57, 0xf0, 0x5f, 0x44, 0x39, 0x1d, 0x7b, 0x2e, 0xdc, 0x80, + 0x05, 0x26, 0x2d, 0x4e, 0xec, 0xe0, 0x2f, 0x16, 0x97, 0x2b, 0xad, 0x8d, 0x9b, 0x90, 0xa5, 0xf6, + 0x6f, 0x44, 0x38, 0xb9, 0x15, 0x94, 0x46, 0x21, 0x43, 0x73, 0x7e, 0x74, 0xbc, 0xe0, 0x3c, 0x9a, + 0xbf, 0x27, 0xc0, 0x7c, 0x9e, 0xaa, 0xe1, 0x67, 0x09, 0x54, 0x59, 0x26, 0xc0, 0x6a, 0x92, 0x68, + 0xf2, 0xba, 0xb7, 0x93, 0xf3, 0x6e, 0xa6, 0xef, 0x5c, 0xd6, 0xcf, 0xd0, 0x28, 0x37, 0xdc, 0x03, + 0x0b, 0x3a, 0xb5, 0x6d, 0xea, 0x6c, 0xe6, 0x3e, 0x98, 0xb7, 0xfc, 0x61, 0x63, 0x61, 0x3d, 0x2f, + 0x01, 0xe5, 0xe3, 0xe0, 0x27, 0x09, 0x00, 0x3d, 0x3e, 0x91, 0xf0, 0xc9, 0xac, 0xb4, 0x76, 0x6f, + 0xe2, 0x07, 0x24, 0x87, 0x97, 0x3e, 0x80, 0x89, 0x8b, 0xa1, 0x0b, 0xa4, 0x9a, 0x72, 0x7c, 0x26, + 0x17, 0x4e, 0xce, 0xe4, 0xc2, 0xe9, 0x99, 0x5c, 0xf8, 0xe8, 0xcb, 0xd2, 0xb1, 0x2f, 0x4b, 0x27, + 0xbe, 0x2c, 0x9d, 0xfa, 0xb2, 0xf4, 0xd3, 0x97, 0xa5, 0x2f, 0xbf, 0xe4, 0xc2, 0x9b, 0xe9, 0x98, + 0xe7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x1e, 0x5f, 0x1d, 0xe3, 0x07, 0x00, 0x00, +} + +func (m *ServerStorageVersion) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServerStorageVersion) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServerStorageVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DecodableVersions) > 0 { + for iNdEx := len(m.DecodableVersions) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.DecodableVersions[iNdEx]) + copy(dAtA[i:], m.DecodableVersions[iNdEx]) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.DecodableVersions[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + i -= len(m.EncodingVersion) + copy(dAtA[i:], m.EncodingVersion) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.EncodingVersion))) + i-- + dAtA[i] = 0x12 + i -= len(m.APIServerID) + copy(dAtA[i:], m.APIServerID) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.APIServerID))) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *StorageVersion) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StorageVersion) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StorageVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Status.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Spec.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.ObjectMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *StorageVersionCondition) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StorageVersionCondition) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StorageVersionCondition) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0x32 + i -= len(m.Reason) + copy(dAtA[i:], m.Reason) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Reason))) + i-- + dAtA[i] = 0x2a + { + size, err := m.LastTransitionTime.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + i = encodeVarintGenerated(dAtA, i, uint64(m.ObservedGeneration)) + i-- + dAtA[i] = 0x18 + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0x12 + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *StorageVersionList) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StorageVersionList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StorageVersionList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.ListMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *StorageVersionSpec) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StorageVersionSpec) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StorageVersionSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *StorageVersionStatus) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StorageVersionStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StorageVersionStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Conditions) > 0 { + for iNdEx := len(m.Conditions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Conditions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.CommonEncodingVersion != nil { + i -= len(*m.CommonEncodingVersion) + copy(dAtA[i:], *m.CommonEncodingVersion) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.CommonEncodingVersion))) + i-- + dAtA[i] = 0x12 + } + if len(m.StorageVersions) > 0 { + for iNdEx := len(m.StorageVersions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StorageVersions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { + offset -= sovGenerated(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ServerStorageVersion) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.APIServerID) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.EncodingVersion) + n += 1 + l + sovGenerated(uint64(l)) + if len(m.DecodableVersions) > 0 { + for _, s := range m.DecodableVersions { + l = len(s) + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func (m *StorageVersion) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ObjectMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Spec.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Status.Size() + n += 1 + l + sovGenerated(uint64(l)) + return n +} + +func (m *StorageVersionCondition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Type) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Status) + n += 1 + l + sovGenerated(uint64(l)) + n += 1 + sovGenerated(uint64(m.ObservedGeneration)) + l = m.LastTransitionTime.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Reason) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Message) + n += 1 + l + sovGenerated(uint64(l)) + return n +} + +func (m *StorageVersionList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ListMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func (m *StorageVersionSpec) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *StorageVersionStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.StorageVersions) > 0 { + for _, e := range m.StorageVersions { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.CommonEncodingVersion != nil { + l = len(*m.CommonEncodingVersion) + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.Conditions) > 0 { + for _, e := range m.Conditions { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + return n +} + +func sovGenerated(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenerated(x uint64) (n int) { + return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *ServerStorageVersion) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ServerStorageVersion{`, + `APIServerID:` + fmt.Sprintf("%v", this.APIServerID) + `,`, + `EncodingVersion:` + fmt.Sprintf("%v", this.EncodingVersion) + `,`, + `DecodableVersions:` + fmt.Sprintf("%v", this.DecodableVersions) + `,`, + `}`, + }, "") + return s +} +func (this *StorageVersion) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StorageVersion{`, + `ObjectMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ObjectMeta), "ObjectMeta", "v1.ObjectMeta", 1), `&`, ``, 1) + `,`, + `Spec:` + strings.Replace(strings.Replace(this.Spec.String(), "StorageVersionSpec", "StorageVersionSpec", 1), `&`, ``, 1) + `,`, + `Status:` + strings.Replace(strings.Replace(this.Status.String(), "StorageVersionStatus", "StorageVersionStatus", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *StorageVersionCondition) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StorageVersionCondition{`, + `Type:` + fmt.Sprintf("%v", this.Type) + `,`, + `Status:` + fmt.Sprintf("%v", this.Status) + `,`, + `ObservedGeneration:` + fmt.Sprintf("%v", this.ObservedGeneration) + `,`, + `LastTransitionTime:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.LastTransitionTime), "Time", "v1.Time", 1), `&`, ``, 1) + `,`, + `Reason:` + fmt.Sprintf("%v", this.Reason) + `,`, + `Message:` + fmt.Sprintf("%v", this.Message) + `,`, + `}`, + }, "") + return s +} +func (this *StorageVersionList) String() string { + if this == nil { + return "nil" + } + repeatedStringForItems := "[]StorageVersion{" + for _, f := range this.Items { + repeatedStringForItems += strings.Replace(strings.Replace(f.String(), "StorageVersion", "StorageVersion", 1), `&`, ``, 1) + "," + } + repeatedStringForItems += "}" + s := strings.Join([]string{`&StorageVersionList{`, + `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v1.ListMeta", 1), `&`, ``, 1) + `,`, + `Items:` + repeatedStringForItems + `,`, + `}`, + }, "") + return s +} +func (this *StorageVersionSpec) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StorageVersionSpec{`, + `}`, + }, "") + return s +} +func (this *StorageVersionStatus) String() string { + if this == nil { + return "nil" + } + repeatedStringForStorageVersions := "[]ServerStorageVersion{" + for _, f := range this.StorageVersions { + repeatedStringForStorageVersions += strings.Replace(strings.Replace(f.String(), "ServerStorageVersion", "ServerStorageVersion", 1), `&`, ``, 1) + "," + } + repeatedStringForStorageVersions += "}" + repeatedStringForConditions := "[]StorageVersionCondition{" + for _, f := range this.Conditions { + repeatedStringForConditions += strings.Replace(strings.Replace(f.String(), "StorageVersionCondition", "StorageVersionCondition", 1), `&`, ``, 1) + "," + } + repeatedStringForConditions += "}" + s := strings.Join([]string{`&StorageVersionStatus{`, + `StorageVersions:` + repeatedStringForStorageVersions + `,`, + `CommonEncodingVersion:` + valueToStringGenerated(this.CommonEncodingVersion) + `,`, + `Conditions:` + repeatedStringForConditions + `,`, + `}`, + }, "") + return s +} +func valueToStringGenerated(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *ServerStorageVersion) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServerStorageVersion: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServerStorageVersion: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field APIServerID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.APIServerID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncodingVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncodingVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecodableVersions", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DecodableVersions = append(m.DecodableVersions, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StorageVersion) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StorageVersion: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StorageVersion: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StorageVersionCondition) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StorageVersionCondition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StorageVersionCondition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = StorageVersionConditionType(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Status = ConditionStatus(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ObservedGeneration", wireType) + } + m.ObservedGeneration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ObservedGeneration |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastTransitionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LastTransitionTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reason = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StorageVersionList) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StorageVersionList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StorageVersionList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, StorageVersion{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StorageVersionSpec) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StorageVersionSpec: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StorageVersionSpec: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StorageVersionStatus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StorageVersionStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StorageVersionStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageVersions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StorageVersions = append(m.StorageVersions, ServerStorageVersion{}) + if err := m.StorageVersions[len(m.StorageVersions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonEncodingVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.CommonEncodingVersion = &s + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conditions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Conditions = append(m.Conditions, StorageVersionCondition{}) + if err := m.Conditions[len(m.Conditions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenerated(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenerated + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenerated + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenerated + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group") +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.proto b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.proto new file mode 100644 index 000000000000..06f45506e59d --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/generated.proto @@ -0,0 +1,121 @@ +/* +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. +*/ + + +// This file was autogenerated by go-to-protobuf. Do not edit it manually! + +syntax = 'proto2'; + +package k8s.io.apiserver.pkg.apis.apiserverinternal.v1alpha1; + +import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; +import "k8s.io/apimachinery/pkg/runtime/generated.proto"; +import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; + +// Package-wide variables from generator "generated". +option go_package = "v1alpha1"; + +// An API server instance reports the version it can decode and the version it +// encodes objects to when persisting objects in the backend. +message ServerStorageVersion { + // The ID of the reporting API server. + optional string apiServerID = 1; + + // The API server encodes the object to this version when persisting it in + // the backend (e.g., etcd). + optional string encodingVersion = 2; + + // The API server can decode objects encoded in these versions. + // The encodingVersion must be included in the decodableVersions. + // +listType=set + repeated string decodableVersions = 3; +} + +// Storage version of a specific resource. +message StorageVersion { + // The name is .. + optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; + + // Spec is an empty spec. It is here to comply with Kubernetes API style. + optional StorageVersionSpec spec = 2; + + // API server instances report the version they can decode and the version they + // encode objects to when persisting objects in the backend. + optional StorageVersionStatus status = 3; +} + +// Describes the state of the storageVersion at a certain point. +message StorageVersionCondition { + // Type of the condition. + // +required + optional string type = 1; + + // Status of the condition, one of True, False, Unknown. + // +required + optional string status = 2; + + // If set, this represents the .metadata.generation that the condition was set based upon. + // +optional + optional int64 observedGeneration = 3; + + // Last time the condition transitioned from one status to another. + // +required + optional k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 4; + + // The reason for the condition's last transition. + // +required + optional string reason = 5; + + // A human readable message indicating details about the transition. + // +required + optional string message = 6; +} + +// A list of StorageVersions. +message StorageVersionList { + // +optional + optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1; + + repeated StorageVersion items = 2; +} + +// StorageVersionSpec is an empty spec. +message StorageVersionSpec { +} + +// API server instances report the versions they can decode and the version they +// encode objects to when persisting objects in the backend. +message StorageVersionStatus { + // The reported versions per API server instance. + // +optional + // +listType=map + // +listMapKey=apiserverID + repeated ServerStorageVersion storageVersions = 1; + + // If all API server instances agree on the same encoding storage version, + // then this field is set to that version. Otherwise this field is left empty. + // API servers should finish updating its storageVersionStatus entry before + // serving write operations, so that this field will be in sync with the reality. + // +optional + optional string commonEncodingVersion = 2; + + // The latest available observations of the storageVersion's state. + // +optional + // +listType=map + // +listMapKey=type + repeated StorageVersionCondition conditions = 3; +} + diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.conversion.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.conversion.go new file mode 100644 index 000000000000..999f99e5c577 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.conversion.go @@ -0,0 +1,249 @@ +// +build !ignore_autogenerated + +/* +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 conversion-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + unsafe "unsafe" + + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + apiserverinternal "k8s.io/apiserver/pkg/apis/apiserverinternal" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*ServerStorageVersion)(nil), (*apiserverinternal.ServerStorageVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ServerStorageVersion_To_apiserverinternal_ServerStorageVersion(a.(*ServerStorageVersion), b.(*apiserverinternal.ServerStorageVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiserverinternal.ServerStorageVersion)(nil), (*ServerStorageVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiserverinternal_ServerStorageVersion_To_v1alpha1_ServerStorageVersion(a.(*apiserverinternal.ServerStorageVersion), b.(*ServerStorageVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StorageVersion)(nil), (*apiserverinternal.StorageVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StorageVersion_To_apiserverinternal_StorageVersion(a.(*StorageVersion), b.(*apiserverinternal.StorageVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiserverinternal.StorageVersion)(nil), (*StorageVersion)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiserverinternal_StorageVersion_To_v1alpha1_StorageVersion(a.(*apiserverinternal.StorageVersion), b.(*StorageVersion), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StorageVersionCondition)(nil), (*apiserverinternal.StorageVersionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StorageVersionCondition_To_apiserverinternal_StorageVersionCondition(a.(*StorageVersionCondition), b.(*apiserverinternal.StorageVersionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiserverinternal.StorageVersionCondition)(nil), (*StorageVersionCondition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiserverinternal_StorageVersionCondition_To_v1alpha1_StorageVersionCondition(a.(*apiserverinternal.StorageVersionCondition), b.(*StorageVersionCondition), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StorageVersionList)(nil), (*apiserverinternal.StorageVersionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StorageVersionList_To_apiserverinternal_StorageVersionList(a.(*StorageVersionList), b.(*apiserverinternal.StorageVersionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiserverinternal.StorageVersionList)(nil), (*StorageVersionList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiserverinternal_StorageVersionList_To_v1alpha1_StorageVersionList(a.(*apiserverinternal.StorageVersionList), b.(*StorageVersionList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StorageVersionSpec)(nil), (*apiserverinternal.StorageVersionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StorageVersionSpec_To_apiserverinternal_StorageVersionSpec(a.(*StorageVersionSpec), b.(*apiserverinternal.StorageVersionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiserverinternal.StorageVersionSpec)(nil), (*StorageVersionSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiserverinternal_StorageVersionSpec_To_v1alpha1_StorageVersionSpec(a.(*apiserverinternal.StorageVersionSpec), b.(*StorageVersionSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*StorageVersionStatus)(nil), (*apiserverinternal.StorageVersionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_StorageVersionStatus_To_apiserverinternal_StorageVersionStatus(a.(*StorageVersionStatus), b.(*apiserverinternal.StorageVersionStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*apiserverinternal.StorageVersionStatus)(nil), (*StorageVersionStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_apiserverinternal_StorageVersionStatus_To_v1alpha1_StorageVersionStatus(a.(*apiserverinternal.StorageVersionStatus), b.(*StorageVersionStatus), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha1_ServerStorageVersion_To_apiserverinternal_ServerStorageVersion(in *ServerStorageVersion, out *apiserverinternal.ServerStorageVersion, s conversion.Scope) error { + out.APIServerID = in.APIServerID + out.EncodingVersion = in.EncodingVersion + out.DecodableVersions = *(*[]string)(unsafe.Pointer(&in.DecodableVersions)) + return nil +} + +// Convert_v1alpha1_ServerStorageVersion_To_apiserverinternal_ServerStorageVersion is an autogenerated conversion function. +func Convert_v1alpha1_ServerStorageVersion_To_apiserverinternal_ServerStorageVersion(in *ServerStorageVersion, out *apiserverinternal.ServerStorageVersion, s conversion.Scope) error { + return autoConvert_v1alpha1_ServerStorageVersion_To_apiserverinternal_ServerStorageVersion(in, out, s) +} + +func autoConvert_apiserverinternal_ServerStorageVersion_To_v1alpha1_ServerStorageVersion(in *apiserverinternal.ServerStorageVersion, out *ServerStorageVersion, s conversion.Scope) error { + out.APIServerID = in.APIServerID + out.EncodingVersion = in.EncodingVersion + out.DecodableVersions = *(*[]string)(unsafe.Pointer(&in.DecodableVersions)) + return nil +} + +// Convert_apiserverinternal_ServerStorageVersion_To_v1alpha1_ServerStorageVersion is an autogenerated conversion function. +func Convert_apiserverinternal_ServerStorageVersion_To_v1alpha1_ServerStorageVersion(in *apiserverinternal.ServerStorageVersion, out *ServerStorageVersion, s conversion.Scope) error { + return autoConvert_apiserverinternal_ServerStorageVersion_To_v1alpha1_ServerStorageVersion(in, out, s) +} + +func autoConvert_v1alpha1_StorageVersion_To_apiserverinternal_StorageVersion(in *StorageVersion, out *apiserverinternal.StorageVersion, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1alpha1_StorageVersionSpec_To_apiserverinternal_StorageVersionSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1alpha1_StorageVersionStatus_To_apiserverinternal_StorageVersionStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1alpha1_StorageVersion_To_apiserverinternal_StorageVersion is an autogenerated conversion function. +func Convert_v1alpha1_StorageVersion_To_apiserverinternal_StorageVersion(in *StorageVersion, out *apiserverinternal.StorageVersion, s conversion.Scope) error { + return autoConvert_v1alpha1_StorageVersion_To_apiserverinternal_StorageVersion(in, out, s) +} + +func autoConvert_apiserverinternal_StorageVersion_To_v1alpha1_StorageVersion(in *apiserverinternal.StorageVersion, out *StorageVersion, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_apiserverinternal_StorageVersionSpec_To_v1alpha1_StorageVersionSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_apiserverinternal_StorageVersionStatus_To_v1alpha1_StorageVersionStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_apiserverinternal_StorageVersion_To_v1alpha1_StorageVersion is an autogenerated conversion function. +func Convert_apiserverinternal_StorageVersion_To_v1alpha1_StorageVersion(in *apiserverinternal.StorageVersion, out *StorageVersion, s conversion.Scope) error { + return autoConvert_apiserverinternal_StorageVersion_To_v1alpha1_StorageVersion(in, out, s) +} + +func autoConvert_v1alpha1_StorageVersionCondition_To_apiserverinternal_StorageVersionCondition(in *StorageVersionCondition, out *apiserverinternal.StorageVersionCondition, s conversion.Scope) error { + out.Type = apiserverinternal.StorageVersionConditionType(in.Type) + out.Status = apiserverinternal.ConditionStatus(in.Status) + out.ObservedGeneration = in.ObservedGeneration + out.LastTransitionTime = in.LastTransitionTime + out.Reason = in.Reason + out.Message = in.Message + return nil +} + +// Convert_v1alpha1_StorageVersionCondition_To_apiserverinternal_StorageVersionCondition is an autogenerated conversion function. +func Convert_v1alpha1_StorageVersionCondition_To_apiserverinternal_StorageVersionCondition(in *StorageVersionCondition, out *apiserverinternal.StorageVersionCondition, s conversion.Scope) error { + return autoConvert_v1alpha1_StorageVersionCondition_To_apiserverinternal_StorageVersionCondition(in, out, s) +} + +func autoConvert_apiserverinternal_StorageVersionCondition_To_v1alpha1_StorageVersionCondition(in *apiserverinternal.StorageVersionCondition, out *StorageVersionCondition, s conversion.Scope) error { + out.Type = StorageVersionConditionType(in.Type) + out.Status = ConditionStatus(in.Status) + out.ObservedGeneration = in.ObservedGeneration + out.LastTransitionTime = in.LastTransitionTime + out.Reason = in.Reason + out.Message = in.Message + return nil +} + +// Convert_apiserverinternal_StorageVersionCondition_To_v1alpha1_StorageVersionCondition is an autogenerated conversion function. +func Convert_apiserverinternal_StorageVersionCondition_To_v1alpha1_StorageVersionCondition(in *apiserverinternal.StorageVersionCondition, out *StorageVersionCondition, s conversion.Scope) error { + return autoConvert_apiserverinternal_StorageVersionCondition_To_v1alpha1_StorageVersionCondition(in, out, s) +} + +func autoConvert_v1alpha1_StorageVersionList_To_apiserverinternal_StorageVersionList(in *StorageVersionList, out *apiserverinternal.StorageVersionList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]apiserverinternal.StorageVersion)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1alpha1_StorageVersionList_To_apiserverinternal_StorageVersionList is an autogenerated conversion function. +func Convert_v1alpha1_StorageVersionList_To_apiserverinternal_StorageVersionList(in *StorageVersionList, out *apiserverinternal.StorageVersionList, s conversion.Scope) error { + return autoConvert_v1alpha1_StorageVersionList_To_apiserverinternal_StorageVersionList(in, out, s) +} + +func autoConvert_apiserverinternal_StorageVersionList_To_v1alpha1_StorageVersionList(in *apiserverinternal.StorageVersionList, out *StorageVersionList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]StorageVersion)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_apiserverinternal_StorageVersionList_To_v1alpha1_StorageVersionList is an autogenerated conversion function. +func Convert_apiserverinternal_StorageVersionList_To_v1alpha1_StorageVersionList(in *apiserverinternal.StorageVersionList, out *StorageVersionList, s conversion.Scope) error { + return autoConvert_apiserverinternal_StorageVersionList_To_v1alpha1_StorageVersionList(in, out, s) +} + +func autoConvert_v1alpha1_StorageVersionSpec_To_apiserverinternal_StorageVersionSpec(in *StorageVersionSpec, out *apiserverinternal.StorageVersionSpec, s conversion.Scope) error { + return nil +} + +// Convert_v1alpha1_StorageVersionSpec_To_apiserverinternal_StorageVersionSpec is an autogenerated conversion function. +func Convert_v1alpha1_StorageVersionSpec_To_apiserverinternal_StorageVersionSpec(in *StorageVersionSpec, out *apiserverinternal.StorageVersionSpec, s conversion.Scope) error { + return autoConvert_v1alpha1_StorageVersionSpec_To_apiserverinternal_StorageVersionSpec(in, out, s) +} + +func autoConvert_apiserverinternal_StorageVersionSpec_To_v1alpha1_StorageVersionSpec(in *apiserverinternal.StorageVersionSpec, out *StorageVersionSpec, s conversion.Scope) error { + return nil +} + +// Convert_apiserverinternal_StorageVersionSpec_To_v1alpha1_StorageVersionSpec is an autogenerated conversion function. +func Convert_apiserverinternal_StorageVersionSpec_To_v1alpha1_StorageVersionSpec(in *apiserverinternal.StorageVersionSpec, out *StorageVersionSpec, s conversion.Scope) error { + return autoConvert_apiserverinternal_StorageVersionSpec_To_v1alpha1_StorageVersionSpec(in, out, s) +} + +func autoConvert_v1alpha1_StorageVersionStatus_To_apiserverinternal_StorageVersionStatus(in *StorageVersionStatus, out *apiserverinternal.StorageVersionStatus, s conversion.Scope) error { + out.StorageVersions = *(*[]apiserverinternal.ServerStorageVersion)(unsafe.Pointer(&in.StorageVersions)) + out.CommonEncodingVersion = (*string)(unsafe.Pointer(in.CommonEncodingVersion)) + out.Conditions = *(*[]apiserverinternal.StorageVersionCondition)(unsafe.Pointer(&in.Conditions)) + return nil +} + +// Convert_v1alpha1_StorageVersionStatus_To_apiserverinternal_StorageVersionStatus is an autogenerated conversion function. +func Convert_v1alpha1_StorageVersionStatus_To_apiserverinternal_StorageVersionStatus(in *StorageVersionStatus, out *apiserverinternal.StorageVersionStatus, s conversion.Scope) error { + return autoConvert_v1alpha1_StorageVersionStatus_To_apiserverinternal_StorageVersionStatus(in, out, s) +} + +func autoConvert_apiserverinternal_StorageVersionStatus_To_v1alpha1_StorageVersionStatus(in *apiserverinternal.StorageVersionStatus, out *StorageVersionStatus, s conversion.Scope) error { + out.StorageVersions = *(*[]ServerStorageVersion)(unsafe.Pointer(&in.StorageVersions)) + out.CommonEncodingVersion = (*string)(unsafe.Pointer(in.CommonEncodingVersion)) + out.Conditions = *(*[]StorageVersionCondition)(unsafe.Pointer(&in.Conditions)) + return nil +} + +// Convert_apiserverinternal_StorageVersionStatus_To_v1alpha1_StorageVersionStatus is an autogenerated conversion function. +func Convert_apiserverinternal_StorageVersionStatus_To_v1alpha1_StorageVersionStatus(in *apiserverinternal.StorageVersionStatus, out *StorageVersionStatus, s conversion.Scope) error { + return autoConvert_apiserverinternal_StorageVersionStatus_To_v1alpha1_StorageVersionStatus(in, out, s) +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000000..7e82a9070fd9 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,175 @@ +// +build !ignore_autogenerated + +/* +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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerStorageVersion) DeepCopyInto(out *ServerStorageVersion) { + *out = *in + if in.DecodableVersions != nil { + in, out := &in.DecodableVersions, &out.DecodableVersions + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerStorageVersion. +func (in *ServerStorageVersion) DeepCopy() *ServerStorageVersion { + if in == nil { + return nil + } + out := new(ServerStorageVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersion) DeepCopyInto(out *StorageVersion) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersion. +func (in *StorageVersion) DeepCopy() *StorageVersion { + if in == nil { + return nil + } + out := new(StorageVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageVersion) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionCondition) DeepCopyInto(out *StorageVersionCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionCondition. +func (in *StorageVersionCondition) DeepCopy() *StorageVersionCondition { + if in == nil { + return nil + } + out := new(StorageVersionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionList) DeepCopyInto(out *StorageVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionList. +func (in *StorageVersionList) DeepCopy() *StorageVersionList { + if in == nil { + return nil + } + out := new(StorageVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageVersionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionSpec) DeepCopyInto(out *StorageVersionSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionSpec. +func (in *StorageVersionSpec) DeepCopy() *StorageVersionSpec { + if in == nil { + return nil + } + out := new(StorageVersionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionStatus) DeepCopyInto(out *StorageVersionStatus) { + *out = *in + if in.StorageVersions != nil { + in, out := &in.StorageVersions, &out.StorageVersions + *out = make([]ServerStorageVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CommonEncodingVersion != nil { + in, out := &in.CommonEncodingVersion, &out.CommonEncodingVersion + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]StorageVersionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionStatus. +func (in *StorageVersionStatus) DeepCopy() *StorageVersionStatus { + if in == nil { + return nil + } + out := new(StorageVersionStatus) + in.DeepCopyInto(out) + return out +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.defaults.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.defaults.go new file mode 100644 index 000000000000..dd621a3acda8 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1/zz_generated.defaults.go @@ -0,0 +1,32 @@ +// +build !ignore_autogenerated + +/* +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 defaulter-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD index 27e5d8ce21a8..1eef2a469ea1 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation/BUILD @@ -1,6 +1,6 @@ package(default_visibility = ["//visibility:public"]) -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", @@ -8,6 +8,8 @@ go_library( importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/validation", importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/validation", deps = [ + "//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:go_default_library", ], @@ -25,3 +27,13 @@ filegroup( srcs = [":package-srcs"], tags = ["automanaged"], ) + +go_test( + name = "go_default_test", + srcs = ["validation_test.go"], + embed = [":go_default_library"], + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:go_default_library", + ], +) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/zz_generated.deepcopy.go b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/zz_generated.deepcopy.go new file mode 100644 index 000000000000..0e8861608b21 --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/zz_generated.deepcopy.go @@ -0,0 +1,175 @@ +// +build !ignore_autogenerated + +/* +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 deepcopy-gen. DO NOT EDIT. + +package apiserverinternal + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerStorageVersion) DeepCopyInto(out *ServerStorageVersion) { + *out = *in + if in.DecodableVersions != nil { + in, out := &in.DecodableVersions, &out.DecodableVersions + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerStorageVersion. +func (in *ServerStorageVersion) DeepCopy() *ServerStorageVersion { + if in == nil { + return nil + } + out := new(ServerStorageVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersion) DeepCopyInto(out *StorageVersion) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersion. +func (in *StorageVersion) DeepCopy() *StorageVersion { + if in == nil { + return nil + } + out := new(StorageVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageVersion) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionCondition) DeepCopyInto(out *StorageVersionCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionCondition. +func (in *StorageVersionCondition) DeepCopy() *StorageVersionCondition { + if in == nil { + return nil + } + out := new(StorageVersionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionList) DeepCopyInto(out *StorageVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionList. +func (in *StorageVersionList) DeepCopy() *StorageVersionList { + if in == nil { + return nil + } + out := new(StorageVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageVersionList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionSpec) DeepCopyInto(out *StorageVersionSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionSpec. +func (in *StorageVersionSpec) DeepCopy() *StorageVersionSpec { + if in == nil { + return nil + } + out := new(StorageVersionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageVersionStatus) DeepCopyInto(out *StorageVersionStatus) { + *out = *in + if in.StorageVersions != nil { + in, out := &in.StorageVersions, &out.StorageVersions + *out = make([]ServerStorageVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CommonEncodingVersion != nil { + in, out := &in.CommonEncodingVersion, &out.CommonEncodingVersion + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]StorageVersionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageVersionStatus. +func (in *StorageVersionStatus) DeepCopy() *StorageVersionStatus { + if in == nil { + return nil + } + out := new(StorageVersionStatus) + in.DeepCopyInto(out) + return out +}