Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix env parsing panics #621

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions override/uncity.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,15 @@ func portIndexer(y any, p tree.Path) (string, error) {
return "", nil
}

func envFileIndexer(y any, _ tree.Path) (string, error) {
func envFileIndexer(y any, p tree.Path) (string, error) {
switch value := y.(type) {
case string:
return value, nil
case map[string]any:
return value["path"].(string), nil
if pathValue, ok := value["path"]; ok {
return pathValue.(string), nil
}
return "", fmt.Errorf("environment path attribut %s is missing", p)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attribut > attribute Just catched this typo while looking at 2.1.1 release.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you missed an opportunity to be recognized as contributor for next release :)
#633

}
return "", nil
}
6 changes: 5 additions & 1 deletion types/stringOrList.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func (l *StringList) DecodeMapstructure(value interface{}) error {
case []interface{}:
list := make([]string, len(v))
for i, e := range v {
list[i] = e.(string)
val, ok := e.(string)
if !ok {
return fmt.Errorf("invalid type %T for string list", value)
}
list[i] = val
}
*l = list
default:
Expand Down