diff --git a/main.go b/main.go index cb9c691..62347f0 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,11 @@ func main() { Name: "env-file", Usage: "source env file", }, + cli.StringFlag{ + Name: "planfile", + Usage: "The absolute path to save the outfile eg: /tmp/myplan.tfout", + EnvVar: "PLUGIN_PLANFILE", + }, cli.StringFlag{ Name: "init_options", Usage: "options for the init command. See https://www.terraform.io/docs/commands/init.html", @@ -48,11 +53,6 @@ func main() { Usage: "The number of concurrent operations as Terraform walks its graph", EnvVar: "PLUGIN_PARALLELISM", }, - cli.StringFlag{ - Name: "plan_path", - Usage: "The absolute path to save the outfile eg: /tmp/myplan.tfout", - EnvVar: "PLUGIN_PLAN_PATH", - }, cli.StringFlag{ Name: "netrc.machine", Usage: "netrc machine", @@ -151,7 +151,7 @@ func run(c *cli.Context) error { RoleARN: c.String("role_arn_to_assume"), RootDir: c.String("root_dir"), Parallelism: c.Int("parallelism"), - PlanPath: c.String("plan_path"), + Planfile: c.String("planfile"), Targets: c.StringSlice("targets"), VarFiles: c.StringSlice("var_files"), }, diff --git a/plugin.go b/plugin.go index dead0b3..7d7d5fc 100644 --- a/plugin.go +++ b/plugin.go @@ -28,7 +28,7 @@ type ( Cacert string Sensitive bool RoleARN string - PlanPath string + Planfile string RootDir string Parallelism int Targets []string @@ -275,12 +275,9 @@ func tfApply(config Config) *exec.Cmd { if config.InitOptions.LockTimeout != "" { args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout)) } - if config.PlanPath != "" { - fmt.Println("--- Setting an outpath---") - args = append(args, config.PlanPath) + if config.Planfile != "" { + args = append(args, config.Planfile) } else { - fmt.Println("--- borked ---") - fmt.Println(config.PlanPath) args = append(args, "plan.tfout") } return exec.Command( @@ -319,10 +316,15 @@ func tfPlan(config Config, destroy bool) *exec.Cmd { "plan", } + logrus.WithFields(logrus.Fields{ + "Config.Parallelism": config.Parallelism, + "Config.Planfile": config.Planfile, + }).Info("Configuration") + if destroy { args = append(args, "-destroy") - } else if config.PlanPath != "" { - args = append(args, fmt.Sprintf("-out=%s", config.PlanPath)) + } else if config.Planfile != "" { + args = append(args, fmt.Sprintf("-out=%s", config.Planfile)) } else { args = append(args, "-out=plan.tfout") } diff --git a/plugin_test.go b/plugin_test.go index 1f95cbd..431bb7f 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -45,7 +45,7 @@ func TestPlugin(t *testing.T) { }, { "with path", - args{config: Config{PlanPath: "/tmp/a.tfout"}}, + args{config: Config{Planfile: "/tmp/a.tfout"}}, exec.Command("terraform", "apply", "/tmp/a.tfout"), }, { @@ -130,7 +130,7 @@ func TestPlugin(t *testing.T) { }, { "with path", - args{config: Config{PlanPath: "/tmp/a.tfout"}}, + args{config: Config{Planfile: "/tmp/a.tfout"}}, false, exec.Command("terraform", "plan", "-out=/tmp/a.tfout"), },