-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Atlantis support. Add
atmos terraform generate varfiles
and `at…
…mos atlantis generate repo-config` CLI commands (#189) * Add custom integrations * Add custom integrations * Add custom integrations * Add custom integrations * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `terraform generate varfiles` command * Add `atlantis` commands * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Add `atlantis generate repo-config` command * Update README * Cleanup code * Cleanup code * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates * Updates
- Loading branch information
Showing
25 changed files
with
1,364 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// atlantisCmd executes Atlantis commands | ||
var atlantisCmd = &cobra.Command{ | ||
Use: "atlantis", | ||
Short: "Execute 'atlantis' commands", | ||
Long: `This command executes Atlantis integration commands`, | ||
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(atlantisCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// atlantisGenerateCmd generates various Atlantis configurations | ||
var atlantisGenerateCmd = &cobra.Command{ | ||
Use: "generate", | ||
Short: "Execute 'atlantis generate' commands", | ||
Long: "This command generates various Atlantis configurations", | ||
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: true}, | ||
} | ||
|
||
func init() { | ||
atlantisCmd.AddCommand(atlantisGenerateCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: true}, | ||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cmd | ||
|
||
import ( | ||
e "github.com/cloudposse/atmos/internal/exec" | ||
u "github.com/cloudposse/atmos/pkg/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// terraformGenerateVarfilesCmd generates varfiles for all terraform components in all stacks | ||
var terraformGenerateVarfilesCmd = &cobra.Command{ | ||
Use: "varfiles", | ||
Short: "Execute 'terraform generate varfiles' command", | ||
Long: `This command generates varfiles for all terraform components in all stacks`, | ||
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := e.ExecuteTerraformGenerateVarfilesCmd(cmd, args) | ||
if err != nil { | ||
u.PrintErrorToStdErrorAndExit(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
terraformGenerateVarfilesCmd.DisableFlagParsing = false | ||
|
||
terraformGenerateVarfilesCmd.PersistentFlags().String("file-template", "", | ||
"Varfile template (the file path, file name, and file extension).\n"+ | ||
"Supports absolute and relative paths.\n"+ | ||
"Supports context tokens: {namespace}, {tenant}, {environment}, {region}, {stage}, {component}, {component-path}.\n"+ | ||
"atmos terraform generate varfiles --file-template {component-path}/{environment}-{stage}.tfvars.json\n"+ | ||
"atmos terraform generate varfiles --file-template /configs/{tenant}/{environment}/{stage}/{component}.json\n"+ | ||
"atmos terraform generate varfiles --file-template /{tenant}/{stage}/{region}/{component}.yaml\n"+ | ||
"All subfolders in the path will be created automatically.", | ||
) | ||
|
||
terraformGenerateVarfilesCmd.PersistentFlags().String("stacks", "", | ||
"Only process the specified stacks (comma-separated values).\n"+ | ||
"atmos terraform generate varfiles --file-template <file_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 terraform generate varfiles --stacks orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2\n"+ | ||
"atmos terraform generate varfiles --stacks tenant1-ue2-staging,tenant1-ue2-prod\n"+ | ||
"atmos terraform generate varfiles --stacks orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod", | ||
) | ||
|
||
terraformGenerateVarfilesCmd.PersistentFlags().String("components", "", | ||
"Only process the specified components (comma-separated values).\n"+ | ||
"atmos terraform generate varfiles --file-template <file_template> --components <component1>,<component2>", | ||
) | ||
|
||
terraformGenerateVarfilesCmd.PersistentFlags().String("format", "json", "Output format.\n"+ | ||
"atmos terraform generate varfiles --file-template <file_template> --format=json/yaml ('json' is default)") | ||
|
||
err := terraformGenerateVarfilesCmd.MarkPersistentFlagRequired("file-template") | ||
if err != nil { | ||
u.PrintErrorToStdErrorAndExit(err) | ||
} | ||
|
||
terraformGenerateCmd.AddCommand(terraformGenerateVarfilesCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ vars: | |
|
||
components: | ||
terraform: | ||
vpc: | ||
infra/vpc: | ||
vars: | ||
availability_zones: | ||
- us-east-1a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ vars: | |
|
||
components: | ||
terraform: | ||
vpc: | ||
infra/vpc: | ||
vars: | ||
availability_zones: | ||
- us-east-2a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.