0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-11-24 23:30:39 +00:00

rename to disable_refrsh

This commit is contained in:
Joel Damata 2020-08-14 16:43:44 -04:00
parent 10db279a6d
commit 079b8769d1
3 changed files with 14 additions and 13 deletions

View File

@ -229,9 +229,6 @@ 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.
@ -272,3 +269,6 @@ parallelism
tf_data_dir tf_data_dir
: changes the location where Terraform keeps its per-working-directory data, such as the current remote backend configuration. : changes the location where Terraform keeps its per-working-directory data, such as the current remote backend configuration.
disable_refresh
: (default: `false`) - whether or not to disable refreshing state before `plan` and `apply` commands.

View File

@ -114,6 +114,11 @@ func main() {
Usage: "changes the location where Terraform keeps its per-working-directory data, such as the current remote backend configuration", Usage: "changes the location where Terraform keeps its per-working-directory data, such as the current remote backend configuration",
EnvVar: "PLUGIN_TF_DATA_DIR", EnvVar: "PLUGIN_TF_DATA_DIR",
}, },
cli.BoolFlag{
Name: "disable_refresh",
Usage: "whether or not to disable refreshing state before `plan` and `apply` commands",
EnvVar: "PLUGIN_DISABLE_REFRESH",
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
@ -163,6 +168,7 @@ func run(c *cli.Context) error {
Targets: c.StringSlice("targets"), Targets: c.StringSlice("targets"),
VarFiles: c.StringSlice("var_files"), VarFiles: c.StringSlice("var_files"),
TerraformDataDir: c.String("tf_data_dir"), TerraformDataDir: c.String("tf_data_dir"),
DisableRefresh: c.Bool("disable_refresh"),
}, },
Netrc: Netrc{ Netrc: Netrc{
Login: c.String("netrc.username"), Login: c.String("netrc.username"),

View File

@ -34,6 +34,7 @@ type (
Targets []string Targets []string
VarFiles []string VarFiles []string
TerraformDataDir string TerraformDataDir string
DisableRefresh bool
} }
// Netrc is credentials for cloning // Netrc is credentials for cloning
@ -48,7 +49,6 @@ 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
@ -235,11 +235,6 @@ 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")
@ -276,8 +271,8 @@ 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 { if config.DisableRefresh {
args = append(args, fmt.Sprintf("-refresh=%t", *config.InitOptions.Refresh)) args = append(args, "-refresh=false")
} }
args = append(args, getTfoutPath()) args = append(args, getTfoutPath())
@ -337,8 +332,8 @@ 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 { if config.DisableRefresh {
args = append(args, fmt.Sprintf("-refresh=%t", *config.InitOptions.Refresh)) args = append(args, "-refresh=false")
} }
return exec.Command( return exec.Command(
"terraform", "terraform",