opentofu/helper/variables/flag_any.go
Mitchell Hashimoto df8529719c
command/init: backend-config accepts key=value pairs
This augments backend-config to also accept key=value pairs.
This should make Terraform easier to script rather than having to
generate a JSON file.

You must still specify the backend type as a minimal amount in
configurations, example:

```
terraform { backend "consul" {} }
```

This is required because Terraform needs to be able to detect the
_absense_ of that value for unsetting, if that is necessary at some
point.
2017-03-16 23:27:05 -07:00

26 lines
515 B
Go

package variables
import (
"strings"
)
// FlagAny is a flag.Value for parsing user variables in the format of
// 'key=value' OR a file path. 'key=value' is assumed if '=' is in the value.
// You cannot use a file path that contains an '='.
type FlagAny map[string]interface{}
func (v *FlagAny) String() string {
return ""
}
func (v *FlagAny) Set(raw string) error {
idx := strings.Index(raw, "=")
if idx >= 0 {
flag := (*Flag)(v)
return flag.Set(raw)
}
flag := (*FlagFile)(v)
return flag.Set(raw)
}