forked from cloudposse/atmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
{attributes}
token in the `components.helmfile.cluster_name…
…_pattern` CLI config (cloudposse#150) * updates * Support `{attributes}'' token in the `components.helmfile.cluster_name_pattern` CLI config
- Loading branch information
Showing
6 changed files
with
116 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# CLI config is loaded from the following locations (from lowest to highest priority): | ||
# system dir (`/usr/local/etc/atmos` on Linux, `%LOCALAPPDATA%/atmos` on Windows) | ||
# home dir (~/.atmos) | ||
# current directory | ||
# ENV vars | ||
# Command-line arguments | ||
# | ||
# It supports POSIX-style Globs for file names/paths (double-star `**` is supported) | ||
# https://en.wikipedia.org/wiki/Glob_(programming) | ||
|
||
# Base path for components, stacks and workflows configurations. | ||
# Can also be set using `ATMOS_BASE_PATH` ENV var, or `--base-path` command-line argument. | ||
# Supports both absolute and relative paths. | ||
# If not provided or is an empty string, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` | ||
# are independent settings (supporting both absolute and relative paths). | ||
# If `base_path` is provided, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` | ||
# are considered paths relative to `base_path`. | ||
base_path: "../../examples/complete" | ||
|
||
components: | ||
terraform: | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_BASE_PATH` ENV var, or `--terraform-dir` command-line argument | ||
# Supports both absolute and relative paths | ||
base_path: "components/terraform" | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE` ENV var | ||
apply_auto_approve: false | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT` ENV var, or `--deploy-run-init` command-line argument | ||
deploy_run_init: true | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE` ENV var, or `--init-run-reconfigure` command-line argument | ||
init_run_reconfigure: true | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE` ENV var, or `--auto-generate-backend-file` command-line argument | ||
auto_generate_backend_file: false | ||
helmfile: | ||
# Can also be set using `ATMOS_COMPONENTS_HELMFILE_BASE_PATH` ENV var, or `--helmfile-dir` command-line argument | ||
# Supports both absolute and relative paths | ||
base_path: "components/helmfile" | ||
# Can also be set using `ATMOS_COMPONENTS_HELMFILE_KUBECONFIG_PATH` ENV var | ||
kubeconfig_path: "/dev/shm" | ||
# Can also be set using `ATMOS_COMPONENTS_HELMFILE_HELM_AWS_PROFILE_PATTERN` ENV var | ||
helm_aws_profile_pattern: "{namespace}-{tenant}-gbl-{stage}-helm" | ||
# Can also be set using `ATMOS_COMPONENTS_HELMFILE_CLUSTER_NAME_PATTERN` ENV var | ||
cluster_name_pattern: "{namespace}-{tenant}-{environment}-{stage}-{attributes}-eks-cluster" | ||
|
||
stacks: | ||
# Can also be set using `ATMOS_STACKS_BASE_PATH` ENV var, or `--config-dir` and `--stacks-dir` command-line arguments | ||
# Supports both absolute and relative paths | ||
base_path: "stacks" | ||
# Can also be set using `ATMOS_STACKS_INCLUDED_PATHS` ENV var (comma-separated values string) | ||
included_paths: | ||
- "**/*" | ||
# Can also be set using `ATMOS_STACKS_EXCLUDED_PATHS` ENV var (comma-separated values string) | ||
excluded_paths: | ||
- "globals/**/*" | ||
- "catalog/**/*" | ||
- "**/*globals*" | ||
# Can also be set using `ATMOS_STACKS_NAME_PATTERN` ENV var | ||
name_pattern: "{tenant}-{environment}-{stage}" | ||
|
||
workflows: | ||
# Can also be set using `ATMOS_WORKFLOWS_BASE_PATH` ENV var, or `--workflows-dir` command-line arguments | ||
# Supports both absolute and relative paths | ||
base_path: "workflows" | ||
|
||
logs: | ||
verbose: false | ||
colors: true |
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,33 @@ | ||
package aws | ||
|
||
import ( | ||
"fmt" | ||
c "github.com/cloudposse/atmos/pkg/config" | ||
u "github.com/cloudposse/atmos/pkg/utils" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestClusterNamePattern(t *testing.T) { | ||
// InitConfig finds and processes `atmos.yaml` CLI config | ||
err := c.InitConfig() | ||
assert.Nil(t, err) | ||
|
||
// Define variables for a component in a stack | ||
componentVars := map[interface{}]interface{}{ | ||
"namespace": "eg", | ||
"tenant": "plat", | ||
"environment": "ue2", | ||
"stage": "dev", | ||
"attributes": []string{"blue"}, | ||
} | ||
|
||
// Build `Context` from the variables | ||
context := c.GetContextFromVars(componentVars) | ||
|
||
// Build EKS cluster name using the `components.helmfile.cluster_name_pattern` config from `atmos.yaml` | ||
// cluster_name_pattern: "{namespace}-{tenant}-{environment}-{stage}-{attributes}-eks-cluster" | ||
clusterName := c.ReplaceContextTokens(context, c.Config.Components.Helmfile.ClusterNamePattern) | ||
u.PrintInfo(fmt.Sprintf("Cluster name: %s", clusterName)) | ||
assert.Equal(t, "eg-plat-ue2-dev-blue-eks-cluster", clusterName) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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