|
@ -24,47 +24,47 @@ func main() { |
|
|
//
|
|
|
//
|
|
|
|
|
|
|
|
|
cli.BoolFlag{ |
|
|
cli.BoolFlag{ |
|
|
Name: "terraform.plan", |
|
|
Name: "plan", |
|
|
Usage: "calculates a plan but does NOT apply it", |
|
|
Usage: "calculates a plan but does NOT apply it", |
|
|
EnvVar: "PLUGIN_PLAN", |
|
|
EnvVar: "PLUGIN_PLAN", |
|
|
}, |
|
|
}, |
|
|
cli.StringFlag{ |
|
|
cli.StringFlag{ |
|
|
Name: "terraform.remote", |
|
|
Name: "remote", |
|
|
Usage: "contains the configuration for the Terraform remote state tracking", |
|
|
Usage: "contains the configuration for the Terraform remote state tracking", |
|
|
EnvVar: "PLUGIN_REMOTE", |
|
|
EnvVar: "PLUGIN_REMOTE", |
|
|
}, |
|
|
}, |
|
|
cli.StringFlag{ |
|
|
cli.StringFlag{ |
|
|
Name: "terraform.vars", |
|
|
Name: "vars", |
|
|
Usage: "a map of variables to pass to the Terraform `plan` and `apply` commands. Each value is passed as a `<key>=<value>` option", |
|
|
Usage: "a map of variables to pass to the Terraform `plan` and `apply` commands. Each value is passed as a `<key>=<value>` option", |
|
|
EnvVar: "PLUGIN_VARS", |
|
|
EnvVar: "PLUGIN_VARS", |
|
|
}, |
|
|
}, |
|
|
cli.StringFlag{ |
|
|
cli.StringFlag{ |
|
|
Name: "terraform.secrets", |
|
|
Name: "secrets", |
|
|
Usage: "a map of secrets to pass to the Terraform `plan` and `apply` commands. Each value is passed as a `<key>=<ENV>` option", |
|
|
Usage: "a map of secrets to pass to the Terraform `plan` and `apply` commands. Each value is passed as a `<key>=<ENV>` option", |
|
|
EnvVar: "PLUGIN_SECRETS", |
|
|
EnvVar: "PLUGIN_SECRETS", |
|
|
}, |
|
|
}, |
|
|
cli.StringFlag{ |
|
|
cli.StringFlag{ |
|
|
Name: "terraform.ca_cert", |
|
|
Name: "ca_cert", |
|
|
Usage: "ca cert to add to your environment to allow terraform to use internal/private resources", |
|
|
Usage: "ca cert to add to your environment to allow terraform to use internal/private resources", |
|
|
EnvVar: "PLUGIN_CA_CERT", |
|
|
EnvVar: "PLUGIN_CA_CERT", |
|
|
}, |
|
|
}, |
|
|
cli.BoolFlag{ |
|
|
cli.BoolFlag{ |
|
|
Name: "terraform.sensitive", |
|
|
Name: "sensitive", |
|
|
Usage: "whether or not to suppress terraform commands to stdout", |
|
|
Usage: "whether or not to suppress terraform commands to stdout", |
|
|
EnvVar: "PLUGIN_SENSITIVE", |
|
|
EnvVar: "PLUGIN_SENSITIVE", |
|
|
}, |
|
|
}, |
|
|
cli.StringFlag{ |
|
|
cli.StringFlag{ |
|
|
Name: "terraform.role_arn_to_assume", |
|
|
Name: "role_arn_to_assume", |
|
|
Usage: "A role to assume before running the terraform commands", |
|
|
Usage: "A role to assume before running the terraform commands", |
|
|
EnvVar: "PLUGIN_ROLE_ARN_TO_ASSUME", |
|
|
EnvVar: "PLUGIN_ROLE_ARN_TO_ASSUME", |
|
|
}, |
|
|
}, |
|
|
cli.StringFlag{ |
|
|
cli.StringFlag{ |
|
|
Name: "terraform.root_dir", |
|
|
Name: "root_dir", |
|
|
Usage: "The root directory where the terraform files live. When unset, the top level directory will be assumed", |
|
|
Usage: "The root directory where the terraform files live. When unset, the top level directory will be assumed", |
|
|
EnvVar: "PLUGIN_ROOT_DIR", |
|
|
EnvVar: "PLUGIN_ROOT_DIR", |
|
|
}, |
|
|
}, |
|
|
cli.IntFlag{ |
|
|
cli.IntFlag{ |
|
|
Name: "terraform.parallelism", |
|
|
Name: "parallelism", |
|
|
Usage: "The number of concurrent operations as Terraform walks its graph", |
|
|
Usage: "The number of concurrent operations as Terraform walks its graph", |
|
|
EnvVar: "PLUGIN_PARALLELISM", |
|
|
EnvVar: "PLUGIN_PARALLELISM", |
|
|
}, |
|
|
}, |
|
@ -93,14 +93,14 @@ func run(c *cli.Context) error { |
|
|
json.Unmarshal([]byte(c.String("terraform.remote")), &remote) |
|
|
json.Unmarshal([]byte(c.String("terraform.remote")), &remote) |
|
|
|
|
|
|
|
|
var vars map[string]string |
|
|
var vars map[string]string |
|
|
if c.String("terraform.vars") != "" { |
|
|
if c.String("vars") != "" { |
|
|
if err := json.Unmarshal([]byte(c.String("terraform.vars")), &vars); err != nil { |
|
|
if err := json.Unmarshal([]byte(c.String("vars")), &vars); err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
var secrets map[string]string |
|
|
var secrets map[string]string |
|
|
if c.String("terraform.secrets") != "" { |
|
|
if c.String("secrets") != "" { |
|
|
if err := json.Unmarshal([]byte(c.String("terraform.secrets")), &secrets); err != nil { |
|
|
if err := json.Unmarshal([]byte(c.String("secrets")), &secrets); err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -108,14 +108,14 @@ func run(c *cli.Context) error { |
|
|
plugin := Plugin{ |
|
|
plugin := Plugin{ |
|
|
Config: Config{ |
|
|
Config: Config{ |
|
|
Remote: remote, |
|
|
Remote: remote, |
|
|
Plan: c.Bool("terraform.plan"), |
|
|
Plan: c.Bool("plan"), |
|
|
Vars: vars, |
|
|
Vars: vars, |
|
|
Secrets: secrets, |
|
|
Secrets: secrets, |
|
|
Cacert: c.String("terraform.ca_cert"), |
|
|
Cacert: c.String("ca_cert"), |
|
|
Sensitive: c.Bool("terraform.sensitive"), |
|
|
Sensitive: c.Bool("sensitive"), |
|
|
RoleARN: c.String("terraform.role_arn_to_assume"), |
|
|
RoleARN: c.String("role_arn_to_assume"), |
|
|
RootDir: c.String("terraform.root_dir"), |
|
|
RootDir: c.String("root_dir"), |
|
|
Parallelism: c.Int("terraform.parallelism"), |
|
|
Parallelism: c.Int("parallelism"), |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|