mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Changes Visit() to Infos() in apply to keep slice of objects
This commit is contained in:
parent
a13ddd5f8e
commit
2103ea4dde
@ -374,11 +374,14 @@ 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 {
|
|
||||||
|
infos, err := r.Infos()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
||||||
if err := dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
if err := dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||||
@ -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,25 +566,27 @@ 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 {
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
return fmt.Errorf("no objects passed to apply")
|
return fmt.Errorf("no objects passed to apply")
|
||||||
|
Loading…
Reference in New Issue
Block a user