-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathcli.go
More file actions
46 lines (39 loc) · 1.51 KB
/
Copy pathcli.go
File metadata and controls
46 lines (39 loc) · 1.51 KB
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
39
40
41
42
43
44
45
46
// Package graph implements the terragrunt dag graph command which generates a visual
// representation of the Terragrunt dependency graph in DOT language format.
//
// Alias for 'list --format=dot --dag --dependencies --external'.
package graph
import (
"context"
"github.com/gruntwork-io/terragrunt/internal/cli/commands/list"
"github.com/gruntwork-io/terragrunt/internal/cli/flags/shared"
"github.com/gruntwork-io/terragrunt/internal/clihelper"
"github.com/gruntwork-io/terragrunt/pkg/log"
"github.com/gruntwork-io/terragrunt/pkg/options"
)
const (
CommandName = "graph"
)
func NewCommand(l log.Logger, opts *options.TerragruntOptions) *clihelper.Command {
sharedFlags := shared.NewQueueFlags(opts, nil)
sharedFlags = append(sharedFlags, shared.NewBackendFlags(opts, nil)...)
sharedFlags = append(sharedFlags, shared.NewFeatureFlags(opts, nil)...)
sharedFlags = append(sharedFlags, shared.NewFilterFlags(l, opts)...)
return &clihelper.Command{
Name: CommandName,
Usage: "Graph the Directed Acyclic Graph (DAG) in DOT language." +
" Alias for 'list --format=dot --dag --dependencies --external'.",
UsageText: "terragrunt dag graph",
Flags: sharedFlags,
Action: func(ctx context.Context, _ *clihelper.Context) error {
return Run(ctx, l, opts)
},
}
}
func Run(ctx context.Context, l log.Logger, opts *options.TerragruntOptions) error {
listOpts := list.NewOptions(opts)
listOpts.Format = list.FormatDot
listOpts.Mode = list.ModeDAG
listOpts.Dependencies = true
return list.Run(ctx, l, listOpts)
}