Skip to content

Commit

Permalink
Updates the error output for an empty directory
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 bug
/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.
-->

**What does this PR do / why we need it:**

Updates the error output for running `odo dev` or `odo deploy` in an
empty directory. Telling the user to run the same command in a non-empty
dir, OR use `odo init`.

**Which issue(s) this PR fixes:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

N/A

**PR acceptance criteria:**

- [X] Unit test

- [X] Integration test

- [X] Documentation

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

Signed-off-by: Charlie Drage <[email protected]>
  • Loading branch information
cdrage committed Mar 30, 2022
1 parent 4669bc9 commit 90c5bca
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/odo/cli/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (o *DeployOptions) Complete(cmdline cmdline.Cmdline, args []string) (err er
return err
}
if isEmptyDir {
return errors.New("this command cannot run in an empty directory, you need to run it in a directory containing source code")
return errors.New("This command cannot run in an empty directory. Run the command in a directory containing source code.\nIf you wish to initialize a new project with sample source code, use 'odo init'.")
}

initFlags := o.clientset.InitClient.GetFlags(cmdline.GetFlags())
Expand Down
2 changes: 1 addition & 1 deletion pkg/odo/cli/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (o *DevOptions) Complete(cmdline cmdline.Cmdline, args []string) error {
return err
}
if isEmptyDir {
return errors.New("this command cannot run in an empty directory, you need to run it in a directory containing source code")
return errors.New("This command cannot run in an empty directory. Run the command in a directory containing source code.\nIf you wish to initialize a new project with sample source code, use 'odo init'.")
}
initFlags := o.clientset.InitClient.GetFlags(cmdline.GetFlags())
err = o.clientset.InitClient.InitDevfile(initFlags, o.contextDir,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/devfile/cmd_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("odo dev command tests", func() {

It("should error", func() {
output := helper.Cmd("odo", "dev").ShouldFail().Err()
Expect(output).To(ContainSubstring("this command cannot run in an empty directory"))
Expect(output).To(ContainSubstring("This command cannot run in an empty directory"))

})
})
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/devfile/cmd_devfile_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = Describe("odo devfile deploy command tests", func() {

It("should error", func() {
output := helper.Cmd("odo", "deploy").ShouldFail().Err()
Expect(output).To(ContainSubstring("this command cannot run in an empty directory"))
Expect(output).To(ContainSubstring("This command cannot run in an empty directory"))

})
})
Expand Down

0 comments on commit 90c5bca

Please sign in to comment.