-
-
Notifications
You must be signed in to change notification settings - Fork 140
Update atmos.yaml config for Terraform/OpenTofu to enable passing the generated varfile to tofu init
#1163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Update atmos.yaml config for Terraform/OpenTofu to enable passing the generated varfile to tofu init
#1163
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e3bd6b7
updates
aknysh f3442b1
updates
aknysh a3fa15f
updates
aknysh aa01305
updates
aknysh c1caa04
updates
aknysh 560b313
Merge remote-tracking branch 'origin/main' into update-terraform-init
aknysh db03a25
updates
aknysh de41c73
updates
aknysh 525ad6c
updates
aknysh 77b9ac8
updates
aknysh b067d5a
updates
aknysh 2f1c103
update `atmos.Component` template function
aknysh d4d71c6
updates
aknysh 44d9826
updates
aknysh 27dcc97
updates
aknysh 8d403c0
updates
aknysh 72e6b1b
updates
aknysh 3ab3adc
add unit tests
aknysh fb601f2
add unit tests
aknysh 4402a68
add unit tests
aknysh c7aec28
add unit tests
aknysh 7fb50fd
add unit tests
aknysh 38c5262
add unit tests
aknysh ae71bc1
Apply suggestions from code review
aknysh 0fc939e
[autofix.ci] apply automated fixes
autofix-ci[bot] 32be813
updates
aknysh 73494fb
Merge remote-tracking branch 'origin/update-terraform-init' into upda…
aknysh 67861ee
Update internal/exec/template_funcs_component.go
aknysh e0c45fc
updates
aknysh a384a0f
updates
aknysh 123dfbb
updates
aknysh 1789f14
Merge remote-tracking branch 'origin/main' into update-terraform-init
aknysh 252b969
updates
aknysh 9eeffef
updates
aknysh d2e708a
updates
aknysh 783717f
updates
aknysh 842ef07
updates
aknysh 8c12e55
Merge remote-tracking branch 'origin/main' into update-terraform-init
aknysh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,74 @@ | ||
| package exec | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| log "github.com/charmbracelet/log" | ||
| "github.com/stretchr/testify/assert" | ||
|
|
||
| cfg "github.com/cloudposse/atmos/pkg/config" | ||
| "github.com/cloudposse/atmos/pkg/schema" | ||
| u "github.com/cloudposse/atmos/pkg/utils" | ||
| ) | ||
|
|
||
| func TestComponentFunc(t *testing.T) { | ||
| log.SetLevel(log.DebugLevel) | ||
| log.SetOutput(os.Stdout) | ||
|
|
||
| // Capture the starting working directory | ||
| startingDir, err := os.Getwd() | ||
| if err != nil { | ||
| t.Fatalf("Failed to get the current working directory: %v", err) | ||
| } | ||
|
|
||
| defer func() { | ||
| // Delete the generated files and folders after the test | ||
| err := os.RemoveAll(filepath.Join("components", "terraform", "mock", ".terraform")) | ||
| assert.NoError(t, err) | ||
|
|
||
| err = os.RemoveAll(filepath.Join("components", "terraform", "mock", "terraform.tfstate.d")) | ||
| assert.NoError(t, err) | ||
|
|
||
| // Change back to the original working directory after the test | ||
| if err = os.Chdir(startingDir); err != nil { | ||
| t.Fatalf("Failed to change back to the starting directory: %v", err) | ||
| } | ||
| }() | ||
|
|
||
| // Define the working directory | ||
| workDir := "../../tests/fixtures/scenarios/stack-templates-3" | ||
| if err := os.Chdir(workDir); err != nil { | ||
| t.Fatalf("Failed to change directory to %q: %v", workDir, err) | ||
| } | ||
|
|
||
| info := schema.ConfigAndStacksInfo{ | ||
| StackFromArg: "", | ||
| Stack: "nonprod", | ||
| StackFile: "", | ||
| ComponentType: "terraform", | ||
| ComponentFromArg: "component-1", | ||
| SubCommand: "deploy", | ||
| ProcessTemplates: true, | ||
| ProcessFunctions: true, | ||
| } | ||
|
|
||
| err = ExecuteTerraform(info) | ||
| if err != nil { | ||
| t.Fatalf("Failed to execute 'ExecuteTerraform': %v", err) | ||
| } | ||
|
|
||
| atmosConfig, err := cfg.InitCliConfig(info, true) | ||
| assert.NoError(t, err) | ||
|
|
||
| d, err := componentFunc(&atmosConfig, &info, "component-2", "nonprod") | ||
| assert.NoError(t, err) | ||
|
|
||
| y, err := u.ConvertToYAML(d) | ||
| assert.NoError(t, err) | ||
|
|
||
| assert.Contains(t, y, "foo: component-1-a") | ||
| assert.Contains(t, y, "bar: component-1-b") | ||
| assert.Contains(t, y, "baz: component-1-b--component-1-c") | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.