diff --git a/pkg/cmd/apply/apply.go b/pkg/cmd/apply/apply.go index 800fa736..f85247e3 100644 --- a/pkg/cmd/apply/apply.go +++ b/pkg/cmd/apply/apply.go @@ -132,7 +132,7 @@ var ( # Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file. kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap`)) - warningNoLastAppliedConfigAnnotation = "Warning: %[1]s apply should be used on resource created by either %[1]s create --save-config or %[1]s apply\n" + warningNoLastAppliedConfigAnnotation = "Warning: resource %[1]s is missing the %[2]s annotation which is required by %[3]s apply. %[3]s apply should only be used on resources created declaratively by either %[3]s create --save-config or %[3]s apply. The missing annotation will be patched automatically.\n" ) // NewApplyOptions creates new ApplyOptions for the `apply` command @@ -542,7 +542,7 @@ See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err) metadata, _ := meta.Accessor(info.Object) annotationMap := metadata.GetAnnotations() if _, ok := annotationMap[corev1.LastAppliedConfigAnnotation]; !ok { - fmt.Fprintf(o.ErrOut, warningNoLastAppliedConfigAnnotation, o.cmdBaseName) + fmt.Fprintf(o.ErrOut, warningNoLastAppliedConfigAnnotation, info.ObjectName(), corev1.LastAppliedConfigAnnotation, o.cmdBaseName) } patcher, err := newPatcher(o, info, helper) diff --git a/pkg/cmd/apply/apply_test.go b/pkg/cmd/apply/apply_test.go index 7fec5564..1d199ebf 100644 --- a/pkg/cmd/apply/apply_test.go +++ b/pkg/cmd/apply/apply_test.go @@ -504,7 +504,7 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) { // uses the name from the file, not the response expectRC := "replicationcontroller/" + nameRC + "\n" - expectWarning := fmt.Sprintf(warningNoLastAppliedConfigAnnotation, "kubectl") + expectWarning := fmt.Sprintf(warningNoLastAppliedConfigAnnotation, "replicationcontrollers/test-rc", corev1.LastAppliedConfigAnnotation, "kubectl") if errBuf.String() != expectWarning { t.Fatalf("unexpected non-warning: %s\nexpected: %s", errBuf.String(), expectWarning) }