Repository: helm/helm (go)

Issue:
Using `helm lint <path> --quiet` produces no output, even when there's an error.
### What happened?

When running `helm lint <path> --quiet`, for some reason, `helm doesn't show any errors. However, if `--quiet` is removed, then errors are shown.

### Steps to reproduce

1. run `helm lint nonexistent/ --quiet`
2. No error is displayed despite that `nonexistent/` doesn't exist. The command exit code is `0` and not `1` to indicate an error.
3. run `helm lint nonexistent/`
4. the output is
```
==> Linting nonexistent/
Error unable to check Chart.yaml file in chart: stat nonexistent/Chart.yaml: no such file or directory

Error: 1 chart(s) linted, 1 chart(s) failed
```

1. run `mkdir charts/`
2. run `helm lint charts/ --quiet`
3. no error is displayed despite the missing `Chart.yaml`. The command exit code is `0` and not `1` to indicate an error.
4. run `helm lint charts/`
```
==> Linting charts/
Error unable to check Chart.yaml file in chart: stat charts/Chart.yaml: no such file or directory

Error: 1 chart(s) linted, 1 chart(s) failed
```

### Expected Behavior

As stated in the command usage `--quiet print only warnings and errors` which is not honored in this case. On error, the command should return `1`.

### Actual Behavior

No outputs at all, including errors. Even with a clear error, the command exit code is `0`.

### Additional context

Output of `helm version`: `version.BuildInfo{Version:"v3.10.0", GitCommit:"ce66412a723e4d89555dc67217607c6579ffcb21", GitTreeState:"clean", GoVersion:"go1.18.6"}`

Output of `kubectl version`: `Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.2", GitCommit:"5835544ca568b757a8ecae5c153f317e5736700e", GitTreeState:"clean", BuildDate:"2022-09-21T14:33:49Z", GoVersion:"go1.19.1", Compiler:"gc", Platform:"linux/amd64"}`

Cloud Provider/Platform (AKS, GKE, Minikube etc.): `k3s` and bare-metal

### Contributing

Vote on this issue by adding a 👍 reaction. 
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already). 


Pull request:
fail quiet linting when an error occurs
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. Make sure to read the Contributing Guide before submitting your PR: https://github.com/helm/helm/blob/main/CONTRIBUTING.md
2. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context.-->

**What this PR does / why we need it**:

When linting with the `--quiet` flag, non-linting errors, such as `no such file or directory` would not fail and would exit with a 0 result. This now checks for errors as well as linting messages and fails correctly.

Fixes #11411 

**Special notes for your reviewer**:

**If applicable**:
- [ ] this PR contains documentation
- [x] this PR contains unit tests
- [ ] this PR has been tested for backwards compatibility


Patch:
diff --git a/pkg/action/lint.go b/pkg/action/lint.go
index adb8ebcab..e71cfe733 100644
--- a/pkg/action/lint.go
+++ b/pkg/action/lint.go
@@ -82,7 +82,7 @@ func HasWarningsOrErrors(result *LintResult) bool {
 			return true
 		}
 	}
-	return false
+	return len(result.Errors) > 0
 }
 
 func lintChart(path string, vals map[string]interface{}, namespace string, strict bool) (support.Linter, error) {


Test patch:
diff --git a/cmd/helm/lint_test.go b/cmd/helm/lint_test.go
index ebea09bf0..314b54c35 100644
--- a/cmd/helm/lint_test.go
+++ b/cmd/helm/lint_test.go
@@ -53,6 +53,11 @@ func TestLintCmdWithQuietFlag(t *testing.T) {
 		name:   "lint chart with warning using --quiet flag",
 		cmd:    "lint --quiet testdata/testcharts/chart-with-only-crds",
 		golden: "output/lint-quiet-with-warning.txt",
+	}, {
+		name:      "lint non-existent chart using --quiet flag",
+		cmd:       "lint --quiet thischartdoesntexist/",
+		golden:    "",
+		wantError: true,
 	}}
 	runTestCmd(t, tests)