From 7e1e631979be0da501a0188d10402bc0a5420440 Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Thu, 21 Jul 2022 13:24:28 -0400 Subject: [PATCH] update --- pkg/odo/cli/deploy/deploy.go | 6 ++---- pkg/odo/cli/dev/dev.go | 8 +++----- tests/integration/cmd_dev_test.go | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pkg/odo/cli/deploy/deploy.go b/pkg/odo/cli/deploy/deploy.go index f6ea9dcf269..616f2fbd611 100644 --- a/pkg/odo/cli/deploy/deploy.go +++ b/pkg/odo/cli/deploy/deploy.go @@ -123,10 +123,8 @@ func (o *DeployOptions) Complete(cmdline cmdline.Cmdline, args []string) (err er if err != nil { return fmt.Errorf("failed to write new env.yaml file: %w", err) } - } - - // If the env.yaml exists and the project is set incorrectly, we'll override it. - if envfileinfo.Exists() && envfileinfo.GetComponentSettings().Project != o.GetProject() { + } else if envfileinfo.Exists() && envfileinfo.GetComponentSettings().Project != o.GetProject() { + // If the env.yaml exists and the project is set incorrectly, we'll override it. klog.V(4).Info("Overriding project name in env.yaml as it's set incorrectly, new project name: ", o.GetProject()) err = envfileinfo.SetConfiguration("project", o.GetProject()) if err != nil { diff --git a/pkg/odo/cli/dev/dev.go b/pkg/odo/cli/dev/dev.go index 10733256815..00105c2559d 100644 --- a/pkg/odo/cli/dev/dev.go +++ b/pkg/odo/cli/dev/dev.go @@ -163,15 +163,13 @@ func (o *DevOptions) Complete(cmdline cmdline.Cmdline, args []string) error { // If the env.yaml does not exist, we will save the project name if !envfileinfo.Exists() { - klog.V(4).Info("Overriding project name in env.yaml as it's set incorrectly, new project name: ", o.GetProject()) err = envfileinfo.SetComponentSettings(envinfo.ComponentSettings{Project: o.GetProject()}) if err != nil { return fmt.Errorf("failed to write new env.yaml file: %w", err) } - } - - // If the env.yaml exists and the project is set incorrectly, we'll override it. - if envfileinfo.Exists() && envfileinfo.GetComponentSettings().Project != o.GetProject() { + } else if envfileinfo.Exists() && envfileinfo.GetComponentSettings().Project != o.GetProject() { + // If the env.yaml exists and the project is set incorrectly, we'll override it. + klog.V(4).Info("Overriding project name in env.yaml as it's set incorrectly, new project name: ", o.GetProject()) err = envfileinfo.SetConfiguration("project", o.GetProject()) if err != nil { return fmt.Errorf("failed to update project in env.yaml file: %w", err) diff --git a/tests/integration/cmd_dev_test.go b/tests/integration/cmd_dev_test.go index e609b5984ac..d57eb9ef531 100644 --- a/tests/integration/cmd_dev_test.go +++ b/tests/integration/cmd_dev_test.go @@ -307,7 +307,7 @@ var _ = Describe("odo dev command tests", func() { // Returned pvc yaml contains ownerreference By("creating a pvc with ownerreference", func() { - output := commonVar.CliRunner.Run("get", "pvc", "--namespace", commonVar.Project, "-o", `jsonpath='{range .items[*].metadata.ownerReferences[*]}{@..kind}{"/"}{@..name}{end}'`).Out.Contents() + output := commonVar.CliRunner.Run("get", "pvc", "--namespace", commonVar.Project, "-o", `jsonpath='{range .items[*].metadata.ownerReferences[*]}{@..kind}{"/"}{@..name}{"\n"}{end}'`).Out.Contents() Expect(string(output)).To(ContainSubstring(fmt.Sprintf("Deployment/%s-app", cmpName))) }) })