From 00e71ebd90f8df4c54357d92172c427a5810f849 Mon Sep 17 00:00:00 2001 From: michalk Date: Fri, 22 Oct 2021 15:58:37 +0200 Subject: [PATCH] Add option to use flag -detailed-exitcode for terraform plan action --- main.go | 6 ++++++ plugin.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/main.go b/main.go index d396e76..451afaa 100644 --- a/main.go +++ b/main.go @@ -119,6 +119,11 @@ func main() { Usage: "whether or not to disable refreshing state before `plan` and `apply` commands", 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 { @@ -169,6 +174,7 @@ func run(c *cli.Context) error { VarFiles: c.StringSlice("var_files"), TerraformDataDir: c.String("tf_data_dir"), DisableRefresh: c.Bool("disable_refresh"), + DetailedExitcode: c.Bool("detailed_exitcode"), }, Netrc: Netrc{ Login: c.String("netrc.username"), diff --git a/plugin.go b/plugin.go index 6646fcf..ce40001 100644 --- a/plugin.go +++ b/plugin.go @@ -35,6 +35,7 @@ type ( VarFiles []string TerraformDataDir string DisableRefresh bool + DetailedExitcode bool } // Netrc is credentials for cloning @@ -325,6 +326,9 @@ func tfPlan(config Config, destroy bool) *exec.Cmd { if config.DisableRefresh { args = append(args, "-refresh=false") } + if config.DetailedExitcode { + args = append(args, "-detailed-exitcode") + } return exec.Command( "terraform", args...,