From b91c7b9659186b8e7b7c5a3a3a9311c137d74dae Mon Sep 17 00:00:00 2001 From: Matt Welke Date: Fri, 12 Apr 2024 15:23:41 -0400 Subject: [PATCH 1/2] fix: better error message for invalid Helm Chart path during init Signed-off-by: Matt Welke --- pkg/devspace/configure/deployment.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/devspace/configure/deployment.go b/pkg/devspace/configure/deployment.go index b4c2d6678..d6b620f76 100644 --- a/pkg/devspace/configure/deployment.go +++ b/pkg/devspace/configure/deployment.go @@ -145,8 +145,18 @@ func (m *manager) AddHelmDeployment(deploymentName string) error { localChartPathRel = localChartPath } - stat, err := os.Stat(path.Join(localChartPathRel, "Chart.yaml")) - if err != nil || stat.IsDir() { + pathStat, err := os.Stat(localChartPath) + if err != nil { + return err + } + + if !pathStat.IsDir() { + m.log.WriteString(logrus.InfoLevel, "\n") + m.log.Errorf("Local path `%s` is not a Helm chart (path is not a directory)", localChartPathRel) + continue + } + + if _, err := os.Stat(path.Join(localChartPathRel, "Chart.yaml")); errors.Is(err, os.ErrNotExist) { m.log.WriteString(logrus.InfoLevel, "\n") m.log.Errorf("Local path `%s` is not a Helm chart (Chart.yaml missing)", localChartPathRel) continue From 84cbb8bd91730bd377559101d7c57b57134170fc Mon Sep 17 00:00:00 2001 From: Matt Welke Date: Thu, 9 May 2024 18:59:28 -0400 Subject: [PATCH 2/2] Made changes for path and error handling from PR review. Signed-off-by: Matt Welke --- pkg/devspace/configure/deployment.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/devspace/configure/deployment.go b/pkg/devspace/configure/deployment.go index d6b620f76..440ddb6ed 100644 --- a/pkg/devspace/configure/deployment.go +++ b/pkg/devspace/configure/deployment.go @@ -145,7 +145,7 @@ func (m *manager) AddHelmDeployment(deploymentName string) error { localChartPathRel = localChartPath } - pathStat, err := os.Stat(localChartPath) + pathStat, err := os.Stat(localChartPathRel) if err != nil { return err } @@ -156,10 +156,15 @@ func (m *manager) AddHelmDeployment(deploymentName string) error { continue } - if _, err := os.Stat(path.Join(localChartPathRel, "Chart.yaml")); errors.Is(err, os.ErrNotExist) { + if _, err := os.Stat(path.Join(localChartPathRel, "Chart.yaml")); err != nil { m.log.WriteString(logrus.InfoLevel, "\n") - m.log.Errorf("Local path `%s` is not a Helm chart (Chart.yaml missing)", localChartPathRel) - continue + if errors.Is(err, os.ErrNotExist) { + m.log.Errorf("Local path `%s` is not a Helm chart (Chart.yaml missing)", localChartPathRel) + continue + } else { + m.log.Errorf("Encountered unexpected error checking local path `%s`: %s", localChartPathRel, err.Error()) + continue + } } helmConfig.Chart.Name = localChartPathRel