Skip to content

Commit

Permalink
Don't save component name in env.yaml
Browse files Browse the repository at this point in the history
<!--
Thank you for opening a PR! Here are some things you need to know before submitting:

1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Dev:-odo-Dev-Guidelines
2. Label this PR accordingly with the '/kind' line
3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Dev:-Writing-and-running-tests
4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/Pull-Requests:-Review-guideline

Documentation:

If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Documentation:-Contributing
-->

**What type of PR is this:**

<!--
Add one of the following kinds:
/kind feature
/kind cleanup
/kind tests
/kind documentation

Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well.
-->
/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:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

Fixes #5780

**PR acceptance criteria:**

- [ ] Unit test

- [ ] Integration test

- [ ] Documentation

**How to test changes / Special notes to the reviewer:**

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
  • Loading branch information
cdrage committed Jun 22, 2022
1 parent 47caa79 commit 1174ff3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pkg/odo/cli/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1174ff3

Please sign in to comment.