don't reuse resource builder in describe

parent 96a0df64
...@@ -73,8 +73,8 @@ type DescribeOptions struct { ...@@ -73,8 +73,8 @@ type DescribeOptions struct {
Selector string Selector string
Namespace string Namespace string
Describer func(*meta.RESTMapping) (printers.Describer, error) Describer func(*meta.RESTMapping) (printers.Describer, error)
Builder *resource.Builder NewBuilder func() *resource.Builder
BuilderArgs []string BuilderArgs []string
...@@ -141,7 +141,7 @@ func (o *DescribeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [ ...@@ -141,7 +141,7 @@ func (o *DescribeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
o.BuilderArgs = args o.BuilderArgs = args
o.Describer = f.Describer o.Describer = f.Describer
o.Builder = f.NewBuilder() o.NewBuilder = f.NewBuilder
// include the uninitialized objects by default // include the uninitialized objects by default
// unless user explicitly set --include-uninitialized=false // unless user explicitly set --include-uninitialized=false
...@@ -154,7 +154,7 @@ func (o *DescribeOptions) Validate(args []string) error { ...@@ -154,7 +154,7 @@ func (o *DescribeOptions) Validate(args []string) error {
} }
func (o *DescribeOptions) Run() error { func (o *DescribeOptions) Run() error {
r := o.Builder. r := o.NewBuilder().
Unstructured(). Unstructured().
ContinueOnError(). ContinueOnError().
NamespaceParam(o.Namespace).DefaultNamespace().AllNamespaces(o.AllNamespaces). NamespaceParam(o.Namespace).DefaultNamespace().AllNamespaces(o.AllNamespaces).
...@@ -212,7 +212,7 @@ func (o *DescribeOptions) Run() error { ...@@ -212,7 +212,7 @@ func (o *DescribeOptions) Run() error {
} }
func (o *DescribeOptions) DescribeMatchingResources(originalError error, resource, prefix string) error { func (o *DescribeOptions) DescribeMatchingResources(originalError error, resource, prefix string) error {
r := o.Builder. r := o.NewBuilder().
Unstructured(). Unstructured().
NamespaceParam(o.Namespace).DefaultNamespace(). NamespaceParam(o.Namespace).DefaultNamespace().
ResourceTypeOrNameArgs(true, resource). ResourceTypeOrNameArgs(true, resource).
......
...@@ -198,7 +198,7 @@ func (b *Builder) Unstructured() *Builder { ...@@ -198,7 +198,7 @@ func (b *Builder) Unstructured() *Builder {
b.errs = append(b.errs, fmt.Errorf("no unstructured mapper provided")) b.errs = append(b.errs, fmt.Errorf("no unstructured mapper provided"))
return b return b
} }
if b.mapper != nil { if b.mapper != nil && b.mapper != b.unstructured {
b.errs = append(b.errs, fmt.Errorf("another mapper was already selected, cannot use unstructured types")) b.errs = append(b.errs, fmt.Errorf("another mapper was already selected, cannot use unstructured types"))
return b return b
} }
...@@ -219,7 +219,7 @@ func (b *Builder) Internal(typer runtime.ObjectTyper) *Builder { ...@@ -219,7 +219,7 @@ func (b *Builder) Internal(typer runtime.ObjectTyper) *Builder {
b.errs = append(b.errs, fmt.Errorf("no internal mapper provided")) b.errs = append(b.errs, fmt.Errorf("no internal mapper provided"))
return b return b
} }
if b.mapper != nil { if b.mapper != nil && b.mapper != b.internal {
b.errs = append(b.errs, fmt.Errorf("another mapper was already selected, cannot use internal types")) b.errs = append(b.errs, fmt.Errorf("another mapper was already selected, cannot use internal types"))
return b return b
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment