-
-
Notifications
You must be signed in to change notification settings - Fork 91
/
describe_component.go
53 lines (43 loc) · 1.2 KB
/
describe_component.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package exec
import (
"fmt"
c "github.com/cloudposse/atmos/pkg/config"
g "github.com/cloudposse/atmos/pkg/globals"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
// ExecuteDescribeComponent executes `describe component` command
func ExecuteDescribeComponent(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("invalid arguments. The command requires one argument `component`")
}
flags := cmd.Flags()
stack, err := flags.GetString("stack")
if err != nil {
return err
}
component := args[0]
var configAndStacksInfo c.ConfigAndStacksInfo
configAndStacksInfo.ComponentFromArg = component
configAndStacksInfo.Stack = stack
configAndStacksInfo.ComponentType = "terraform"
configAndStacksInfo, err = ProcessStacks(configAndStacksInfo, true)
if err != nil {
configAndStacksInfo.ComponentType = "helmfile"
configAndStacksInfo, err = ProcessStacks(configAndStacksInfo, true)
if err != nil {
return err
}
}
if g.LogVerbose {
fmt.Println()
color.Cyan("Component config:\n\n")
}
err = u.PrintAsYAML(configAndStacksInfo.ComponentSection)
if err != nil {
return err
}
return nil
}