refactor builder in kubectl factory

This commit is contained in:
ymqytw
2017-11-07 17:42:03 -08:00
parent 42d5dc709e
commit 06c5be9802
25 changed files with 125 additions and 159 deletions

View File

@@ -226,13 +226,7 @@ func (options *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []str
return options.watch(f, cmd, args)
}
mapper, typer, err := f.UnstructuredObject()
if err != nil {
return err
}
r := f.NewBuilder().
Unstructured(f.UnstructuredClientForMapping, mapper, typer).
r := f.NewUnstructuredBuilder().
NamespaceParam(options.Namespace).DefaultNamespace().AllNamespaces(options.AllNamespaces).
FilenameParam(options.ExplicitNamespace, &options.FilenameOptions).
LabelSelectorParam(options.LabelSelector).
@@ -439,18 +433,12 @@ func (options *GetOptions) raw(f cmdutil.Factory) error {
// watch starts a client-side watch of one or more resources.
// TODO: remove the need for arguments here.
func (options *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
mapper, typer, err := f.UnstructuredObject()
if err != nil {
return err
}
// TODO: this could be better factored
// include uninitialized objects when watching on a single object
// unless explicitly set --include-uninitialized=false
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, len(args) == 2)
r := f.NewBuilder().
Unstructured(f.UnstructuredClientForMapping, mapper, typer).
r := f.NewUnstructuredBuilder().
NamespaceParam(options.Namespace).DefaultNamespace().AllNamespaces(options.AllNamespaces).
FilenameParam(options.ExplicitNamespace, &options.FilenameOptions).
LabelSelectorParam(options.LabelSelector).
@@ -462,7 +450,7 @@ func (options *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []s
SingleResourceType().
Latest().
Do()
err = r.Err()
err := r.Err()
if err != nil {
return err
}