diff --git a/decision_maker.go b/decision_maker.go index ec6e5f93..ae1a82f0 100644 --- a/decision_maker.go +++ b/decision_maker.go @@ -275,7 +275,7 @@ func diffRelease(r *release) string { } if exitCode, msg = cmd.exec(debug, verbose); exitCode != 0 { - logError("Command returned with exit code: " + string(exitCode) + ". And error message: " + msg) + logError(fmt.Sprintf("Command returned with exit code: %d. And error message: %s ", exitCode, msg)) } else { if (verbose || showDiff) && msg != "" { fmt.Println(msg) diff --git a/decision_maker_test.go b/decision_maker_test.go index 42cf4333..4dd40226 100644 --- a/decision_maker_test.go +++ b/decision_maker_test.go @@ -94,7 +94,7 @@ func Test_inspectUpgradeScenario(t *testing.T){ Name: "release1", Namespace: "namespace", Version: "1.0.0", - Chart: "/local/charts", + Chart: "./test_files/chart-test", Enabled: true, }, s: releaseState{ diff --git a/helm_helpers.go b/helm_helpers.go index 75bb7afb..49c8ba70 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -331,15 +331,15 @@ func getChartVersion(r *release) (string, string) { } if exitCode, result := cmd.exec(debug, verbose); exitCode != 0 || strings.Contains(result, "No results found") { - return "", "ERROR: chart " + r.Chart + " with version " + r.Version + " is specified for " + "but version is not found in the defined repo." + return "", "ERROR: chart " + r.Chart + " with version " + r.Version + " is specified but not found in the helm repos." } else { versions := strings.Split(result, "\n") if len(versions) < 2 { - return "", "ERROR: chart " + r.Chart + " with version " + r.Version + " is specified for " + "but version is not found in the defined repo." + return "", "ERROR: chart " + r.Chart + " with version " + r.Version + " is specified but not found in the helm repos (unrecognized helm output?)." } fields := strings.Split(versions[1], "\t") if len(fields) != 4 { - return "", "ERROR: chart " + r.Chart + " with version " + r.Version + " is specified for " + "but version is not found in the defined repo." + return "", "ERROR: chart " + r.Chart + " with version " + r.Version + " is specified but not found in the helm repos (unrecognized helm output?)." } return strings.TrimSpace(fields[1]), "" } diff --git a/helm_helpers_test.go b/helm_helpers_test.go index 57f0c243..547c91e3 100644 --- a/helm_helpers_test.go +++ b/helm_helpers_test.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "testing" "time" @@ -16,7 +17,7 @@ func setupTestCase(t *testing.T) func(t *testing.T) { Description: "creating an empty local chart directory", } if exitCode, msg := cmd.exec(debug, verbose); exitCode != 0 { - logError("Command returned with exit code: " + string(exitCode) + ". And error message: " + msg) + logError(fmt.Sprintf("Command returned with exit code: %d. And error message: %s ", exitCode, msg)) } return func(t *testing.T) { @@ -359,7 +360,7 @@ func Test_getChartVersion(t *testing.T) { Name: "release1", Namespace: "namespace", Version: "1.0.0", - Chart: "/local/charts", + Chart: "./test_files/chart-test", Enabled: true, }, }, @@ -388,4 +389,4 @@ func Test_getChartVersion(t *testing.T) { } }) } -} \ No newline at end of file +} diff --git a/plan.go b/plan.go index 8d44a7ce..40f4e8bf 100644 --- a/plan.go +++ b/plan.go @@ -100,7 +100,7 @@ func (p plan) execPlan() { if errorMsg = msg; !verbose { errorMsg = strings.Split(msg, "---")[0] } - logError("Command returned with exit code: " + string(exitCode) + ". And error message: " + errorMsg) + logError(fmt.Sprintf("Command returned with exit code: %d. And error message: %s ", exitCode, errorMsg)) } else { log.Println(style.Cyan(msg)) if cmd.targetRelease != nil && !dryRun { diff --git a/test_files/chart-test/Chart.yaml b/test_files/chart-test/Chart.yaml new file mode 100644 index 00000000..27cbcc07 --- /dev/null +++ b/test_files/chart-test/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v1 +name: chart-test +version: 1.0.0 diff --git a/utils.go b/utils.go index 555a615c..3788c484 100644 --- a/utils.go +++ b/utils.go @@ -521,7 +521,11 @@ func Indent(s, prefix string) string { // isLocalChart checks if a chart specified in the DSF is a local directory or not func isLocalChart(chart string) bool { - return filepath.IsAbs(chart) + _, err := os.Stat(chart) + if err == nil { + return true + } + return false } func generateCmdDescription(r *release, action string) string { @@ -543,4 +547,4 @@ func generateDecisionMessage(r *release, message string, isTillerAware bool) str return fmt.Sprintf(baseMessage + " %s", tillerNamespaceMsg) } return baseMessage -} \ No newline at end of file +}