Skip to content

Commit

Permalink
Deal with ambiguous filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
stilvoid committed Mar 7, 2019
1 parent 638b5bd commit 3e47f0a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions goformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ func OpenWithOptions(filename string, options *intrinsics.ProcessorOptions) (*cl
}

if strings.HasSuffix(filename, ".yaml") || strings.HasSuffix(filename, ".yml") {
// This is definitely YAML
return ParseYAMLWithOptions(data, options)
} else if strings.HasSuffix(filename, ".template") {
// We can't tell from the extension so let's try parsing as YAML first
t, err := ParseYAMLWithOptions(data, options)
if err == nil {
return t, err
}
}

return ParseJSONWithOptions(data, options)
Expand Down

0 comments on commit 3e47f0a

Please sign in to comment.