Revert "refactor builder in kubectl factory"

This reverts commit 06c5be9802.
This commit is contained in:
Clayton Coleman
2017-11-13 22:43:58 -05:00
parent 6b97376a53
commit 98e0c69907
25 changed files with 160 additions and 126 deletions

View File

@@ -189,23 +189,31 @@ func (o AnnotateOptions) RunAnnotate(f cmdutil.Factory, cmd *cobra.Command) erro
changeCause := f.Command(cmd, false)
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
var b *resource.Builder
if o.local {
b = f.NewBuilder().
Local(f.ClientForMapping)
} else {
b = f.NewUnstructuredBuilder().
LabelSelectorParam(o.selector).
ResourceTypeOrNameArgs(o.all, o.resources...).
Latest()
}
r := b.ContinueOnError().
b := f.NewBuilder().
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, &o.FilenameOptions).
IncludeUninitialized(includeUninitialized).
Flatten().
Do()
Flatten()
if !o.local {
// call this method here, as it requires an api call
// and will cause the command to fail when there is
// no connection to a server
mapper, typer, err := f.UnstructuredObject()
if err != nil {
return err
}
b = b.LabelSelectorParam(o.selector).
Unstructured(f.UnstructuredClientForMapping, mapper, typer).
ResourceTypeOrNameArgs(o.all, o.resources...).
Latest()
} else {
b = b.Local(f.ClientForMapping)
}
r := b.Do()
if err := r.Err(); err != nil {
return err
}