-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.go
38 lines (33 loc) · 1.23 KB
/
command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package renderjson
import (
"github.com/terraform-modules-krish/terragrunt/options"
"github.com/terraform-modules-krish/terragrunt/pkg/cli"
)
const (
CommandName = "render-json"
FlagNameTerragruntJSONOut = "terragrunt-json-out"
FlagNameWithMetadata = "with-metadata"
)
func NewFlags(opts *options.TerragruntOptions) cli.Flags {
return cli.Flags{
&cli.GenericFlag[string]{
Name: FlagNameTerragruntJSONOut,
Destination: &opts.JSONOut,
Usage: "The file path that terragrunt should use when rendering the terragrunt.hcl config as json.",
},
&cli.BoolFlag{
Name: FlagNameWithMetadata,
Destination: &opts.RenderJsonWithMetadata,
Usage: "Add metadata to the rendered JSON file.",
},
}
}
func NewCommand(opts *options.TerragruntOptions) *cli.Command {
return &cli.Command{
Name: CommandName,
Usage: "Render the final terragrunt config, with all variables, includes, and functions resolved, as json.",
Description: "This is useful for enforcing policies using static analysis tools like Open Policy Agent, or for debugging your terragrunt config.",
Flags: NewFlags(opts).Sort(),
Action: func(ctx *cli.Context) error { return Run(opts.OptionsFromContext(ctx)) },
}
}