kubectl rollout: support recursive flag for rollout status

This commit is contained in:
Philip Ottesen 2022-03-17 15:41:10 -04:00 committed by Philip Ottesen
parent f173d01c01
commit 9d8286c82c

View File

@ -168,24 +168,17 @@ func (o *RolloutStatusOptions) Run() error {
LabelSelectorParam(o.LabelSelector). LabelSelectorParam(o.LabelSelector).
FilenameParam(o.EnforceNamespace, o.FilenameOptions). FilenameParam(o.EnforceNamespace, o.FilenameOptions).
ResourceTypeOrNameArgs(true, o.BuilderArgs...). ResourceTypeOrNameArgs(true, o.BuilderArgs...).
SingleResourceType(). ContinueOnError().
Latest(). Latest().
Do() Do()
err := r.Err() err := r.Err()
if err != nil { if err != nil {
return err return err
} }
infos, err := r.Infos() return r.Visit(func(info *resource.Info, err error) error {
if err != nil {
return err
}
if len(infos) != 1 {
return fmt.Errorf("rollout status is only supported on individual resources and resource collections - %d resources were found", len(infos))
}
info := infos[0]
mapping := info.ResourceMapping() mapping := info.ResourceMapping()
statusViewer, err := o.StatusViewerFn(mapping) statusViewer, err := o.StatusViewerFn(mapping)
if err != nil { if err != nil {
return err return err
@ -237,4 +230,5 @@ func (o *RolloutStatusOptions) Run() error {
}) })
return err return err
}) })
})
} }