diff --git a/pkg/kapp/app/recorded_app.go b/pkg/kapp/app/recorded_app.go index 971e41484..0e3aa005f 100644 --- a/pkg/kapp/app/recorded_app.go +++ b/pkg/kapp/app/recorded_app.go @@ -170,20 +170,26 @@ func (a *RecordedApp) CreateOrUpdate(labels map[string]string, isDiffRun bool) e } } - return a.createOrUpdate(configMap, labels) + return a.createOrUpdate(configMap, labels, isDiffRun) } } return fmt.Errorf("Getting app: %s", err) } -func (a *RecordedApp) createOrUpdate(c *corev1.ConfigMap, labels map[string]string) error { +func (a *RecordedApp) createOrUpdate(c *corev1.ConfigMap, labels map[string]string, isDiffRun bool) error { err := a.mergeAppUpdates(c, labels) if err != nil { return err } - _, err = a.coreClient.CoreV1().ConfigMaps(a.nsName).Create(context.TODO(), c, metav1.CreateOptions{}) + var dryRunValue []string = nil + + if isDiffRun { + dryRunValue = []string{metav1.DryRunAll} + } + + app, err := a.coreClient.CoreV1().ConfigMaps(a.nsName).Create(context.TODO(), c, metav1.CreateOptions{DryRun: dryRunValue}) if err != nil { if errors.IsAlreadyExists(err) { existingConfigMap, err := a.coreClient.CoreV1().ConfigMaps(a.nsName).Get(context.TODO(), c.GetObjectMeta().GetName(), metav1.GetOptions{}) @@ -197,6 +203,10 @@ func (a *RecordedApp) createOrUpdate(c *corev1.ConfigMap, labels map[string]stri return fmt.Errorf("Creating app: %s", err) } + if isDiffRun { + a.setMeta(*app) + } + return nil } @@ -214,7 +224,7 @@ func (a *RecordedApp) updateApp(existingConfigMap *corev1.ConfigMap, labels map[ return nil } -func (a *RecordedApp) RenamePrevApp(prevAppName string, labels map[string]string) error { +func (a *RecordedApp) RenamePrevApp(prevAppName string, labels map[string]string, isDiffRun bool) error { defer a.logger.DebugFunc("RenamePrevApp").Finish() var c *corev1.ConfigMap var err error @@ -269,7 +279,7 @@ func (a *RecordedApp) RenamePrevApp(prevAppName string, labels map[string]string return err } } - return a.createOrUpdate(newConf, labels) + return a.createOrUpdate(newConf, labels, isDiffRun) } } }