mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #128009 from seans3/leader-migration-config-strict-validate
LeaderMigrationConfig now uses strict validation kube-controller-manager
This commit is contained in:
commit
023cd33d23
@ -25,7 +25,7 @@ import (
|
||||
util "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
internal "k8s.io/controller-manager/config"
|
||||
"k8s.io/controller-manager/config/v1"
|
||||
v1 "k8s.io/controller-manager/config/v1"
|
||||
"k8s.io/controller-manager/config/v1alpha1"
|
||||
"k8s.io/controller-manager/config/v1beta1"
|
||||
)
|
||||
@ -63,7 +63,7 @@ func ReadLeaderMigrationConfiguration(configFilePath string) (*internal.LeaderMi
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read leader migration configuration from %q: %w", configFilePath, err)
|
||||
}
|
||||
config, gvk, err := serializer.NewCodecFactory(cfgScheme).UniversalDecoder().Decode(data, nil, nil)
|
||||
config, gvk, err := serializer.NewCodecFactory(cfgScheme, serializer.EnableStrict).UniversalDecoder().Decode(data, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -82,6 +82,30 @@ controllerLeaders: []
|
||||
ControllerLeaders: []internal.ControllerLeaderConfiguration{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "unknown field causes error with strict validation",
|
||||
content: `
|
||||
apiVersion: controllermanager.config.k8s.io/v1alpha1
|
||||
kind: LeaderMigrationConfiguration
|
||||
leaderName: migration-120-to-121
|
||||
resourceLock: endpoints
|
||||
foo: bar
|
||||
controllerLeaders: []
|
||||
`,
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "duplicate field causes error with strict validation",
|
||||
content: `
|
||||
apiVersion: controllermanager.config.k8s.io/v1alpha1
|
||||
kind: LeaderMigrationConfiguration
|
||||
leaderName: migration-120-to-121
|
||||
resourceLock: endpoints
|
||||
resourceLock: endpoints1
|
||||
controllerLeaders: []
|
||||
`,
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "withLeaders",
|
||||
content: `
|
||||
|
Loading…
Reference in New Issue
Block a user