Browse Source

Add option to use flag -detailed-exitcode for terraform plan action

pull/133/head
michalk 3 years ago
parent
commit
00e71ebd90
  1. 6
      main.go
  2. 4
      plugin.go

6
main.go

@ -119,6 +119,11 @@ func main() {
Usage: "whether or not to disable refreshing state before `plan` and `apply` commands", Usage: "whether or not to disable refreshing state before `plan` and `apply` commands",
EnvVar: "PLUGIN_DISABLE_REFRESH", EnvVar: "PLUGIN_DISABLE_REFRESH",
}, },
cli.BoolFlag{
Name: "detailed_exitcode",
Usage: "whether or not to use flag `-detailed-exitcode` with `plan` command",
EnvVar: "PLUGIN_DETAILED_EXITCODE",
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
@ -169,6 +174,7 @@ func run(c *cli.Context) error {
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"), DisableRefresh: c.Bool("disable_refresh"),
DetailedExitcode: c.Bool("detailed_exitcode"),
}, },
Netrc: Netrc{ Netrc: Netrc{
Login: c.String("netrc.username"), Login: c.String("netrc.username"),

4
plugin.go

@ -35,6 +35,7 @@ type (
VarFiles []string VarFiles []string
TerraformDataDir string TerraformDataDir string
DisableRefresh bool DisableRefresh bool
DetailedExitcode bool
} }
// Netrc is credentials for cloning // Netrc is credentials for cloning
@ -325,6 +326,9 @@ func tfPlan(config Config, destroy bool) *exec.Cmd {
if config.DisableRefresh { if config.DisableRefresh {
args = append(args, "-refresh=false") args = append(args, "-refresh=false")
} }
if config.DetailedExitcode {
args = append(args, "-detailed-exitcode")
}
return exec.Command( return exec.Command(
"terraform", "terraform",
args..., args...,

Loading…
Cancel
Save