-
-
Notifications
You must be signed in to change notification settings - Fork 91
/
help.go
65 lines (58 loc) · 3.97 KB
/
help.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
54
55
56
57
58
59
60
61
62
63
64
65
package exec
import (
"fmt"
u "github.com/cloudposse/atmos/pkg/utils"
)
// processHelp processes help commands
func processHelp(componentType string, command string) error {
if len(command) == 0 {
fmt.Println(fmt.Sprintf("'atmos' supports all native '%s' commands.", componentType))
fmt.Println(fmt.Sprintf("In addition, 'component' and 'stack' are required in order to generate variables for the component in the stack."))
u.PrintInfo(fmt.Sprintf("atmos %s <command> <component> -s <stack> [options]", componentType))
u.PrintInfo(fmt.Sprintf("atmos %s <command> <component> --stack <stack> [options]", componentType))
if componentType == "terraform" {
fmt.Println()
u.PrintInfo("Additions and differences from native terraform:")
fmt.Println(" - before executing other 'terraform' commands, 'atmos' calls 'terraform init'")
fmt.Println(" - 'atmos terraform deploy' command executes 'terraform plan' and then 'terraform apply'")
fmt.Println(" - 'atmos terraform deploy' command supports '--deploy-run-init=true/false' flag to enable/disable running 'terraform init' " +
"before executing the command")
fmt.Println(" - 'atmos terraform deploy' command sets '-auto-approve' flag before running 'terraform apply'")
fmt.Println(" - 'atmos terraform apply' and 'atmos terraform deploy' commands support '--from-plan' flag. If the flag is specified, the commands " +
"will use the previously generated 'planfile' instead of generating a new 'varfile'")
fmt.Println(" - 'atmos terraform clean' command deletes the '.terraform' folder, '.terraform.lock.hcl' lock file, " +
"and the previously generated 'planfile' and 'varfile' for the specified component and stack")
fmt.Println(" - 'atmos terraform workspace' command first calls 'terraform init -reconfigure', then 'terraform workspace select', " +
"and if the workspace was not created before, it then calls 'terraform workspace new'")
fmt.Println(" - 'atmos terraform import' command searches for 'region' in the variables for the specified component and stack, and if it finds it, " +
"sets 'AWS_REGION=<region>' ENV var before executing the command")
fmt.Println(" - 'atmos terraform generate backend' command generates the backend file for the component in the stack")
fmt.Println(" - 'atmos terraform generate varfile' command generates a varfile for the component in the stack")
fmt.Println(" - 'atmos terraform shell' command configures an environment for the component in the stack and starts a new shell allowing executing all native terraform commands")
}
if componentType == "helmfile" {
fmt.Println()
u.PrintInfo("Additions and differences from native helmfile:")
fmt.Println(" - 'atmos helmfile generate varfile' command generates a varfile for the component in the stack")
fmt.Println(" - 'atmos helmfile' commands support '[global options]' in the command-line argument '--global-options'. " +
"Usage: atmos helmfile <command> <component> -s <stack> [command options] [arguments...] --global-options=\"--no-color --namespace=test\"")
fmt.Println(" - before executing the 'helmfile' commands, 'atmos' calls 'aws eks update-kubeconfig' to read kubeconfig from the EKS cluster " +
"and use it to authenticate with the cluster")
}
err := ExecuteShellCommand(componentType, []string{"--help"}, "", nil, false)
if err != nil {
return err
}
} else {
fmt.Println(fmt.Sprintf("'atmos' supports native '%s %s' command with all the options, arguments and flags.", componentType, command))
fmt.Println(fmt.Sprintf("In addition, 'component' and 'stack' are required in order to generate variables for the component in the stack."))
u.PrintInfo(fmt.Sprintf("atmos %s %s <component> -s <stack> [options]", componentType, command))
u.PrintInfo(fmt.Sprintf("atmos %s %s <component> --stack <stack> [options]", componentType, command))
err := ExecuteShellCommand(componentType, []string{command, "--help"}, "", nil, false)
if err != nil {
return err
}
}
fmt.Println()
return nil
}