Change:
<!-- This form is for bug reports and feature requests ONLY! If you're looking for help check and the . If the matter is security related, please disclose it privately via --Is this a BUG REPORT or FEATURE REQUEST?: /kind bug What happened: The dry run output listed all the resources that would be configured: deployments, HPAs, services, and an ingress: This was expected. However, it then listed all resources again (except for the HPAs) as being pruned: The config was then applied with: As expected, no resources were actually pruned. What you expected to happen: should actually display which resources are going to be pruned. How to reproduce it (as minimally and precisely as possible): a YAML file to with it: run + prune: should be listed as both configured and pruned it again with pruning: that the deployment is configured but not pruned, even though the dry run said it would be. Anything else we need to know?: Was trying to write a devops script that gave a warning before any resources would be pruned. Environment: Kubernetes version (use ):Cloud provider or hardware configuration: GKE OS (e.g. from /etc/os-release): (Lubuntu 18.04) Kernel (e.g. ):Install tools: Others:
Reiterating the mentions to trigger a notification: <detailsIn response to : Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
I can reproduce it, and i will try to fix it.

Discussion:
return cmdutil.AddSourceToErr("creating", info.Source, err) } info.Refresh(obj, true) <del> metadata, err := meta.Accessor(info.Object) if err != nil { return err } visitedUids.Insert(string(metadata.GetUID())) </del> } <ins> metadata, err := meta.Accessor(info.Object) if err != nil { return err } visitedUids.Insert(string(metadata.GetUID())) </ins> count++ if printObject {

return printer.PrintObj(info.Object, o.Out) } <del> if !o.DryRun { metadata, err := meta.Accessor(info.Object) if err != nil { return err } </del> <ins> metadata, err := meta.Accessor(info.Object) if err != nil { return err } visitedUids.Insert(string(metadata.GetUID())) if !o.DryRun { </ins> annotationMap := metadata.GetAnnotations() if _, ok := annotationMap[corev1.LastAppliedConfigAnnotation]; !ok { fmt.Fprintf(o.ErrOut, warningNoLastAppliedConfigAnnotation, o.cmdBaseName)

info.Refresh(patchedObject, true) <del> visitedUids.Insert(string(metadata.GetUID())) </del> if string(patchBytes) == "{}" && !printObject { count++

filenameWidgetServerside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/widget-serverside.yaml" ) <del> func readConfigMapList(t *testing.T, filename string) []byte { </del> <ins> func readConfigMapList(t *testing.T, filename string) [][]byte { </ins> data := readBytesFromFile(t, filename) cmList := corev1.ConfigMapList{} if err := runtime.DecodeInto(codec, data, &cmList); err != nil { t.Fatal(err) } <del> cmListBytes, err := runtime.Encode(codec, &cmList) if err != nil { t.Fatal(err) </del> <ins> var listCmBytes [][]byte for _, cm := range cmList.Items { cmBytes, err := runtime.Encode(codec, &cm) if err != nil { t.Fatal(err) } listCmBytes = append(listCmBytes, cmBytes) </ins> } <del> return cmListBytes </del> <ins> return listCmBytes </ins> } func readBytesFromFile(t *testing.T, filename string) []byte {

func TestRunApplyPrintsValidObjectList(t *testing.T) { cmdtesting.InitTestErrorHandler(t) <del> cmBytes := readConfigMapList(t, filenameCM) </del> <ins> configMapList := readConfigMapList(t, filenameCM) </ins> pathCM := "/namespaces/test/configmaps" tf := cmdtesting.NewTestFactory().WithNamespace("test")

NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer, Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { switch p, m := req.URL.Path, req.Method; { <del> case strings.HasPrefix(p, pathCM) && m != "GET": pod := ioutil.NopCloser(bytes.NewReader(cmBytes)) return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: pod}, nil case strings.HasPrefix(p, pathCM) && m != "PATCH": pod := ioutil.NopCloser(bytes.NewReader(cmBytes)) return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: pod}, nil </del> <ins> case strings.HasPrefix(p, pathCM) && m == "GET": fallthrough case strings.HasPrefix(p, pathCM) && m == "PATCH": var body io.ReadCloser switch p { case pathCM + "/test0": body = ioutil.NopCloser(bytes.NewReader(configMapList[0])) case pathCM + "/test1": body = ioutil.NopCloser(bytes.NewReader(configMapList[1])) default: t.Errorf("unexpected request to %s", p) } return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: body}, nil </ins> default: t.Fatalf("unexpected request: %#vn%#v", req.URL, req) return nil, nil

if err := runtime.DecodeInto(codec, buf.Bytes(), &cmList); err != nil { t.Fatal(err) } <ins> if len(cmList.Items) != 2 { t.Fatalf("Expected 2 items in the result; got %d", len(cmList.Items)) } if !strings.Contains(string(cmList.Items[0].Raw), "key1") { t.Fatalf("Did not get first ConfigMap at the first position") } if !strings.Contains(string(cmList.Items[1].Raw), "key2") { t.Fatalf("Did not get second ConfigMap at the second position") } </ins> } func TestRunApplyViewLastApplied(t *testing.T) {

- kind: ConfigMap apiVersion: v1 metadata: <del> name: test </del> <ins> name: test0 </ins> data: key1: apple - kind: ConfigMap apiVersion: v1 metadata: <del> name: test2 </del> <ins> name: test1 </ins> data: key2: apple kind: ConfigMapList