Skip to content

Commit ded205f

Browse files
authored
Update providers and hooks sections (#1188)
* updates * updates * updates * updates * updates * updates
1 parent a1b7804 commit ded205f

29 files changed

+231
-89
lines changed

examples/quick-start-advanced/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG GEODESIC_OS=debian
66
# https://atmos.tools/
77
# https://github.com/cloudposse/atmos
88
# https://github.com/cloudposse/atmos/releases
9-
ARG ATMOS_VERSION=1.169.0
9+
ARG ATMOS_VERSION=1.170.0
1010

1111
# Terraform: https://github.com/hashicorp/terraform/releases
1212
ARG TF_VERSION=1.5.7

go.mod

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.sum

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/exec/atmos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ExecuteAtmosCmd() error {
4141

4242
// Get a map of stacks and components in the stacks
4343
// Don't process `Go` templates and YAML functions in Atmos stack manifests since we just need to display the stack and component names in the TUI
44-
stacksMap, err := ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, true, true, false, nil)
44+
stacksMap, err := ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, false, false, false, nil)
4545
if err != nil {
4646
return err
4747
}

internal/exec/stack_processor_utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,8 @@ func ProcessStackConfig(
10731073
baseComponentVars = baseComponentConfig.BaseComponentVars
10741074
baseComponentSettings = baseComponentConfig.BaseComponentSettings
10751075
baseComponentEnv = baseComponentConfig.BaseComponentEnv
1076+
baseComponentProviders = baseComponentConfig.BaseComponentProviders
1077+
baseComponentHooks = baseComponentConfig.BaseComponentHooks
10761078
baseComponentTerraformCommand = baseComponentConfig.BaseComponentCommand
10771079
baseComponentBackendType = baseComponentConfig.BaseComponentBackendType
10781080
baseComponentBackendSection = baseComponentConfig.BaseComponentBackendSection

internal/exec/stack_processor_utils_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package exec
22

33
import (
4+
"path/filepath"
45
"sort"
56
"testing"
67

@@ -441,3 +442,66 @@ func TestProcessYAMLConfigFileInvalidHelmfileOverridesSection(t *testing.T) {
441442

442443
assert.Error(t, err)
443444
}
445+
446+
func TestProcessStackConfigProviderSection(t *testing.T) {
447+
basePath := filepath.Join("..", "..", "tests", "fixtures", "scenarios", "atmos-providers-section")
448+
stacksBasePath := filepath.Join(basePath, "stacks")
449+
manifest := filepath.Join(stacksBasePath, "deploy", "nonprod.yaml")
450+
451+
atmosConfig := schema.AtmosConfiguration{
452+
Logs: schema.Logs{
453+
Level: "Info",
454+
},
455+
}
456+
457+
deepMergedStackConfig, importsConfig, _, _, _, _, _, err := ProcessYAMLConfigFile(
458+
atmosConfig,
459+
stacksBasePath,
460+
manifest,
461+
map[string]map[string]any{},
462+
nil,
463+
false,
464+
false,
465+
true,
466+
false,
467+
nil,
468+
nil,
469+
nil,
470+
nil,
471+
"",
472+
)
473+
assert.Nil(t, err)
474+
475+
config, err := ProcessStackConfig(
476+
atmosConfig,
477+
stacksBasePath,
478+
filepath.Join(basePath, "components", "terraform"),
479+
filepath.Join(basePath, "components", "helmfile"),
480+
"nonprod",
481+
deepMergedStackConfig,
482+
false,
483+
false,
484+
"",
485+
map[string]map[string][]string{},
486+
importsConfig,
487+
true,
488+
)
489+
assert.Nil(t, err)
490+
491+
providers, err := u.EvaluateYqExpression(&atmosConfig, config, ".components.terraform.component-2.providers")
492+
assert.Nil(t, err)
493+
494+
awsProvider, err := u.EvaluateYqExpression(&atmosConfig, providers, ".aws")
495+
assert.Nil(t, err)
496+
497+
contextProvider, err := u.EvaluateYqExpression(&atmosConfig, providers, ".context")
498+
assert.Nil(t, err)
499+
500+
awsProviderRoleArn, err := u.EvaluateYqExpression(&atmosConfig, awsProvider, ".assume_role.role_arn")
501+
assert.Nil(t, err)
502+
assert.Equal(t, "Derived component IAM Role ARN", awsProviderRoleArn)
503+
504+
contextProviderPropertyOrder0, err := u.EvaluateYqExpression(&atmosConfig, contextProvider, ".property_order[0]")
505+
assert.Nil(t, err)
506+
assert.Equal(t, "product", contextProviderPropertyOrder0)
507+
}

pkg/config/load.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func mergeDefaultImports(dirPath string, dst *viper.Viper) error {
252252
searchDir := filepath.Join(filepath.FromSlash(dirPath), filepath.Join("atmos.d", "**", "*"))
253253
foundPaths1, err := SearchAtmosConfig(searchDir)
254254
if err != nil {
255-
log.Debug("Failed to find atmos config file", "path", searchDir, "error", err)
255+
log.Debug("Atmos configuration not found", "path", searchDir, "error", err)
256256
}
257257
if len(foundPaths1) > 0 {
258258
atmosFoundFilePaths = append(atmosFoundFilePaths, foundPaths1...)
@@ -261,7 +261,7 @@ func mergeDefaultImports(dirPath string, dst *viper.Viper) error {
261261
searchDir = filepath.Join(filepath.FromSlash(dirPath), filepath.Join(".atmos.d", "**", "*"))
262262
foundPaths2, err := SearchAtmosConfig(searchDir)
263263
if err != nil {
264-
log.Debug("Failed to find atmos config file", "path", searchDir, "error", err)
264+
log.Debug("Atmos configuration not found", "path", searchDir, "error", err)
265265
}
266266
if len(foundPaths2) > 0 {
267267
atmosFoundFilePaths = append(atmosFoundFilePaths, foundPaths2...)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
base_path: "./"
2+
3+
components:
4+
terraform:
5+
base_path: "../../components/terraform"
6+
apply_auto_approve: false
7+
deploy_run_init: true
8+
init_run_reconfigure: true
9+
auto_generate_backend_file: false
10+
11+
stacks:
12+
base_path: "stacks"
13+
included_paths:
14+
- "deploy/**/*"
15+
excluded_paths:
16+
- "**/_defaults.yaml"
17+
name_template: "{{ .vars.stage }}"
18+
19+
logs:
20+
file: "/dev/stderr"
21+
level: Info
22+
23+
# `Go` templates in Atmos manifests
24+
# https://atmos.tools/core-concepts/stacks/templates
25+
# https://pkg.go.dev/text/template
26+
templates:
27+
settings:
28+
enabled: true
29+
evaluations: 1
30+
# https://masterminds.github.io/sprig
31+
sprig:
32+
enabled: true
33+
# https://docs.gomplate.ca
34+
gomplate:
35+
enabled: true
36+
timeout: 10
37+
# https://docs.gomplate.ca/datasources
38+
datasources: {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# yaml-language-server: $schema=https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json
2+
3+
vars:
4+
stage: nonprod
5+
6+
components:
7+
terraform:
8+
component-1:
9+
metadata:
10+
type: abstract
11+
vars:
12+
foo: component-1-foo
13+
bar: component-1-bar
14+
baz: component-1-baz
15+
providers:
16+
aws:
17+
assume_role:
18+
role_arn: "Base component IAM Role ARN"
19+
context:
20+
enabled: true
21+
delimiter: "-"
22+
property_order:
23+
- product
24+
- region
25+
- environment
26+
- name
27+
28+
component-2:
29+
metadata:
30+
component: mock
31+
inherits:
32+
- component-1
33+
vars:
34+
foo: component-2-foo
35+
providers:
36+
aws:
37+
assume_role:
38+
role_arn: "Derived component IAM Role ARN"

tests/fixtures/scenarios/stack-templates-3/atmos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ templates:
3535
enabled: true
3636
timeout: 10
3737
# https://docs.gomplate.ca/datasources
38-
datasources: { }
38+
datasources: {}

tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/snapshots/TestCLICommands_Valid_Log_Level_in_Environment_Variable.stderr.golden

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/snapshots/TestCLICommands_Valid_log_file_in_env_should_be_priortized_over_config.stdout.golden

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)