From e491f2c4ca7a05e74f91c1383c362d804a66278c Mon Sep 17 00:00:00 2001 From: Jim Razmus II Date: Wed, 13 May 2020 12:15:28 -0500 Subject: [PATCH] Recognize tfvars files as hcl by default. --- viper.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/viper.go b/viper.go index f61f4ed..4312990 100644 --- a/viper.go +++ b/viper.go @@ -286,7 +286,7 @@ func NewWithOptions(opts ...Option) *Viper { // can use it in their testing as well. func Reset() { v = New() - SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "dotenv", "env", "ini"} + SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "tfvars", "dotenv", "env", "ini"} SupportedRemoteProviders = []string{"etcd", "consul", "firestore"} } @@ -325,7 +325,7 @@ type RemoteProvider interface { } // SupportedExts are universally supported extensions. -var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "dotenv", "env", "ini"} +var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl", "tfvars", "dotenv", "env", "ini"} // SupportedRemoteProviders are universally supported remote providers. var SupportedRemoteProviders = []string{"etcd", "consul", "firestore"} @@ -1496,7 +1496,7 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error { return ConfigParseError{err} } - case "hcl": + case "hcl", "tfvars": obj, err := hcl.Parse(buf.String()) if err != nil { return ConfigParseError{err} @@ -1576,7 +1576,7 @@ func (v *Viper) marshalWriter(f afero.File, configType string) error { return ConfigMarshalError{err} } - case "hcl": + case "hcl", "tfvars": b, err := json.Marshal(c) if err != nil { return ConfigMarshalError{err}