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).
FilenameParam(o.EnforceNamespace, o.FilenameOptions).
ResourceTypeOrNameArgs(true, o.BuilderArgs...).
SingleResourceType().
ContinueOnError().
Latest().
Do()
err := r.Err()
if err != nil {
return err
}
infos, err := r.Infos()
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]
return r.Visit(func(info *resource.Info, err error) error {
mapping := info.ResourceMapping()
statusViewer, err := o.StatusViewerFn(mapping)
if err != nil {
return err
@ -237,4 +230,5 @@ func (o *RolloutStatusOptions) Run() error {
})
return err
})
})
}