From 19037bb14bec55d26b63481372fea19b2d6cf89c Mon Sep 17 00:00:00 2001 From: Ricardo N Feliciano Date: Thu, 2 Feb 2023 21:37:13 -0500 Subject: [PATCH] Improve repos file not found error (#75) --- warden/cmd/audit.go | 5 ++--- warden/cmd/util.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/warden/cmd/audit.go b/warden/cmd/audit.go index 528947d..76f658a 100644 --- a/warden/cmd/audit.go +++ b/warden/cmd/audit.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "log" "os" "strings" @@ -53,12 +52,12 @@ var ( repoFile, _, err := loadRepositoriesFile(repositoriesFileFl) if err != nil { - log.Fatal(err) + return err } policy, _, err := loadPolicyFile(policyFileFl) if err != nil { - log.Fatal(err) + return err } ghToken := viper.GetString("githubToken") diff --git a/warden/cmd/util.go b/warden/cmd/util.go index 1378470..b905944 100644 --- a/warden/cmd/util.go +++ b/warden/cmd/util.go @@ -43,7 +43,7 @@ func loadRepositoriesFile(customPath string) (*RepositoriesFile, []byte, error) yamlContent, err = loadYAMLFile("repositories.yml", customPath) if err != nil { - return nil, nil, fmt.Errorf("A Repositories file was not found. Either './repositories.yml' needs to be used or the '--repositoriesFile' flag set.") + return nil, nil, fmt.Errorf("./repositories.yml' was not found. The file either doesn't exist, you're in the wrong directory, or the '--repositoriesFile' flag needs to be set.") } err = yaml.Unmarshal(yamlContent, &repositoriesFile)