diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/OWNERS b/staging/src/k8s.io/apimachinery/pkg/apis/config/OWNERS deleted file mode 100644 index 2f7b10df4b..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/OWNERS +++ /dev/null @@ -1,7 +0,0 @@ -approvers: -- api-approvers -- sttts -- luxas -reviewers: -- api-reviewers -- hanxiaoshuai diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/types.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/types.go deleted file mode 100644 index b32fc8a281..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/types.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2018 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 config - -// ClientConnectionConfiguration contains details for constructing a client. -type ClientConnectionConfiguration struct { - // kubeconfig is the path to a KubeConfig file. - Kubeconfig string - // acceptContentTypes defines the Accept header sent by clients when connecting to a server, overriding the - // default value of 'application/json'. This field will control all connections to the server used by a particular - // client. - AcceptContentTypes string - // contentType is the content type used when sending data to the server from this client. - ContentType string - // qps controls the number of queries per second allowed for this connection. - QPS float32 - // burst allows extra queries to accumulate when a client is exceeding its rate. - Burst int32 -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/BUILD b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/BUILD deleted file mode 100644 index 576f861b27..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/BUILD +++ /dev/null @@ -1,36 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "conversion.go", - "defaults.go", - "doc.go", - "register.go", - "types.go", - "zz_generated.conversion.go", - "zz_generated.deepcopy.go", - ], - importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/config/v1alpha1", - importpath = "k8s.io/apimachinery/pkg/apis/config/v1alpha1", - visibility = ["//visibility:public"], - deps = [ - "//staging/src/k8s.io/apimachinery/pkg/apis/config:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/runtime: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/apimachinery/pkg/apis/config/v1alpha1/conversion.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/conversion.go deleted file mode 100644 index 7e7d34795e..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/conversion.go +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright 2018 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 ( - "k8s.io/apimachinery/pkg/apis/config" - "k8s.io/apimachinery/pkg/conversion" -) - -// Important! The public back-and-forth conversion functions for the types in this generic -// package with ComponentConfig types need to be manually exposed like this in order for -// other packages that reference this package to be able to call these conversion functions -// in an autogenerated manner. -// TODO: Fix the bug in conversion-gen so it automatically discovers these Convert_* functions -// in autogenerated code as well. - -func Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(in *ClientConnectionConfiguration, out *config.ClientConnectionConfiguration, s conversion.Scope) error { - return autoConvert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(in, out, s) -} - -func Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(in *config.ClientConnectionConfiguration, out *ClientConnectionConfiguration, s conversion.Scope) error { - return autoConvert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(in, out, s) -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/defaults.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/defaults.go deleted file mode 100644 index 37971fcc5c..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/defaults.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2018 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 - -// RecommendedDefaultClientConnectionConfiguration defaults a pointer to a -// ClientConnectionConfiguration struct. This will set the recommended default -// values, but they may be subject to change between API versions. This function -// is intentionally not registered in the scheme as a "normal" `SetDefaults_Foo` -// function to allow consumers of this type to set whatever defaults for their -// embedded configs. Forcing consumers to use these defaults would be problematic -// as defaulting in the scheme is done as part of the conversion, and there would -// be no easy way to opt-out. Instead, if you want to use this defaulting method -// run it in your wrapper struct of this type in its `SetDefaults_` method. -func RecommendedDefaultClientConnectionConfiguration(obj *ClientConnectionConfiguration) { - if len(obj.ContentType) == 0 { - obj.ContentType = "application/vnd.kubernetes.protobuf" - } - if obj.QPS == 0.0 { - obj.QPS = 50.0 - } - if obj.Burst == 0 { - obj.Burst = 100 - } -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/doc.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/doc.go deleted file mode 100644 index ce0a58a571..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2018 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:conversion-gen=k8s.io/apimachinery/pkg/apis/config - -package v1alpha1 // import "k8s.io/apimachinery/pkg/apis/config/v1alpha1" diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/types.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/types.go deleted file mode 100644 index b762c4f0bb..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/types.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2018 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 - -// ClientConnectionConfiguration contains details for constructing a client. -type ClientConnectionConfiguration struct { - // kubeconfig is the path to a KubeConfig file. - Kubeconfig string `json:"kubeconfig"` - // acceptContentTypes defines the Accept header sent by clients when connecting to a server, overriding the - // default value of 'application/json'. This field will control all connections to the server used by a particular - // client. - AcceptContentTypes string `json:"acceptContentTypes"` - // contentType is the content type used when sending data to the server from this client. - ContentType string `json:"contentType"` - // qps controls the number of queries per second allowed for this connection. - QPS float32 `json:"qps"` - // burst allows extra queries to accumulate when a client is exceeding its rate. - Burst int32 `json:"burst"` -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/zz_generated.conversion.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/zz_generated.conversion.go deleted file mode 100644 index 4cea203cc4..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/zz_generated.conversion.go +++ /dev/null @@ -1,75 +0,0 @@ -// +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 ( - config "k8s.io/apimachinery/pkg/apis/config" - conversion "k8s.io/apimachinery/pkg/conversion" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -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((*ClientConnectionConfiguration)(nil), (*config.ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(a.(*ClientConnectionConfiguration), b.(*config.ClientConnectionConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*config.ClientConnectionConfiguration)(nil), (*ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(a.(*config.ClientConnectionConfiguration), b.(*ClientConnectionConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*config.ClientConnectionConfiguration)(nil), (*ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(a.(*config.ClientConnectionConfiguration), b.(*ClientConnectionConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*ClientConnectionConfiguration)(nil), (*config.ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(a.(*ClientConnectionConfiguration), b.(*config.ClientConnectionConfiguration), scope) - }); err != nil { - return err - } - return nil -} - -func autoConvert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(in *ClientConnectionConfiguration, out *config.ClientConnectionConfiguration, s conversion.Scope) error { - out.Kubeconfig = in.Kubeconfig - out.AcceptContentTypes = in.AcceptContentTypes - out.ContentType = in.ContentType - out.QPS = in.QPS - out.Burst = in.Burst - return nil -} - -func autoConvert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(in *config.ClientConnectionConfiguration, out *ClientConnectionConfiguration, s conversion.Scope) error { - out.Kubeconfig = in.Kubeconfig - out.AcceptContentTypes = in.AcceptContentTypes - out.ContentType = in.ContentType - out.QPS = in.QPS - out.Burst = in.Burst - return nil -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index d03adfbff9..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,37 +0,0 @@ -// +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 - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClientConnectionConfiguration) DeepCopyInto(out *ClientConnectionConfiguration) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClientConnectionConfiguration. -func (in *ClientConnectionConfiguration) DeepCopy() *ClientConnectionConfiguration { - if in == nil { - return nil - } - out := new(ClientConnectionConfiguration) - in.DeepCopyInto(out) - return out -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/BUILD b/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/BUILD deleted file mode 100644 index f84ca74498..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/BUILD +++ /dev/null @@ -1,37 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = ["validation.go"], - importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/config/validation", - importpath = "k8s.io/apimachinery/pkg/apis/config/validation", - visibility = ["//visibility:public"], - deps = [ - "//staging/src/k8s.io/apimachinery/pkg/apis/config:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = ["validation_test.go"], - embed = [":go_default_library"], - deps = [ - "//staging/src/k8s.io/apimachinery/pkg/apis/config:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/util/validation/field: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/apimachinery/pkg/apis/config/validation/validation.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/validation.go deleted file mode 100644 index dba3767744..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/validation.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2018 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 ( - "k8s.io/apimachinery/pkg/apis/config" - "k8s.io/apimachinery/pkg/util/validation/field" -) - -// ValidateClientConnectionConfiguration ensures validation of the ClientConnectionConfiguration struct -func ValidateClientConnectionConfiguration(cc *config.ClientConnectionConfiguration, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - if cc.Burst < 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("burst"), cc.Burst, "must be non-negative")) - } - return allErrs -} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/validation_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/validation_test.go deleted file mode 100644 index dfa0376740..0000000000 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/validation/validation_test.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2018 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 ( - "k8s.io/apimachinery/pkg/apis/config" - "k8s.io/apimachinery/pkg/util/validation/field" - "testing" -) - -func TestValidateClientConnectionConfiguration(t *testing.T) { - validConfig := &config.ClientConnectionConfiguration{ - AcceptContentTypes: "application/json", - ContentType: "application/json", - QPS: 10, - Burst: 10, - } - - qpsLessThanZero := validConfig.DeepCopy() - qpsLessThanZero.QPS = -1 - - burstLessThanZero := validConfig.DeepCopy() - burstLessThanZero.Burst = -1 - - scenarios := map[string]struct { - expectedToFail bool - config *config.ClientConnectionConfiguration - }{ - "good": { - expectedToFail: false, - config: validConfig, - }, - "good-qps-less-than-zero": { - expectedToFail: false, - config: qpsLessThanZero, - }, - "bad-burst-less-then-zero": { - expectedToFail: true, - config: burstLessThanZero, - }, - } - - for name, scenario := range scenarios { - errs := ValidateClientConnectionConfiguration(scenario.config, field.NewPath("clientConnectionConfiguration")) - if len(errs) == 0 && scenario.expectedToFail { - t.Errorf("Unexpected success for scenario: %s", name) - } - if len(errs) > 0 && !scenario.expectedToFail { - t.Errorf("Unexpected failure for scenario: %s - %+v", name, errs) - } - } -} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/BUILD b/staging/src/k8s.io/apiserver/pkg/apis/config/BUILD index feaa8a3c37..ce25409aaa 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/apis/config/BUILD @@ -30,8 +30,6 @@ filegroup( srcs = [ ":package-srcs", "//staging/src/k8s.io/apiserver/pkg/apis/config/v1:all-srcs", - "//staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1:all-srcs", - "//staging/src/k8s.io/apiserver/pkg/apis/config/validation:all-srcs", ], tags = ["automanaged"], visibility = ["//visibility:public"], diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/types.go b/staging/src/k8s.io/apiserver/pkg/apis/config/types.go index 822806d7e5..0b0d8254c0 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/types.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/config/types.go @@ -20,43 +20,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// LeaderElectionConfiguration defines the configuration of leader election -// clients for components that can run with leader election enabled. -type LeaderElectionConfiguration struct { - // leaderElect enables a leader election client to gain leadership - // before executing the main loop. Enable this when running replicated - // components for high availability. - LeaderElect bool - // leaseDuration is the duration that non-leader candidates will wait - // after observing a leadership renewal until attempting to acquire - // leadership of a led but unrenewed leader slot. This is effectively the - // maximum duration that a leader can be stopped before it is replaced - // by another candidate. This is only applicable if leader election is - // enabled. - LeaseDuration metav1.Duration - // renewDeadline is the interval between attempts by the acting master to - // renew a leadership slot before it stops leading. This must be less - // than or equal to the lease duration. This is only applicable if leader - // election is enabled. - RenewDeadline metav1.Duration - // retryPeriod is the duration the clients should wait between attempting - // acquisition and renewal of a leadership. This is only applicable if - // leader election is enabled. - RetryPeriod metav1.Duration - // resourceLock indicates the resource object type that will be used to lock - // during leader election cycles. - ResourceLock string -} - -// DebuggingConfiguration holds configuration for Debugging related features. -type DebuggingConfiguration struct { - // enableProfiling enables profiling via web interface host:port/debug/pprof/ - EnableProfiling bool - // enableContentionProfiling enables lock contention profiling, if - // enableProfiling is true. - EnableContentionProfiling bool -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // EncryptionConfiguration stores the complete configuration for encryption providers. diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/register.go b/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/register.go deleted file mode 100644 index ddc186c9aa..0000000000 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/register.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2018 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 ( - "k8s.io/apimachinery/pkg/runtime" -) - -var ( - // SchemeBuilder is the scheme builder with scheme init functions to run for this API package - SchemeBuilder runtime.SchemeBuilder - // localSchemeBuilder extends the SchemeBuilder instance with the external types. In this package, - // defaulting and conversion init funcs are registered as well. - localSchemeBuilder = &SchemeBuilder - // AddToScheme is a global function that registers this API group & version to a scheme - AddToScheme = localSchemeBuilder.AddToScheme -) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/zz_generated.deepcopy.go b/staging/src/k8s.io/apiserver/pkg/apis/config/zz_generated.deepcopy.go index 438dff997d..f5a16a51c4 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/apiserver/pkg/apis/config/zz_generated.deepcopy.go @@ -45,22 +45,6 @@ func (in *AESConfiguration) DeepCopy() *AESConfiguration { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DebuggingConfiguration) DeepCopyInto(out *DebuggingConfiguration) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DebuggingConfiguration. -func (in *DebuggingConfiguration) DeepCopy() *DebuggingConfiguration { - if in == nil { - return nil - } - out := new(DebuggingConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EncryptionConfiguration) DeepCopyInto(out *EncryptionConfiguration) { *out = *in @@ -141,25 +125,6 @@ func (in *Key) DeepCopy() *Key { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LeaderElectionConfiguration) DeepCopyInto(out *LeaderElectionConfiguration) { - *out = *in - out.LeaseDuration = in.LeaseDuration - out.RenewDeadline = in.RenewDeadline - out.RetryPeriod = in.RetryPeriod - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeaderElectionConfiguration. -func (in *LeaderElectionConfiguration) DeepCopy() *LeaderElectionConfiguration { - if in == nil { - return nil - } - out := new(LeaderElectionConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ProviderConfiguration) DeepCopyInto(out *ProviderConfiguration) { *out = *in diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/BUILD b/staging/src/k8s.io/component-base/config/BUILD similarity index 59% rename from staging/src/k8s.io/apimachinery/pkg/apis/config/BUILD rename to staging/src/k8s.io/component-base/config/BUILD index 45016d21ac..7301ed294d 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/BUILD +++ b/staging/src/k8s.io/component-base/config/BUILD @@ -7,9 +7,10 @@ go_library( "types.go", "zz_generated.deepcopy.go", ], - importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/config", - importpath = "k8s.io/apimachinery/pkg/apis/config", + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/config", + importpath = "k8s.io/component-base/config", visibility = ["//visibility:public"], + deps = ["//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library"], ) filegroup( @@ -23,8 +24,8 @@ filegroup( name = "all-srcs", srcs = [ ":package-srcs", - "//staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1:all-srcs", - "//staging/src/k8s.io/apimachinery/pkg/apis/config/validation:all-srcs", + "//staging/src/k8s.io/component-base/config/v1alpha1:all-srcs", + "//staging/src/k8s.io/component-base/config/validation:all-srcs", ], tags = ["automanaged"], visibility = ["//visibility:public"], diff --git a/staging/src/k8s.io/component-base/config/OWNERS b/staging/src/k8s.io/component-base/config/OWNERS new file mode 100644 index 0000000000..e0c2557b84 --- /dev/null +++ b/staging/src/k8s.io/component-base/config/OWNERS @@ -0,0 +1,12 @@ +# Disable inheritance as this is an api owners file +options: + no_parent_owners: true +approvers: +- api-approvers +reviewers: +- api-reviewers +- luxas +- mtaufen +- sttts +labels: +- kind/api-change diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go b/staging/src/k8s.io/component-base/config/doc.go similarity index 90% rename from staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go rename to staging/src/k8s.io/component-base/config/doc.go index d849c7aa3b..dd0a5a53a7 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go +++ b/staging/src/k8s.io/component-base/config/doc.go @@ -16,4 +16,4 @@ limitations under the License. // +k8s:deepcopy-gen=package -package config // import "k8s.io/apimachinery/pkg/apis/config" +package config // import "k8s.io/component-base/config" diff --git a/staging/src/k8s.io/component-base/config/types.go b/staging/src/k8s.io/component-base/config/types.go new file mode 100644 index 0000000000..f0a20915cc --- /dev/null +++ b/staging/src/k8s.io/component-base/config/types.go @@ -0,0 +1,74 @@ +/* +Copyright 2018 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 config + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ClientConnectionConfiguration contains details for constructing a client. +type ClientConnectionConfiguration struct { + // kubeconfig is the path to a KubeConfig file. + Kubeconfig string + // acceptContentTypes defines the Accept header sent by clients when connecting to a server, overriding the + // default value of 'application/json'. This field will control all connections to the server used by a particular + // client. + AcceptContentTypes string + // contentType is the content type used when sending data to the server from this client. + ContentType string + // qps controls the number of queries per second allowed for this connection. + QPS float32 + // burst allows extra queries to accumulate when a client is exceeding its rate. + Burst int32 +} + +// LeaderElectionConfiguration defines the configuration of leader election +// clients for components that can run with leader election enabled. +type LeaderElectionConfiguration struct { + // leaderElect enables a leader election client to gain leadership + // before executing the main loop. Enable this when running replicated + // components for high availability. + LeaderElect bool + // leaseDuration is the duration that non-leader candidates will wait + // after observing a leadership renewal until attempting to acquire + // leadership of a led but unrenewed leader slot. This is effectively the + // maximum duration that a leader can be stopped before it is replaced + // by another candidate. This is only applicable if leader election is + // enabled. + LeaseDuration metav1.Duration + // renewDeadline is the interval between attempts by the acting master to + // renew a leadership slot before it stops leading. This must be less + // than or equal to the lease duration. This is only applicable if leader + // election is enabled. + RenewDeadline metav1.Duration + // retryPeriod is the duration the clients should wait between attempting + // acquisition and renewal of a leadership. This is only applicable if + // leader election is enabled. + RetryPeriod metav1.Duration + // resourceLock indicates the resource object type that will be used to lock + // during leader election cycles. + ResourceLock string +} + +// DebuggingConfiguration holds configuration for Debugging related features. +type DebuggingConfiguration struct { + // enableProfiling enables profiling via web interface host:port/debug/pprof/ + EnableProfiling bool + // enableContentionProfiling enables lock contention profiling, if + // enableProfiling is true. + EnableContentionProfiling bool +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/BUILD b/staging/src/k8s.io/component-base/config/v1alpha1/BUILD similarity index 80% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/BUILD rename to staging/src/k8s.io/component-base/config/v1alpha1/BUILD index 067f019c66..d6deae7a9b 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/BUILD +++ b/staging/src/k8s.io/component-base/config/v1alpha1/BUILD @@ -11,14 +11,14 @@ go_library( "zz_generated.conversion.go", "zz_generated.deepcopy.go", ], - importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/config/v1alpha1", - importpath = "k8s.io/apiserver/pkg/apis/config/v1alpha1", + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/config/v1alpha1", + importpath = "k8s.io/component-base/config/v1alpha1", visibility = ["//visibility:public"], 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/apiserver/pkg/apis/config:go_default_library", + "//staging/src/k8s.io/component-base/config:go_default_library", "//vendor/k8s.io/utils/pointer:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/conversion.go b/staging/src/k8s.io/component-base/config/v1alpha1/conversion.go similarity index 77% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/conversion.go rename to staging/src/k8s.io/component-base/config/v1alpha1/conversion.go index 75190ad161..e2951e310d 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/conversion.go +++ b/staging/src/k8s.io/component-base/config/v1alpha1/conversion.go @@ -18,7 +18,7 @@ package v1alpha1 import ( "k8s.io/apimachinery/pkg/conversion" - "k8s.io/apiserver/pkg/apis/config" + "k8s.io/component-base/config" ) // Important! The public back-and-forth conversion functions for the types in this generic @@ -28,6 +28,14 @@ import ( // TODO: Fix the bug in conversion-gen so it automatically discovers these Convert_* functions // in autogenerated code as well. +func Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(in *ClientConnectionConfiguration, out *config.ClientConnectionConfiguration, s conversion.Scope) error { + return autoConvert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(in, out, s) +} + +func Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(in *config.ClientConnectionConfiguration, out *ClientConnectionConfiguration, s conversion.Scope) error { + return autoConvert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(in, out, s) +} + func Convert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(in *DebuggingConfiguration, out *config.DebuggingConfiguration, s conversion.Scope) error { return autoConvert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(in, out, s) } diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/defaults.go b/staging/src/k8s.io/component-base/config/v1alpha1/defaults.go similarity index 66% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/defaults.go rename to staging/src/k8s.io/component-base/config/v1alpha1/defaults.go index caee3d8e49..caeb869a37 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/defaults.go +++ b/staging/src/k8s.io/component-base/config/v1alpha1/defaults.go @@ -50,3 +50,24 @@ func RecommendedDefaultLeaderElectionConfiguration(obj *LeaderElectionConfigurat obj.LeaderElect = utilpointer.BoolPtr(true) } } + +// RecommendedDefaultClientConnectionConfiguration defaults a pointer to a +// ClientConnectionConfiguration struct. This will set the recommended default +// values, but they may be subject to change between API versions. This function +// is intentionally not registered in the scheme as a "normal" `SetDefaults_Foo` +// function to allow consumers of this type to set whatever defaults for their +// embedded configs. Forcing consumers to use these defaults would be problematic +// as defaulting in the scheme is done as part of the conversion, and there would +// be no easy way to opt-out. Instead, if you want to use this defaulting method +// run it in your wrapper struct of this type in its `SetDefaults_` method. +func RecommendedDefaultClientConnectionConfiguration(obj *ClientConnectionConfiguration) { + if len(obj.ContentType) == 0 { + obj.ContentType = "application/vnd.kubernetes.protobuf" + } + if obj.QPS == 0.0 { + obj.QPS = 50.0 + } + if obj.Burst == 0 { + obj.Burst = 100 + } +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/doc.go b/staging/src/k8s.io/component-base/config/v1alpha1/doc.go similarity index 82% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/doc.go rename to staging/src/k8s.io/component-base/config/v1alpha1/doc.go index a7492964ef..3cd4f4292e 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/doc.go +++ b/staging/src/k8s.io/component-base/config/v1alpha1/doc.go @@ -15,6 +15,6 @@ limitations under the License. */ // +k8s:deepcopy-gen=package -// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/config +// +k8s:conversion-gen=k8s.io/component-base/config -package v1alpha1 // import "k8s.io/apiserver/pkg/apis/config/v1alpha1" +package v1alpha1 // import "k8s.io/component-base/config/v1alpha1" diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/register.go b/staging/src/k8s.io/component-base/config/v1alpha1/register.go similarity index 100% rename from staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/register.go rename to staging/src/k8s.io/component-base/config/v1alpha1/register.go diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/types.go b/staging/src/k8s.io/component-base/config/v1alpha1/types.go similarity index 75% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/types.go rename to staging/src/k8s.io/component-base/config/v1alpha1/types.go index f5ca97151a..d5a0391a20 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/types.go +++ b/staging/src/k8s.io/component-base/config/v1alpha1/types.go @@ -58,3 +58,19 @@ type DebuggingConfiguration struct { // enableProfiling is true. EnableContentionProfiling bool `json:"enableContentionProfiling"` } + +// ClientConnectionConfiguration contains details for constructing a client. +type ClientConnectionConfiguration struct { + // kubeconfig is the path to a KubeConfig file. + Kubeconfig string `json:"kubeconfig"` + // acceptContentTypes defines the Accept header sent by clients when connecting to a server, overriding the + // default value of 'application/json'. This field will control all connections to the server used by a particular + // client. + AcceptContentTypes string `json:"acceptContentTypes"` + // contentType is the content type used when sending data to the server from this client. + ContentType string `json:"contentType"` + // qps controls the number of queries per second allowed for this connection. + QPS float32 `json:"qps"` + // burst allows extra queries to accumulate when a client is exceeding its rate. + Burst int32 `json:"burst"` +} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/zz_generated.conversion.go b/staging/src/k8s.io/component-base/config/v1alpha1/zz_generated.conversion.go similarity index 70% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/zz_generated.conversion.go rename to staging/src/k8s.io/component-base/config/v1alpha1/zz_generated.conversion.go index eaf2076ac4..55f0dac039 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/zz_generated.conversion.go +++ b/staging/src/k8s.io/component-base/config/v1alpha1/zz_generated.conversion.go @@ -24,7 +24,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" - config "k8s.io/apiserver/pkg/apis/config" + config "k8s.io/component-base/config" ) func init() { @@ -34,6 +34,16 @@ func init() { // RegisterConversions adds conversion functions to the given scheme. // Public to allow building arbitrary schemes. func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*ClientConnectionConfiguration)(nil), (*config.ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(a.(*ClientConnectionConfiguration), b.(*config.ClientConnectionConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.ClientConnectionConfiguration)(nil), (*ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(a.(*config.ClientConnectionConfiguration), b.(*ClientConnectionConfiguration), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*DebuggingConfiguration)(nil), (*config.DebuggingConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(a.(*DebuggingConfiguration), b.(*config.DebuggingConfiguration), scope) }); err != nil { @@ -54,6 +64,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*config.ClientConnectionConfiguration)(nil), (*ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(a.(*config.ClientConnectionConfiguration), b.(*ClientConnectionConfiguration), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*config.DebuggingConfiguration)(nil), (*DebuggingConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_config_DebuggingConfiguration_To_v1alpha1_DebuggingConfiguration(a.(*config.DebuggingConfiguration), b.(*DebuggingConfiguration), scope) }); err != nil { @@ -64,6 +79,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*ClientConnectionConfiguration)(nil), (*config.ClientConnectionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(a.(*ClientConnectionConfiguration), b.(*config.ClientConnectionConfiguration), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*DebuggingConfiguration)(nil), (*config.DebuggingConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(a.(*DebuggingConfiguration), b.(*config.DebuggingConfiguration), scope) }); err != nil { @@ -77,6 +97,24 @@ func RegisterConversions(s *runtime.Scheme) error { return nil } +func autoConvert_v1alpha1_ClientConnectionConfiguration_To_config_ClientConnectionConfiguration(in *ClientConnectionConfiguration, out *config.ClientConnectionConfiguration, s conversion.Scope) error { + out.Kubeconfig = in.Kubeconfig + out.AcceptContentTypes = in.AcceptContentTypes + out.ContentType = in.ContentType + out.QPS = in.QPS + out.Burst = in.Burst + return nil +} + +func autoConvert_config_ClientConnectionConfiguration_To_v1alpha1_ClientConnectionConfiguration(in *config.ClientConnectionConfiguration, out *ClientConnectionConfiguration, s conversion.Scope) error { + out.Kubeconfig = in.Kubeconfig + out.AcceptContentTypes = in.AcceptContentTypes + out.ContentType = in.ContentType + out.QPS = in.QPS + out.Burst = in.Burst + return nil +} + func autoConvert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(in *DebuggingConfiguration, out *config.DebuggingConfiguration, s conversion.Scope) error { out.EnableProfiling = in.EnableProfiling out.EnableContentionProfiling = in.EnableContentionProfiling diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/component-base/config/v1alpha1/zz_generated.deepcopy.go similarity index 77% rename from staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go rename to staging/src/k8s.io/component-base/config/v1alpha1/zz_generated.deepcopy.go index f40bbe19af..e747afa99b 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/component-base/config/v1alpha1/zz_generated.deepcopy.go @@ -20,6 +20,22 @@ limitations under the License. package v1alpha1 +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClientConnectionConfiguration) DeepCopyInto(out *ClientConnectionConfiguration) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClientConnectionConfiguration. +func (in *ClientConnectionConfiguration) DeepCopy() *ClientConnectionConfiguration { + if in == nil { + return nil + } + out := new(ClientConnectionConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DebuggingConfiguration) DeepCopyInto(out *DebuggingConfiguration) { *out = *in diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/validation/BUILD b/staging/src/k8s.io/component-base/config/validation/BUILD similarity index 74% rename from staging/src/k8s.io/apiserver/pkg/apis/config/validation/BUILD rename to staging/src/k8s.io/component-base/config/validation/BUILD index e66a553c3c..fe29ae9c5b 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/validation/BUILD +++ b/staging/src/k8s.io/component-base/config/validation/BUILD @@ -3,12 +3,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", srcs = ["validation.go"], - importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/config/validation", - importpath = "k8s.io/apiserver/pkg/apis/config/validation", + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/config/validation", + importpath = "k8s.io/component-base/config/validation", visibility = ["//visibility:public"], deps = [ "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", - "//staging/src/k8s.io/apiserver/pkg/apis/config:go_default_library", + "//staging/src/k8s.io/component-base/config:go_default_library", ], ) @@ -19,7 +19,7 @@ go_test( deps = [ "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", - "//staging/src/k8s.io/apiserver/pkg/apis/config:go_default_library", + "//staging/src/k8s.io/component-base/config:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation.go b/staging/src/k8s.io/component-base/config/validation/validation.go similarity index 80% rename from staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation.go rename to staging/src/k8s.io/component-base/config/validation/validation.go index 00cadf1013..6e66c0cec2 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation.go +++ b/staging/src/k8s.io/component-base/config/validation/validation.go @@ -18,9 +18,18 @@ package validation import ( "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/apiserver/pkg/apis/config" + "k8s.io/component-base/config" ) +// ValidateClientConnectionConfiguration ensures validation of the ClientConnectionConfiguration struct +func ValidateClientConnectionConfiguration(cc *config.ClientConnectionConfiguration, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + if cc.Burst < 0 { + allErrs = append(allErrs, field.Invalid(fldPath.Child("burst"), cc.Burst, "must be non-negative")) + } + return allErrs +} + // ValidateLeaderElectionConfiguration ensures validation of the LeaderElectionConfiguration struct func ValidateLeaderElectionConfiguration(cc *config.LeaderElectionConfiguration, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} diff --git a/staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation_test.go b/staging/src/k8s.io/component-base/config/validation/validation_test.go similarity index 75% rename from staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation_test.go rename to staging/src/k8s.io/component-base/config/validation/validation_test.go index b55c9fb1ba..628fc1094f 100644 --- a/staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation_test.go +++ b/staging/src/k8s.io/component-base/config/validation/validation_test.go @@ -17,13 +17,57 @@ limitations under the License. package validation import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/apiserver/pkg/apis/config" "testing" "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/validation/field" + "k8s.io/component-base/config" ) +func TestValidateClientConnectionConfiguration(t *testing.T) { + validConfig := &config.ClientConnectionConfiguration{ + AcceptContentTypes: "application/json", + ContentType: "application/json", + QPS: 10, + Burst: 10, + } + + qpsLessThanZero := validConfig.DeepCopy() + qpsLessThanZero.QPS = -1 + + burstLessThanZero := validConfig.DeepCopy() + burstLessThanZero.Burst = -1 + + scenarios := map[string]struct { + expectedToFail bool + config *config.ClientConnectionConfiguration + }{ + "good": { + expectedToFail: false, + config: validConfig, + }, + "good-qps-less-than-zero": { + expectedToFail: false, + config: qpsLessThanZero, + }, + "bad-burst-less-then-zero": { + expectedToFail: true, + config: burstLessThanZero, + }, + } + + for name, scenario := range scenarios { + errs := ValidateClientConnectionConfiguration(scenario.config, field.NewPath("clientConnectionConfiguration")) + if len(errs) == 0 && scenario.expectedToFail { + t.Errorf("Unexpected success for scenario: %s", name) + } + if len(errs) > 0 && !scenario.expectedToFail { + t.Errorf("Unexpected failure for scenario: %s - %+v", name, errs) + } + } +} + func TestValidateLeaderElectionConfiguration(t *testing.T) { validConfig := &config.LeaderElectionConfiguration{ ResourceLock: "configmap", diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/zz_generated.deepcopy.go b/staging/src/k8s.io/component-base/config/zz_generated.deepcopy.go similarity index 51% rename from staging/src/k8s.io/apimachinery/pkg/apis/config/zz_generated.deepcopy.go rename to staging/src/k8s.io/component-base/config/zz_generated.deepcopy.go index f09beb0e38..9812234f13 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/config/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/component-base/config/zz_generated.deepcopy.go @@ -35,3 +35,38 @@ func (in *ClientConnectionConfiguration) DeepCopy() *ClientConnectionConfigurati in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DebuggingConfiguration) DeepCopyInto(out *DebuggingConfiguration) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DebuggingConfiguration. +func (in *DebuggingConfiguration) DeepCopy() *DebuggingConfiguration { + if in == nil { + return nil + } + out := new(DebuggingConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LeaderElectionConfiguration) DeepCopyInto(out *LeaderElectionConfiguration) { + *out = *in + out.LeaseDuration = in.LeaseDuration + out.RenewDeadline = in.RenewDeadline + out.RetryPeriod = in.RetryPeriod + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeaderElectionConfiguration. +func (in *LeaderElectionConfiguration) DeepCopy() *LeaderElectionConfiguration { + if in == nil { + return nil + } + out := new(LeaderElectionConfiguration) + in.DeepCopyInto(out) + return out +}