mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #108777 from pjo256/recursive-rollout-status
feat(kubectl rollout): support multiple resources for rollout status
This commit is contained in:
commit
47bb8c6d0c
@ -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
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -383,6 +383,17 @@ run_recursive_resources_tests() {
|
|||||||
# Post-condition: nginx0 & nginx1 should both have paused set to nothing, and since nginx2 is malformed, it should error
|
# Post-condition: nginx0 & nginx1 should both have paused set to nothing, and since nginx2 is malformed, it should error
|
||||||
kube::test::get_object_assert deployment "{{range.items}}{{.spec.paused}}:{{end}}" "<no value>:<no value>:"
|
kube::test::get_object_assert deployment "{{range.items}}{{.spec.paused}}:{{end}}" "<no value>:<no value>:"
|
||||||
kube::test::if_has_string "${output_message}" "Object 'Kind' is missing"
|
kube::test::if_has_string "${output_message}" "Object 'Kind' is missing"
|
||||||
|
## Fetch rollout status for multiple resources
|
||||||
|
output_message=$(! kubectl rollout status -f hack/testdata/recursive/deployment/deployment --timeout=1s 2>&1 "${kube_flags[@]:?}")
|
||||||
|
# Post-condition: nginx1 should both exist and nginx2 should error
|
||||||
|
kube::test::if_has_string "${output_message}" "Waiting for deployment \"nginx1-deployment\" rollout to finish"
|
||||||
|
kube::test::if_has_string "${output_message}" "Object 'Kind' is missing"
|
||||||
|
## Fetch rollout status for deployments recursively
|
||||||
|
output_message=$(! kubectl rollout status -f hack/testdata/recursive/deployment -R --timeout=1s 2>&1 "${kube_flags[@]:?}")
|
||||||
|
# Post-condition: nginx0 & nginx1 should both exist, nginx2 should error
|
||||||
|
kube::test::if_has_string "${output_message}" "Waiting for deployment \"nginx0-deployment\" rollout to finish"
|
||||||
|
kube::test::if_has_string "${output_message}" "Waiting for deployment \"nginx1-deployment\" rollout to finish"
|
||||||
|
kube::test::if_has_string "${output_message}" "Object 'Kind' is missing"
|
||||||
## Retrieve the rollout history of the deployments recursively
|
## Retrieve the rollout history of the deployments recursively
|
||||||
output_message=$(! kubectl rollout history -f hack/testdata/recursive/deployment --recursive 2>&1 "${kube_flags[@]}")
|
output_message=$(! kubectl rollout history -f hack/testdata/recursive/deployment --recursive 2>&1 "${kube_flags[@]}")
|
||||||
# Post-condition: nginx0 & nginx1 should both have a history, and since nginx2 is malformed, it should error
|
# Post-condition: nginx0 & nginx1 should both have a history, and since nginx2 is malformed, it should error
|
||||||
|
Loading…
Reference in New Issue
Block a user