Merge pull request #67207 from luxas/remove_shared_config_defaulting
Automatic merge from submit-queue (batch tested with PRs 66602, 67178, 67207, 67125, 66332). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Remove defaulting from shared ComponentConfig types **What this PR does / why we need it**: As @deads2k commented in kubernetes/community#2354, we should not register defaults for the shared componentconfig types as it gets very hard for consumer to opt-out of the default defaulting funcs. Instead, the package provides a `DefaultFoo` function the consuming API group can call if it wants to as an opt-in in `SetDefaults_Bar` (where `Bar` wraps `Foo` as a field) **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: kubernetes/community#2354 **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` /assign @sttts @liggitt @deads2k Kubernetes-commit: 94a754c794d41287ba3d009fb96dfa24f088e175
This commit is contained in:
commit
a79ff62589
|
@ -980,215 +980,215 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/validation",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/validation/path",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/validation",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/rand",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/uuid",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/waitgroup",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
||||
"Rev": "720795f37ef04a6d63ba53b0b43233b3f851c149"
|
||||
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go/discovery",
|
||||
|
@ -1845,6 +1845,10 @@
|
|||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
"Rev": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/utils/pointer",
|
||||
"Rev": "66066c83e385e385ccc3c964b44fd7dcd413d0ed"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -20,15 +20,19 @@ import (
|
|||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
kruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *kruntime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_LeaderElectionConfiguration(obj *LeaderElectionConfiguration) {
|
||||
booltrue := true
|
||||
// RecommendedDefaultLeaderElectionConfiguration defaults a pointer to a
|
||||
// LeaderElectionConfiguration 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 RecommendedDefaultLeaderElectionConfiguration(obj *LeaderElectionConfiguration) {
|
||||
zero := metav1.Duration{}
|
||||
if obj.LeaseDuration == zero {
|
||||
obj.LeaseDuration = metav1.Duration{Duration: 15 * time.Second}
|
||||
|
@ -43,6 +47,6 @@ func SetDefaults_LeaderElectionConfiguration(obj *LeaderElectionConfiguration) {
|
|||
obj.ResourceLock = EndpointsResourceLock
|
||||
}
|
||||
if obj.LeaderElect == nil {
|
||||
obj.LeaderElect = &booltrue
|
||||
obj.LeaderElect = utilpointer.BoolPtr(true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,5 @@ limitations under the License.
|
|||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/config
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
|
||||
package v1alpha1
|
||||
package v1alpha1 // import "k8s.io/apiserver/pkg/apis/config/v1alpha1"
|
||||
|
|
|
@ -21,15 +21,7 @@ import (
|
|||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -1,32 +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 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
|
||||
}
|
Loading…
Reference in New Issue