From ad1f3e659e8ea9120e65534c43d1f71d68944894 Mon Sep 17 00:00:00 2001 From: hangaoshuai Date: Thu, 12 Jul 2018 15:14:08 +0800 Subject: [PATCH] move componentconfig ClientConnectionConfiguration to k8s.io/apimachinery/pkg/apis/config --- .../apimachinery/pkg/apis/config/doc.go | 19 ++++++++++ .../apimachinery/pkg/apis/config/types.go | 33 +++++++++++++++++ .../pkg/apis/config/v1alpha1/defaults.go | 37 +++++++++++++++++++ .../pkg/apis/config/v1alpha1/doc.go | 21 +++++++++++ .../pkg/apis/config/v1alpha1/register.go | 35 ++++++++++++++++++ .../pkg/apis/config/v1alpha1/types.go | 33 +++++++++++++++++ 6 files changed, 178 insertions(+) create mode 100644 staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go create mode 100644 staging/src/k8s.io/apimachinery/pkg/apis/config/types.go create mode 100644 staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/defaults.go create mode 100644 staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/doc.go create mode 100644 staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/register.go create mode 100644 staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/types.go diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go new file mode 100644 index 00000000000..d849c7aa3bd --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/config/doc.go @@ -0,0 +1,19 @@ +/* +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 + +package config // import "k8s.io/apimachinery/pkg/apis/config" diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/types.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/types.go new file mode 100644 index 00000000000..9b1a218a477 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/config/types.go @@ -0,0 +1,33 @@ +/* +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 { + // kubeConfigFile is the path to a kubeconfig file. + KubeConfigFile 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 + // cps 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/defaults.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/defaults.go new file mode 100644 index 00000000000..11b7de24954 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/defaults.go @@ -0,0 +1,37 @@ +/* +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 ( + kruntime "k8s.io/apimachinery/pkg/runtime" +) + +func addDefaultingFuncs(scheme *kruntime.Scheme) error { + return RegisterDefaults(scheme) +} + +func SetDefaults_ClientConnectionConfiguration(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 new file mode 100644 index 00000000000..c199193f188 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/doc.go @@ -0,0 +1,21 @@ +/* +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 +// +k8s:defaulter-gen=TypeMeta + +package v1alpha1 // import "k8s.io/apimachinery/pkg/apis/config/v1alpha1" diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/register.go b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/register.go new file mode 100644 index 00000000000..9f545f14477 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/register.go @@ -0,0 +1,35 @@ +/* +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 ( + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + 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(addDefaultingFuncs) +} 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 new file mode 100644 index 00000000000..aacc16443dd --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1/types.go @@ -0,0 +1,33 @@ +/* +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 { + // kubeConfigFile is the path to a kubeconfig file. + KubeConfigFile 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"` + // cps 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"` +}