From 453bf803e379696a0b9142c772402ba4599cff34 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Wed, 11 Jan 2023 14:33:17 -0500 Subject: [PATCH] fix KO_CONFIG_PATH pointing to a file (#923) * fix KO_CONFIG_PATH pointing to a file * make test pass --- pkg/commands/options/build.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/commands/options/build.go b/pkg/commands/options/build.go index 635958f8b4..d06c245627 100644 --- a/pkg/commands/options/build.go +++ b/pkg/commands/options/build.go @@ -108,21 +108,22 @@ func (bo *BuildOptions) LoadConfig() error { if err != nil { return fmt.Errorf("error looking for config file: %w", err) } - var path string - if file.IsDir() { - path = filepath.Join(override, configName+".yaml") + if file.Mode().IsRegular() { + v.SetConfigFile(override) + } else if file.IsDir() { + path := filepath.Join(override, ".ko.yaml") file, err = os.Stat(path) if err != nil { return fmt.Errorf("error looking for config file: %w", err) } + if file.Mode().IsRegular() { + v.SetConfigFile(path) + } else { + return fmt.Errorf("config file %s is not a regular file", path) + } } else { - path = override - } - - if !file.Mode().IsRegular() { - return fmt.Errorf("config file %s is not a regular file", path) + return fmt.Errorf("config file %s is not a regular file", override) } - v.AddConfigPath(override) } v.AddConfigPath(bo.WorkingDirectory)