Skip to content

Commit

Permalink
fix(render): fix panic if metadata.name is not set (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: German Lashevich <[email protected]>
  • Loading branch information
kbudde and Zebradil authored Oct 30, 2023
1 parent a22f7aa commit cdf3266
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/myks/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ func genRenderedResourceFileName(resource map[string]interface{}) string {
name := "NO_NAME"
if n, ok := resource["metadata"]; ok {
metadata := n.(map[string]interface{})
name = metadata["name"].(string)
if n, ok := metadata["name"].(string); ok {
name = n
}
}
// Worst case this returns "no_kind-no_name.yaml" which probably is not what we want.
// TODO: exit with an error instead
return fmt.Sprintf("%s-%s.yaml", strings.ToLower(kind), strings.ToLower(name))
}

Expand Down

0 comments on commit cdf3266

Please sign in to comment.