mirror of
https://github.com/thegeeklab/wp-opentofu.git
synced 2024-11-24 03:10:39 +00:00
feat: add init options backend
and lockfile
(#76)
This commit is contained in:
parent
c88ab40fcd
commit
3dc0a87342
18
tofu/tofu.go
18
tofu/tofu.go
@ -23,9 +23,11 @@ type Tofu struct {
|
|||||||
|
|
||||||
// InitOptions include options for the OpenTofu init command.
|
// InitOptions include options for the OpenTofu init command.
|
||||||
type InitOptions struct {
|
type InitOptions struct {
|
||||||
|
Backend *bool `json:"backend"`
|
||||||
BackendConfig []string `json:"backend-config"`
|
BackendConfig []string `json:"backend-config"`
|
||||||
Lock *bool `json:"lock"`
|
Lock *bool `json:"lock"`
|
||||||
LockTimeout string `json:"lock-timeout"`
|
LockTimeout string `json:"lock-timeout"`
|
||||||
|
Lockfile string `json:"lockfile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FmtOptions fmt options for the OpenTofu fmt command.
|
// FmtOptions fmt options for the OpenTofu fmt command.
|
||||||
@ -52,10 +54,26 @@ func (t *Tofu) Init() *plugin_exec.Cmd {
|
|||||||
"init",
|
"init",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.InitOptions.Backend != nil {
|
||||||
|
args = append(args, fmt.Sprintf("-backend=%t", *t.InitOptions.Backend))
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range t.InitOptions.BackendConfig {
|
for _, v := range t.InitOptions.BackendConfig {
|
||||||
args = append(args, fmt.Sprintf("-backend-config=%s", v))
|
args = append(args, fmt.Sprintf("-backend-config=%s", v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.InitOptions.Lock != nil {
|
||||||
|
args = append(args, fmt.Sprintf("-lock=%t", *t.InitOptions.Lock))
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.InitOptions.Lockfile != "" {
|
||||||
|
args = append(args, fmt.Sprintf("-lockfile=%s", t.InitOptions.Lockfile))
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.InitOptions.LockTimeout != "" {
|
||||||
|
args = append(args, fmt.Sprintf("-lock-timeout=%s", t.InitOptions.LockTimeout))
|
||||||
|
}
|
||||||
|
|
||||||
// Fail tofu execution on prompt
|
// Fail tofu execution on prompt
|
||||||
args = append(args, "-input=false")
|
args = append(args, "-input=false")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user