From 7417f09293a2a0337e7159341205f3a0aaab7e81 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Sun, 10 Dec 2017 21:31:17 -0800 Subject: [PATCH] feat(repo): Improve error message for missing repositories.yaml New users to helm don't always run `helm init` (e.g. if their cluster already has helm installed). The user's initial interaction with any of helm's repository commands (e.g. `helm repo list`) will then be an error message due to a missing repositories.yaml in their local config. Give the user a little hint about how to fix the error without them having to hunt through the man/help pages. --- pkg/repo/repo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index cbf54c572..194eace79 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -55,6 +55,13 @@ func NewRepoFile() *RepoFile { func LoadRepositoriesFile(path string) (*RepoFile, error) { b, err := ioutil.ReadFile(path) if err != nil { + if os.IsNotExist(err) { + return nil, fmt.Errorf( + "Couldn't load repositories file (%s).\n"+ + "You might need to run `helm init` (or "+ + "`helm init --client-only` if tiller is "+ + "already installed)", path) + } return nil, err }