Skip to content
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

#2347 - add --terragrunt-global-cache support to run_cmd #2348

Merged

Conversation

tjstansell
Copy link
Contributor

@tjstansell tjstansell commented Nov 1, 2022

Description

Fixes #2347 and #2184.

This adds a new --terragrunt-global-cache option to run_cmd that caches the command globally instead of relative to the directory it is run from.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added --terragrunt-global-cache option for run_cmd to cache output globally instead of per directory.

Migration Guide

@@ -685,6 +685,12 @@ carrot
* Output contains multiple times `uuid3`, +1 more output comparing to `uuid1` and `uuid2` - because `uuid3` is declared in locals and inputs which add one more evaluation
* Output contains only once `uuid4` since it is declared only once in `inputs`, `inputs` is not evaluated twice

You can modify this caching behavior to ignore the existing directory if you know the command you are running is not dependent on the current directory path. To do so, use the special `--terragrunt-global-cache` argument which must be passed as one of the first arguments to `run_cmd()` (and can be combined with `--terragrunt-quiet` in any order):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Could you let me know how you tested this behavior? Looking at the code above it doesn't look like they can be combined in any order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what the for loop and switch statement does. It consumes the arguments that match in the switch statement. It doesn't matter which order they occur, they just have to be the first entries.

I tested manually to check the performance difference as shown in the linked issue. We could add additional tests here to verify both can be specified in any order if that helps.

@denis256 denis256 merged commit c3870aa into gruntwork-io:master Dec 2, 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.

ability to cache run_cmd ignoring current directory
3 participants