devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.29k stars 360 forks source link

Unclear error message during init using path to existing Helm chart Chart.yaml file #2838

Closed mattwelke closed 4 months ago

mattwelke commented 5 months ago

What happened?

While trying to initialize a project with DevSpace, I ran into an error message that was unclear to me at first. I had a Helm chart already, so I selected that option during init and specified the path to it in the form of <dir>/Chart.yaml. The error message told me that it couldn't continue because file Chart.yaml was missing. It didn't take me long to realize what I'd done wrong (that a Helm chart should always be a directory, not a file), so I wasn't blocked for long.

But, even though I got myself unblocked, I thought it would be pretty straightforward to contribute a fix to improve the error message. So I'm logging this issue and opening a PR to resolve it.

The error I got was:

? Please enter the relative path to your local Helm chart (e.g. ./chart) foo/Chart.yaml

error Local path `foo/Chart.yaml` is not a Helm chart (Chart.yaml missing)

What did you expect to happen instead?

Clear error message telling me the problem was that I didn't select a directory.

For example, I think a clearer error message would be:

error Local path `foo/Chart.yaml` is not a Helm chart (path is not a directory)

How can we reproduce the bug? (as minimally and precisely as possible)

On a system with Helm installed, in a test directory, follow Helm's instructions to create a chart. Then, run devspace init from the test directory. Attempt to specify the path to the Helm chart by specifying the path to the Chart.yaml file within it.

~/helm-test > devspace init

     %########%      
     %###########%       ____                 _____                      
         %#########%    |  _ \   ___ __   __ / ___/  ____    ____   ____ ___ 
         %#########%    | | | | / _ \\ \ / / \___ \ |  _ \  / _  | / __// _ \
     %#############%    | |_| |(  __/ \ V /  ____) )| |_) )( (_| |( (__(  __/
     %#############%    |____/  \___|  \_/   \____/ |  __/  \__,_| \___\\___|
 %###############%                                  |_|
 %###########%

info Detecting programming language...

? Select the programming language of this project other

? How do you want to deploy this project? 

? Do you already have a Helm chart for this project? Yes

? Which Helm chart do you want to use? 

? Please enter the relative path to your local Helm chart (e.g. ./chart) foo/Chart.yaml

error Local path `foo/Chart.yaml` is not a Helm chart (Chart.yaml missing)

? Which Helm chart do you want to use? 

? Please enter the relative path to your local Helm chart (e.g. ./chart) .

error Local path `.` is not a Helm chart (Chart.yaml missing)

? Which Helm chart do you want to use? 

? Please enter the relative path to your local Helm chart (e.g. ./chart) foo

? Do you want to develop this project with DevSpace or just deploy it?  [Use arrows to move, type to filter]  [Use arrows to move, type to filter]
> I want to develop this project and my current working dir contains the source code
  I just want to deploy this project

My devspace.yaml: n/a

Local Environment: