0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-11-10 04:10:41 +00:00

add the -refresh option to plan and apply

This commit is contained in:
Joel Damata 2020-08-11 15:32:23 -04:00
parent f7a19b2770
commit 10db279a6d
2 changed files with 15 additions and 0 deletions

View File

@ -229,6 +229,9 @@ init_options.lock
init_options.lock-timeout init_options.lock-timeout
: Duration to wait for a state lock. Default `0s`. : Duration to wait for a state lock. Default `0s`.
init_options.refresh
: Update the state for each resource prior to planning and applying. Default `true`.
fmt_options fmt_options
: contains the configuration for the fmt action. : contains the configuration for the fmt action.

View File

@ -48,6 +48,7 @@ type (
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"`
Refresh *bool `json:"refresh"`
} }
// FmtOptions fmt options for the Terraform's fmt command // FmtOptions fmt options for the Terraform's fmt command
@ -234,6 +235,11 @@ func initCommand(config InitOptions) *exec.Cmd {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.LockTimeout)) args = append(args, fmt.Sprintf("-lock-timeout=%s", config.LockTimeout))
} }
// True is default in TF
if config.Refresh != nil {
args = append(args, fmt.Sprintf("-refresh=%t", *config.Refresh))
}
// Fail Terraform execution on prompt // Fail Terraform execution on prompt
args = append(args, "-input=false") args = append(args, "-input=false")
@ -270,6 +276,9 @@ func tfApply(config Config) *exec.Cmd {
if config.InitOptions.LockTimeout != "" { if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout)) args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
} }
if config.InitOptions.Refresh != nil {
args = append(args, fmt.Sprintf("-refresh=%t", *config.InitOptions.Refresh))
}
args = append(args, getTfoutPath()) args = append(args, getTfoutPath())
return exec.Command( return exec.Command(
@ -328,6 +337,9 @@ func tfPlan(config Config, destroy bool) *exec.Cmd {
if config.InitOptions.LockTimeout != "" { if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout)) args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
} }
if config.InitOptions.Refresh != nil {
args = append(args, fmt.Sprintf("-refresh=%t", *config.InitOptions.Refresh))
}
return exec.Command( return exec.Command(
"terraform", "terraform",
args..., args...,