Skip to content

Commit

Permalink
fix KO_CONFIG_PATH pointing to a file (#923)
Browse files Browse the repository at this point in the history
* fix KO_CONFIG_PATH pointing to a file

* make test pass
  • Loading branch information
imjasonh authored Jan 11, 2023
1 parent 7bf3626 commit 453bf80
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/commands/options/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 453bf80

Please sign in to comment.