From 1174ff3500177076b6f6cec9b412de4f71e2beae Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Tue, 21 Jun 2022 08:49:33 -0400 Subject: [PATCH] Don't save component name in env.yaml **What type of PR is this:** /kind bug **What does this PR do / why we need it:** By default we should be saving the namespace / project name, not the app name / component name **Which issue(s) this PR fixes:** Fixes https://github.com/redhat-developer/odo/issues/5780 **PR acceptance criteria:** - [ ] Unit test - [ ] Integration test - [ ] Documentation **How to test changes / Special notes to the reviewer:** Signed-off-by: Charlie Drage --- pkg/odo/cli/dev/dev.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pkg/odo/cli/dev/dev.go b/pkg/odo/cli/dev/dev.go index 495c10410a2..6aa3522b062 100644 --- a/pkg/odo/cli/dev/dev.go +++ b/pkg/odo/cli/dev/dev.go @@ -145,26 +145,22 @@ func (o *DevOptions) Complete(cmdline cmdline.Cmdline, args []string) error { o.initialDevfileObj = o.Context.EnvSpecificInfo.GetDevfileObj() + // If the env.yaml does not exist, we will save the project name if !envfileinfo.Exists() { - // if env.yaml doesn't exist, get component name from the devfile.yaml - var cmpName string - cmpName, err = component.GatherName(o.EnvSpecificInfo.GetDevfileObj(), o.GetDevfilePath()) - if err != nil { - return fmt.Errorf("unable to retrieve component name: %w", err) - } - // create env.yaml file with component, project/namespace and application info - // TODO - store only namespace into env.yaml, we don't want to track component or application name via env.yaml - err = envfileinfo.SetComponentSettings(envinfo.ComponentSettings{Name: cmpName, Project: o.GetProject(), AppName: "app"}) + err = envfileinfo.SetComponentSettings(envinfo.ComponentSettings{Project: o.GetProject()}) if err != nil { return fmt.Errorf("failed to write new env.yaml file: %w", err) } - } else if envfileinfo.GetComponentSettings().Project != o.GetProject() { - // set namespace if the evn.yaml exists; that's the only piece we care about in env.yaml + } + + // If the env.yaml exists and the project is set incorrectly, we'll override it. + if envfileinfo.Exists() && envfileinfo.GetComponentSettings().Project != o.GetProject() { err = envfileinfo.SetConfiguration("project", o.GetProject()) if err != nil { return fmt.Errorf("failed to update project in env.yaml file: %w", err) } } + o.clientset.KubernetesClient.SetNamespace(o.GetProject()) // 3 steps to evaluate the paths to be ignored when "watching" the pwd/cwd for changes