Skip to content

Commit

Permalink
fix: Allow YAML files to have no extension (#35)
Browse files Browse the repository at this point in the history
The file extension wasn't used previously to determine if a file was yaml.
So the addition of JSON and thus checking of extensions introduced a
scenario where yaml files without extension resulted in an error. This
change allows resets the default behavior that a file with no extension
is assumed to be yaml.

Added integration tests to test all three variants
  • Loading branch information
abtreece committed Sep 29, 2021
1 parent 4564eaf commit 6d3d05d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backends/file/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func readFile(path string, vars map[string]string) error {
return err
}
err = nodeWalk(fileMap, "/", vars)
case ".yml", ".yaml":
case "", ".yml", ".yaml":
fileMap := make(map[interface{}]interface{})
err = yaml.Unmarshal(data, &fileMap)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions integration/file/test_yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export HOSTNAME="localhost"
mkdir backends1 backends2
cat <<EOT >> backends1/1.yaml
cat <<EOT >> backends1/1
key: foobar
database:
host: 127.0.0.1
Expand All @@ -11,7 +11,7 @@ database:
username: confd
EOT

cat <<EOT >> backends1/2.yaml
cat <<EOT >> backends1/2.yml
upstream:
app1: 10.0.1.10:8080
app2: 10.0.1.11:8080
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

const Version = "0.18.3-dev"
const Version = "0.18.3"

// We want to replace this variable at build time with "-ldflags -X main.GitSHA=xxx", where const is not supported.
var GitSHA = ""

0 comments on commit 6d3d05d

Please sign in to comment.