mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-02 12:17:39 -06:00
df8529719c
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.
26 lines
515 B
Go
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)
|
|
}
|