Changes Visit() to Infos() in apply to keep slice of objects

This commit is contained in:
Sean Sullivan 2019-12-16 13:00:33 -08:00
parent a13ddd5f8e
commit 2103ea4dde

View File

@ -374,10 +374,13 @@ func (o *ApplyOptions) Run() error {
var objs []runtime.Object var objs []runtime.Object
count := 0 count := 0
err = r.Visit(func(info *resource.Info, err error) error {
if err != nil { infos, err := r.Infos()
return err if err != nil {
} return err
}
for _, info := range infos {
// If server-dry-run is requested but the type doesn't support it, fail right away. // If server-dry-run is requested but the type doesn't support it, fail right away.
if o.ServerDryRun { if o.ServerDryRun {
@ -449,7 +452,7 @@ See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err)
count++ count++
if len(output) > 0 && !shortOutput { if len(output) > 0 && !shortOutput {
objs = append(objs, info.Object) objs = append(objs, info.Object)
return nil continue
} }
printer, err := o.ToPrinter("serverside-applied") printer, err := o.ToPrinter("serverside-applied")
@ -457,7 +460,10 @@ See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err)
return err return err
} }
return printer.PrintObj(info.Object, o.Out) if err = printer.PrintObj(info.Object, o.Out); err != nil {
return err
}
continue
} }
// Get the modified configuration of the object. Embed the result // Get the modified configuration of the object. Embed the result
@ -505,14 +511,17 @@ See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err)
if printObject { if printObject {
objs = append(objs, info.Object) objs = append(objs, info.Object)
return nil continue
} }
printer, err := o.ToPrinter("created") printer, err := o.ToPrinter("created")
if err != nil { if err != nil {
return err return err
} }
return printer.PrintObj(info.Object, o.Out) if err = printer.PrintObj(info.Object, o.Out); err != nil {
return err
}
continue
} }
metadata, err := meta.Accessor(info.Object) metadata, err := meta.Accessor(info.Object)
@ -557,24 +566,26 @@ See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err)
if err != nil { if err != nil {
return err return err
} }
return printer.PrintObj(info.Object, o.Out) if err = printer.PrintObj(info.Object, o.Out); err != nil {
return err
}
continue
} }
} }
count++ count++
if printObject { if printObject {
objs = append(objs, info.Object) objs = append(objs, info.Object)
return nil continue
} }
printer, err := o.ToPrinter("configured") printer, err := o.ToPrinter("configured")
if err != nil { if err != nil {
return err return err
} }
return printer.PrintObj(info.Object, o.Out) if err = printer.PrintObj(info.Object, o.Out); err != nil {
}) return err
if err != nil { }
return err
} }
if count == 0 { if count == 0 {