mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix dry-run output in kubectl apply --prune
Makes dry-run output match what would happen when running in non dry-run mode. Objects would only get added to visitedUids if running in non dry-run mode. visitedUids is used by prune() to know if an action should be taked on the item or not. Fixes #67863
This commit is contained in:
parent
8307fb2fb3
commit
74e63c8f00
@ -389,13 +389,14 @@ func (o *ApplyOptions) Run() error {
|
||||
return cmdutil.AddSourceToErr("creating", info.Source, err)
|
||||
}
|
||||
info.Refresh(obj, true)
|
||||
metadata, err := meta.Accessor(info.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
visitedUids.Insert(string(metadata.GetUID()))
|
||||
}
|
||||
|
||||
metadata, err := meta.Accessor(info.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
visitedUids.Insert(string(metadata.GetUID()))
|
||||
|
||||
count++
|
||||
|
||||
if printObject {
|
||||
@ -410,12 +411,13 @@ func (o *ApplyOptions) Run() error {
|
||||
return printer.PrintObj(info.Object, o.Out)
|
||||
}
|
||||
|
||||
if !o.DryRun {
|
||||
metadata, err := meta.Accessor(info.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
metadata, err := meta.Accessor(info.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
visitedUids.Insert(string(metadata.GetUID()))
|
||||
|
||||
if !o.DryRun {
|
||||
annotationMap := metadata.GetAnnotations()
|
||||
if _, ok := annotationMap[corev1.LastAppliedConfigAnnotation]; !ok {
|
||||
fmt.Fprintf(o.ErrOut, warningNoLastAppliedConfigAnnotation, o.cmdBaseName)
|
||||
@ -443,8 +445,6 @@ func (o *ApplyOptions) Run() error {
|
||||
|
||||
info.Refresh(patchedObject, true)
|
||||
|
||||
visitedUids.Insert(string(metadata.GetUID()))
|
||||
|
||||
if string(patchBytes) == "{}" && !printObject {
|
||||
count++
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user