remove cmd arg

related issue "Remove cmd from kubectl/cmd/factory arguments #4470"
This commit is contained in:
Young 2015-03-27 21:46:17 +08:00
parent 8a7a127352
commit 84bfda0587
9 changed files with 11 additions and 11 deletions

View File

@ -56,7 +56,7 @@ func RunClusterInfo(factory *Factory, out io.Writer, cmd *cobra.Command) error {
}
// TODO use generalized labels once they are implemented (#341)
b := resource.NewBuilder(mapper, typer, factory.ClientMapperForCommand(cmd)).
b := resource.NewBuilder(mapper, typer, factory.ClientMapperForCommand()).
NamespaceParam(cmdNamespace).DefaultNamespace().
SelectorParam("kubernetes.io/cluster-service=true").
ResourceTypeOrNameArgs(false, []string{"services"}...).

View File

@ -320,8 +320,8 @@ func (f *Factory) PrinterForMapping(cmd *cobra.Command, mapping *meta.RESTMappin
return printer, nil
}
// ClientMapperForCommand returns a ClientMapper for the given command and factory.
func (f *Factory) ClientMapperForCommand(cmd *cobra.Command) resource.ClientMapper {
// ClientMapperForCommand returns a ClientMapper for the factory.
func (f *Factory) ClientMapperForCommand() resource.ClientMapper {
return resource.ClientMapperFunc(func(mapping *meta.RESTMapping) (resource.RESTClient, error) {
return f.RESTClient(mapping)
})

View File

@ -73,7 +73,7 @@ func RunCreate(f *Factory, out io.Writer, cmd *cobra.Command, filenames util.Str
}
mapper, typer := f.Object()
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
ContinueOnError().
NamespaceParam(cmdNamespace).RequireNamespace().
FilenameParam(filenames...).

View File

@ -79,7 +79,7 @@ func RunDelete(f *Factory, out io.Writer, cmd *cobra.Command, args []string, fil
return err
}
mapper, typer := f.Object()
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(filenames...).

View File

@ -91,7 +91,7 @@ func RunGet(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error
// handle watch separately since we cannot watch multiple resource types
isWatch, isWatchOnly := util.GetFlagBool(cmd, "watch"), util.GetFlagBool(cmd, "watch-only")
if isWatch || isWatchOnly {
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
NamespaceParam(cmdNamespace).DefaultNamespace().
SelectorParam(selector).
ResourceTypeOrNameArgs(true, args...).
@ -140,7 +140,7 @@ func RunGet(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error
return nil
}
b := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
b := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
NamespaceParam(cmdNamespace).DefaultNamespace().
SelectorParam(selector).
ResourceTypeOrNameArgs(true, args...).

View File

@ -189,7 +189,7 @@ func RunLabel(f *Factory, out io.Writer, cmd *cobra.Command, args []string) erro
}
mapper, typer := f.Object()
b := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
b := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
SelectorParam(selector).

View File

@ -81,7 +81,7 @@ func RunRollingUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []stri
mapper, typer := f.Object()
// TODO: use resource.Builder instead
obj, err := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
obj, err := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
NamespaceParam(cmdNamespace).RequireNamespace().
FilenameParam(filename).
Do().

View File

@ -57,7 +57,7 @@ func (f *Factory) NewCmdStop(out io.Writer) *cobra.Command {
cmdNamespace, err := f.DefaultNamespace()
cmdutil.CheckErr(err)
mapper, typer := f.Object()
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
ContinueOnError().
NamespaceParam(cmdNamespace).RequireNamespace().
ResourceTypeOrNameArgs(false, args...).

View File

@ -87,7 +87,7 @@ func RunUpdate(f *Factory, out io.Writer, cmd *cobra.Command, args []string, fil
}
mapper, typer := f.Object()
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand(cmd)).
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
ContinueOnError().
NamespaceParam(cmdNamespace).RequireNamespace().
FilenameParam(filenames...).