@@ -105,6 +105,9 @@ func init() {
105
105
106
106
encoderRegistry .RegisterEncoder ("hcl" , codec )
107
107
decoderRegistry .RegisterDecoder ("hcl" , codec )
108
+
109
+ encoderRegistry .RegisterEncoder ("tfvars" , codec )
110
+ decoderRegistry .RegisterDecoder ("tfvars" , codec )
108
111
}
109
112
}
110
113
@@ -329,7 +332,7 @@ func NewWithOptions(opts ...Option) *Viper {
329
332
// can use it in their testing as well.
330
333
func Reset () {
331
334
v = New ()
332
- SupportedExts = []string {"json" , "toml" , "yaml" , "yml" , "properties" , "props" , "prop" , "hcl" , "dotenv" , "env" , "ini" }
335
+ SupportedExts = []string {"json" , "toml" , "yaml" , "yml" , "properties" , "props" , "prop" , "hcl" , "tfvars" , " dotenv" , "env" , "ini" }
333
336
SupportedRemoteProviders = []string {"etcd" , "consul" , "firestore" }
334
337
}
335
338
@@ -368,7 +371,7 @@ type RemoteProvider interface {
368
371
}
369
372
370
373
// SupportedExts are universally supported extensions.
371
- var SupportedExts = []string {"json" , "toml" , "yaml" , "yml" , "properties" , "props" , "prop" , "hcl" , "dotenv" , "env" , "ini" }
374
+ var SupportedExts = []string {"json" , "toml" , "yaml" , "yml" , "properties" , "props" , "prop" , "hcl" , "tfvars" , " dotenv" , "env" , "ini" }
372
375
373
376
// SupportedRemoteProviders are universally supported remote providers.
374
377
var SupportedRemoteProviders = []string {"etcd" , "consul" , "firestore" }
@@ -1624,7 +1627,7 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
1624
1627
buf .ReadFrom (in )
1625
1628
1626
1629
switch format := strings .ToLower (v .getConfigType ()); format {
1627
- case "yaml" , "yml" , "json" , "toml" , "hcl" :
1630
+ case "yaml" , "yml" , "json" , "toml" , "hcl" , "tfvars" :
1628
1631
err := decoderRegistry .Decode (format , buf .Bytes (), & c )
1629
1632
if err != nil {
1630
1633
return ConfigParseError {err }
@@ -1681,7 +1684,7 @@ func (v *Viper) unmarshalReader(in io.Reader, c map[string]interface{}) error {
1681
1684
func (v * Viper ) marshalWriter (f afero.File , configType string ) error {
1682
1685
c := v .AllSettings ()
1683
1686
switch configType {
1684
- case "yaml" , "yml" , "json" , "toml" , "hcl" :
1687
+ case "yaml" , "yml" , "json" , "toml" , "hcl" , "tfvars" :
1685
1688
b , err := encoderRegistry .Encode (configType , c )
1686
1689
if err != nil {
1687
1690
return ConfigMarshalError {err }
0 commit comments