Mustafa Babil
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
15 additions and
1 deletions
-
DOCS.md
-
plugin.go
-
plugin_test.go
|
|
@ -194,6 +194,7 @@ pipeline: |
|
|
|
+ write: false |
|
|
|
+ diff: true |
|
|
|
+ check: true |
|
|
|
+ recursive: true |
|
|
|
``` |
|
|
|
|
|
|
|
You may want to run some executions in parallel without having racing condition problems with the .terraform dir and |
|
|
@ -244,6 +245,9 @@ fmt_options.diff |
|
|
|
fmt_options.check |
|
|
|
: Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise. Default `false`. |
|
|
|
|
|
|
|
fmt_options.recursive |
|
|
|
: Process files in subdirectories as well. Default `false`. |
|
|
|
|
|
|
|
vars |
|
|
|
: a map of variables to pass to the Terraform `plan` and `apply` commands. |
|
|
|
Each value is passed as a `-var <key>=<value>` option. |
|
|
|
|
|
@ -57,6 +57,7 @@ type ( |
|
|
|
Write *bool `json:"write"` |
|
|
|
Diff *bool `json:"diff"` |
|
|
|
Check *bool `json:"check"` |
|
|
|
Recursive *bool `json:"recursive"` |
|
|
|
} |
|
|
|
|
|
|
|
// Plugin represents the plugin instance to be executed
|
|
|
@ -354,6 +355,9 @@ func tfFmt(config Config) *exec.Cmd { |
|
|
|
if config.FmtOptions.Check != nil { |
|
|
|
args = append(args, fmt.Sprintf("-check=%t", *config.FmtOptions.Check)) |
|
|
|
} |
|
|
|
if config.FmtOptions.Recursive != nil { |
|
|
|
args = append(args, fmt.Sprintf("-recursive=%t", *config.FmtOptions.Recursive)) |
|
|
|
} |
|
|
|
return exec.Command( |
|
|
|
"terraform", |
|
|
|
args..., |
|
|
|
|
|
@ -243,6 +243,11 @@ func TestPlugin(t *testing.T) { |
|
|
|
args{config: Config{FmtOptions: FmtOptions{Check: &affirmative}}}, |
|
|
|
exec.Command("terraform", "fmt", "-check=true"), |
|
|
|
}, |
|
|
|
{ |
|
|
|
"with recursive", |
|
|
|
args{config: Config{FmtOptions: FmtOptions{Recursive: &affirmative}}}, |
|
|
|
exec.Command("terraform", "fmt", "-recursive=true"), |
|
|
|
}, |
|
|
|
{ |
|
|
|
"with combination", |
|
|
|
args{config: Config{FmtOptions: FmtOptions{ |
|
|
@ -250,8 +255,9 @@ func TestPlugin(t *testing.T) { |
|
|
|
Write: &negative, |
|
|
|
Diff: &affirmative, |
|
|
|
Check: &affirmative, |
|
|
|
Recursive: &affirmative, |
|
|
|
}}}, |
|
|
|
exec.Command("terraform", "fmt", "-list=false", "-write=false", "-diff=true", "-check=true"), |
|
|
|
exec.Command("terraform", "fmt", "-list=false", "-write=false", "-diff=true", "-check=true", "-recursive=true"), |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|