Skip to content

git_functions: propagate environment variables #2086

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 1 commit into from
Apr 29, 2022

Conversation

lexton
Copy link
Contributor

@lexton lexton commented Apr 27, 2022

Proposed solution for: #2085

Copy link
Member

@denis256 denis256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
However failed multiple tests related to git invocation

TestGetRepoRoot
TestGetPathFromRepoRoot
TestGetPathToRepoRoot
TestShowWarningWithDependentModulesBeforeDestroy
time=2022-04-27T14:31:50Z level=debug msg=Running command: terraform --version prefix=[/home/circleci/project/test/fixture-include-multiple/expose/vpc] 
Releasing state lock. This may take a few moments...
=== CONT  TestGetRepoRoot
    integration_test.go:2791: 
        	Error Trace:	integration_test.go:2791
        	Error:      	Received unexpected error:
        	            	unexpected end of JSON input
        	Test:       	TestGetRepoRoot
--- FAIL: TestGetRepoRoot (152.85s)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
...
Initializing provider plugins...
- Finding latest version of hashicorp/random...
--- PASS: TestAWSGetCallerIdentityFunctions (157.69s)
- Installing hashicorp/random v3.1.3...
=== CONT  TestGetPathFromRepoRoot
    integration_test.go:2824: 
        	Error Trace:	integration_test.go:2824
        	Error:      	Received unexpected error:
        	            	unexpected end of JSON input
        	Test:       	TestGetPathFromRepoRoot
--- FAIL: TestGetPathFromRepoRoot (158.33s)
...
You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.
=== CONT  TestGetPathToRepoRoot
    integration_test.go:2856: 
        	Error Trace:	integration_test.go:2856
        	Error:      	Received unexpected error:
        	            	unexpected end of JSON input
        	Test:       	TestGetPathToRepoRoot
--- FAIL: TestGetPathToRepoRoot (159.54s)
--- PASS: TestPreventDestroyOverride (159.63s)
...
=== RUN   TestShowWarningWithDependentModulesBeforeDestroy
    integration_test.go:3726: Copying fixture-destroy-warning to /tmp/terragrunt-test165306862
runTerragruntVersionCommand after split
[terragrunt run-all init --terragrunt-non-interactive --terragrunt-working-dir /tmp/terragrunt-test165306862/fixture-destroy-warning]
runTerragruntVersionCommand after split
[terragrunt run-all apply --terragrunt-non-interactive --terragrunt-working-dir /tmp/terragrunt-test165306862/fixture-destroy-warning]
runTerragruntVersionCommand after split
[terragrunt destroy --terragrunt-non-interactive --terragrunt-working-dir /tmp/terragrunt-test165306862/fixture-destroy-warning/vpc]
    integration_test.go:4340: 
        	Error Trace:	integration_test.go:4340
        	Error:      	Not equal: 
        	            	expected: 1
        	            	actual  : 0
        	Test:       	TestShowWarningWithDependentModulesBeforeDestroy
--- FAIL: TestShowWarningWithDependentModulesBeforeDestroy (6.73s)

I think it is related to setting opts.Writer = &stdout on options.TerragruntOptions which make git output to be passed to application output...

If issues occur only because of passed env variables, code can be extended to copy env variables:

	opts, _ := options.NewTerragruntOptions(path)
	opts.Env = terragruntOptions.Env

@lexton lexton changed the title git_functions: don't re-create the existing options.terragruntOptions git_functions: propagate environment variables Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants