terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

`sops_decrypt_file()`: resolve path argument relative to `terragrunt.hcl`

Open sybereal opened this issue 1 year ago • 3 comments

Description

Update path resolution logic in sops_decrypt_file() to resolve relative path arguments relative to the file containing the call to sops_decrypt_file(), rather than relative to the working directory of the Terragrunt process.

This change should be invisible for the common case of running Terragrunt directly inside the directory containing terragrunt.hcl. However, it enables intuitive use of terragrunt run-all with sops_decrypt_file(), ensuring configurations behave the same, no matter if they're evaluated directly or under run-all.

An additional test case for sops_decrypt_file() was added that validates its behavior in combination with run-all.

TODOs

Read the Gruntwork contribution guidelines.

  • [x] Update the docs.
  • [x] Run the relevant tests successfully, including pre-commit checks.
  • [x] Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Updated sops_decrypt_file() path resolution to be relative to terragrunt.hcl instead of Terragrunt's working directory.

Migration Guide

If you were relying on the behavior of terragrunt run-all on a set of modules using sops_decrypt_file() using a file in the current working directory, such as a shared secret, you can wrap the argument to sops_decrypt_file() in a call to find_in_parent_folders(), as shown in the documentation for sops_decrypt_file().

sybereal avatar Oct 11 '23 14:10 sybereal

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud

sonarqubecloud[bot] avatar May 23 '24 09:05 sonarqubecloud[bot]

INFO [runner] linters took 44.194334557s with stages: goanalysis_metalinter: 44.168422498s 
test/integration_test.go:4946:36: S1030: should use stdout.Bytes() instead of []byte(stdout.String()) (gosimple)
        require.NoError(t, json.Unmarshal([]byte(stdout.String()), &outputs))

denis256 avatar Jun 20 '24 14:06 denis256

My bad. I just copied the existing test case that was there at the time I made the change without thinking. Should be fine now, I hope.

sybereal avatar Jun 20 '24 15:06 sybereal

Hey @sybereal

I've run the tests for this functionality, and they still aren't passing. Are you able to run the tests locally?

This PR has been open for a long time, and while this functionality seems very convenient, there are workarounds via functions like get_terragrunt_dir.

We can leave the PR open a little bit longer, but if you could ensure that tests are passing before re-requesting review from me, that would be great.

yhakbar avatar Aug 01 '24 16:08 yhakbar

Could you tell me which tests are failing that aren't failing on master? I can't see the CircleCI logs even after creating an account, and locally I can't run the full suite because I do not have an AWS account set up. I specifically ran only the sops tests with go test ./... -run '.*Sops.*', and those were fine, but ofc that way I can't tell if my change broke anything else.

sybereal avatar Aug 01 '24 21:08 sybereal

Running the tests after rebase worked!

yhakbar avatar Aug 02 '24 11:08 yhakbar