diff --git a/.gitignore b/.gitignore index 7f84399..f903160 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ *.out go-yq* -test.yaml \ No newline at end of file +test.yaml + +vendor \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index c1f33fd..ad80837 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: go script: - - go test + - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + - dep ensure -update + - go test ./... -cover - wget https://gist.githubusercontent.com/030/da7c28869ae69fc4c02634e253ab615b/raw/43df4fbbff30d6e065e0de1270e5ee9ad0803bb7/go-releases.sh - chmod +x ./go-releases.sh - ./go-releases.sh yq diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..f87cfa9 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,137 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + digest = "1:abeb38ade3f32a92943e5be54f55ed6d6e3b6602761d74b4aab4c9dd45c18abd" + name = "github.com/fsnotify/fsnotify" + packages = ["."] + pruneopts = "UT" + revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" + version = "v1.4.7" + +[[projects]] + digest = "1:c0d19ab64b32ce9fe5cf4ddceba78d5bc9807f0016db6b1183599da3dcc24d10" + name = "github.com/hashicorp/hcl" + packages = [ + ".", + "hcl/ast", + "hcl/parser", + "hcl/printer", + "hcl/scanner", + "hcl/strconv", + "hcl/token", + "json/parser", + "json/scanner", + "json/token", + ] + pruneopts = "UT" + revision = "8cb6e5b959231cc1119e43259c4a608f9c51a241" + version = "v1.0.0" + +[[projects]] + digest = "1:c568d7727aa262c32bdf8a3f7db83614f7af0ed661474b24588de635c20024c7" + name = "github.com/magiconair/properties" + packages = ["."] + pruneopts = "UT" + revision = "c2353362d570a7bfa228149c62842019201cfb71" + version = "v1.8.0" + +[[projects]] + digest = "1:53bc4cd4914cd7cd52139990d5170d6dc99067ae31c56530621b18b35fc30318" + name = "github.com/mitchellh/mapstructure" + packages = ["."] + pruneopts = "UT" + revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe" + version = "v1.1.2" + +[[projects]] + digest = "1:95741de3af260a92cc5c7f3f3061e85273f5a81b5db20d4bd68da74bd521675e" + name = "github.com/pelletier/go-toml" + packages = ["."] + pruneopts = "UT" + revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" + version = "v1.2.0" + +[[projects]] + digest = "1:6a4a11ba764a56d2758899ec6f3848d24698d48442ebce85ee7a3f63284526cd" + name = "github.com/spf13/afero" + packages = [ + ".", + "mem", + ] + pruneopts = "UT" + revision = "d40851caa0d747393da1ffb28f7f9d8b4eeffebd" + version = "v1.1.2" + +[[projects]] + digest = "1:08d65904057412fc0270fc4812a1c90c594186819243160dc779a402d4b6d0bc" + name = "github.com/spf13/cast" + packages = ["."] + pruneopts = "UT" + revision = "8c9545af88b134710ab1cd196795e7f2388358d7" + version = "v1.3.0" + +[[projects]] + digest = "1:68ea4e23713989dc20b1bded5d9da2c5f9be14ff9885beef481848edd18c26cb" + name = "github.com/spf13/jwalterweatherman" + packages = ["."] + pruneopts = "UT" + revision = "4a4406e478ca629068e7768fc33f3f044173c0a6" + version = "v1.0.0" + +[[projects]] + digest = "1:c1b1102241e7f645bc8e0c22ae352e8f0dc6484b6cb4d132fa9f24174e0119e2" + name = "github.com/spf13/pflag" + packages = ["."] + pruneopts = "UT" + revision = "298182f68c66c05229eb03ac171abe6e309ee79a" + version = "v1.0.3" + +[[projects]] + digest = "1:de37e343c64582d7026bf8ab6ac5b22a72eac54f3a57020db31524affed9f423" + name = "github.com/spf13/viper" + packages = ["."] + pruneopts = "UT" + revision = "6d33b5a963d922d182c91e8a1c88d81fd150cfd4" + version = "v1.3.1" + +[[projects]] + branch = "master" + digest = "1:418531991b3ea024fd1947c8fdd18019b3ce285025955fddc6b8e4cc4f9213fc" + name = "golang.org/x/sys" + packages = ["unix"] + pruneopts = "UT" + revision = "7da8ea5c81829e397bdf930c5d8ba4b703616f33" + +[[projects]] + digest = "1:8029e9743749d4be5bc9f7d42ea1659471767860f0cdc34d37c3111bd308a295" + name = "golang.org/x/text" + packages = [ + "internal/gen", + "internal/triegen", + "internal/ucd", + "transform", + "unicode/cldr", + "unicode/norm", + ] + pruneopts = "UT" + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" + +[[projects]] + digest = "1:4d2e5a73dc1500038e504a8d78b986630e3626dc027bc030ba5c75da257cdb96" + name = "gopkg.in/yaml.v2" + packages = ["."] + pruneopts = "UT" + revision = "51d6538a90f86fe93ac480b35f37b2be17fef232" + version = "v2.2.2" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = [ + "github.com/spf13/viper", + "gopkg.in/yaml.v2", + ] + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..d7c5c9b --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,38 @@ +# Gopkg.toml example +# +# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" +# +# [prune] +# non-go = false +# go-tests = true +# unused-packages = true + + +[[constraint]] + name = "github.com/spf13/viper" + version = "1.3.1" + +[[constraint]] + name = "gopkg.in/yaml.v2" + version = "2.2.2" + +[prune] + go-tests = true + unused-packages = true diff --git a/main.go b/main.go index a2d40e1..2dedfa1 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ func (i input) value() string { if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - value := fmt.Sprintf("%s", viper.Get(keyWithoutFirstDot)) + value := fmt.Sprintf("%v", viper.Get(keyWithoutFirstDot)) if value == "%!s()" { log.Fatal("File: ", i.file, " does not contain key: ", i.key) diff --git a/main_test.go b/main_test.go index 8f96221..84e526b 100644 --- a/main_test.go +++ b/main_test.go @@ -34,6 +34,10 @@ firefox_checksum: sha512:49d776 hello: world: hallo wereld world: [hola, hallo] +firefox_version4: 64 +firefox_version3: 64.1 +firefox_version2: "64.0" +firefox_version: 64.0.0 ` type T struct { @@ -78,8 +82,12 @@ func TestYamlValue(t *testing.T) { ".foo.bar": "boo", ".services.db.image": "someimage", ".services.db.environment.MYSQL_ROOT_PASSWORD": "somewordpress", - ".world": "[hola hallo]", - ".hello.world": "hallo wereld", + ".world": "[hola hallo]", + ".hello.world": "hallo wereld", + ".firefox_version4": "64", + ".firefox_version3": "64.1", + ".firefox_version2": "64.0", + ".firefox_version": "64.0.0", } for key, value := range keyValue {