mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
divide statically known typer from dynamically derive restmapper
This commit is contained in:
@@ -389,9 +389,10 @@ func RunCreateSubcommand(f cmdutil.Factory, options *CreateSubcommandOptions) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mapper, typer := f.Object()
|
||||
mapper := f.RESTMapper()
|
||||
if !options.DryRun {
|
||||
gvks, _, err := typer.ObjectKinds(obj)
|
||||
// create subcommands have compiled knowledge of things they create, so type them directly
|
||||
gvks, _, err := legacyscheme.Scheme.ObjectKinds(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ func TestClusterRoleValidate(t *testing.T) {
|
||||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
test.clusterRoleOptions.Mapper, _ = tf.Object()
|
||||
test.clusterRoleOptions.Mapper = tf.RESTMapper()
|
||||
err := test.clusterRoleOptions.Validate()
|
||||
if test.expectErr && err == nil {
|
||||
t.Errorf("%s: expect error happens, but validate passes.", name)
|
||||
|
||||
@@ -205,7 +205,7 @@ func (o *CreateRoleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
o.ResourceNames = resourceNames
|
||||
|
||||
// Complete other options for Run.
|
||||
o.Mapper, _ = f.Object()
|
||||
o.Mapper = f.RESTMapper()
|
||||
|
||||
o.DryRun = cmdutil.GetDryRunFlag(cmd)
|
||||
o.OutputFormat = cmdutil.GetFlagString(cmd, "output")
|
||||
|
||||
@@ -339,7 +339,7 @@ func TestValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
test.roleOptions.Mapper, _ = tf.Object()
|
||||
test.roleOptions.Mapper = tf.RESTMapper()
|
||||
err := test.roleOptions.Validate()
|
||||
if test.expectErr && err == nil {
|
||||
t.Errorf("%s: expect error happens but validate passes.", name)
|
||||
|
||||
Reference in New Issue
Block a user