forked from cloudposse/atmos
/
atlantis_generate_repo_config.go
61 lines (51 loc) · 3.47 KB
/
atlantis_generate_repo_config.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
package cmd
import (
e "github.com/cloudposse/atmos/internal/exec"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/spf13/cobra"
)
// atlantisGenerateRepoConfigCmd generates repository configuration for Atlantis
var atlantisGenerateRepoConfigCmd = &cobra.Command{
Use: "repo-config",
Short: "Execute 'atlantis generate repo-config`",
Long: "This command generates repository configuration for Atlantis",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
err := e.ExecuteAtlantisGenerateRepoConfigCmd(cmd, args)
if err != nil {
u.PrintErrorToStdErrorAndExit(err)
}
},
}
func init() {
atlantisGenerateRepoConfigCmd.DisableFlagParsing = false
atlantisGenerateRepoConfigCmd.PersistentFlags().String("output-path", "", "atmos atlantis generate repo-config --output-path ./atmos.yaml --config-template config-1 --project-template project-1 --workflow-template workflow-1")
atlantisGenerateRepoConfigCmd.PersistentFlags().String("config-template", "", "atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1")
atlantisGenerateRepoConfigCmd.PersistentFlags().String("project-template", "", "atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1")
atlantisGenerateRepoConfigCmd.PersistentFlags().String("workflow-template", "", "atmos atlantis generate repo-config --config-template config-1 --project-template project-1 --workflow-template workflow-1")
atlantisGenerateRepoConfigCmd.PersistentFlags().String("stacks", "",
"Only generate config for the specified stacks (comma-separated values).\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --stacks <stack1>,<stack2>\n"+
"The filter can contain the names of the top-level stack config files and the logical stack names (derived from the context vars)\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --workflow-template <workflow_template> --stacks orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --workflow-template <workflow_template> --stacks tenant1-ue2-staging,tenant1-ue2-prod\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --workflow-template <workflow_template> --stacks orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod",
)
atlantisGenerateRepoConfigCmd.PersistentFlags().String("components", "",
"Only generate config for the specified components (comma-separated values).\n"+
"atmos atlantis generate repo-config --config-template <config_template> --project-template <project_template> --workflow-template <workflow_template> --components <component1>,<component2>",
)
err := atlantisGenerateRepoConfigCmd.MarkPersistentFlagRequired("config-template")
if err != nil {
u.PrintErrorToStdErrorAndExit(err)
}
err = atlantisGenerateRepoConfigCmd.MarkPersistentFlagRequired("project-template")
if err != nil {
u.PrintErrorToStdErrorAndExit(err)
}
err = atlantisGenerateRepoConfigCmd.MarkPersistentFlagRequired("workflow-template")
if err != nil {
u.PrintErrorToStdErrorAndExit(err)
}
atlantisGenerateCmd.AddCommand(atlantisGenerateRepoConfigCmd)
}