Skip to content

add repo path functions #1954

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 3 commits into from
Jan 13, 2022

Conversation

tbell83
Copy link
Contributor

@tbell83 tbell83 commented Dec 17, 2021

This PR adds two functions, get_path_to_repo_root() and get_path_from_repo_root(), loosely linked to #305

Tests:

terragrunt/test on  add-repo-path-functions via 🐹 v1.17
❯ go test -v -run TestGetPathToRepoRoot
=== RUN   TestGetPathToRepoRoot
=== PAUSE TestGetPathToRepoRoot
=== CONT  TestGetPathToRepoRoot
    integration_test.go:3467: Copying fixture-get-path-to-repo-root to /var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test1054949920
runTerragruntVersionCommand after split
[terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test1054949920/fixture-get-path-to-repo-root]
WARN[0000] 'apply-all' is deprecated. Running 'terragrunt run-all apply' instead. Please update your workflows to use 'terragrunt run-all apply', as 'apply-all' may be removed in the future!
INFO[0000] The stack at /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test1054949920/fixture-get-path-to-repo-root will be processed in the following order for command apply:
Group 1
- Module /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test1054949920/fixture-get-path-to-repo-root
  prefix=[/private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test1054949920/fixture-get-path-to-repo-root]

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Changes to Outputs:
  + path_to_root = "../../"

You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

path_to_root = "../../"
runTerragruntVersionCommand after split
[terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test1054949920/fixture-get-path-to-repo-root]
--- PASS: TestGetPathToRepoRoot (15.09s)
PASS
ok  	github.com/gruntwork-io/terragrunt/test	16.128s
terragrunt/test on  add-repo-path-functions via 🐹 v1.17 took 22s
❯ go test -v -run TestGetPathFromRepoRoot
=== RUN   TestGetPathFromRepoRoot
=== PAUSE TestGetPathFromRepoRoot
=== CONT  TestGetPathFromRepoRoot
    integration_test.go:3467: Copying fixture-get-path-from-repo-root to /var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test2705825776
runTerragruntVersionCommand after split
[terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test2705825776/fixture-get-path-from-repo-root]
WARN[0000] 'apply-all' is deprecated. Running 'terragrunt run-all apply' instead. Please update your workflows to use 'terragrunt run-all apply', as 'apply-all' may be removed in the future!
INFO[0000] The stack at /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test2705825776/fixture-get-path-from-repo-root will be processed in the following order for command apply:
Group 1
- Module /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test2705825776/fixture-get-path-from-repo-root
  prefix=[/private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test2705825776/fixture-get-path-from-repo-root]

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Changes to Outputs:
  + path_from_root = "terragrunt-test2705825776/fixture-get-path-from-repo-root"

You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

path_from_root = "terragrunt-test2705825776/fixture-get-path-from-repo-root"
runTerragruntVersionCommand after split
[terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir /private/var/folders/mg/dlfyyxbj4s32mwd8599bh3200000gq/T/terragrunt-test2705825776/fixture-get-path-from-repo-root]
--- PASS: TestGetPathFromRepoRoot (12.21s)
PASS
ok  	github.com/gruntwork-io/terragrunt/test	12.826s

Copy link
Contributor

@yorinasub17 yorinasub17 left a comment

Choose a reason for hiding this comment

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

Makes sense and LGTM! Thanks for your contribution! Just have one minor suggestion.

@tbell83
Copy link
Contributor Author

tbell83 commented Dec 18, 2021

Updated to address comments

@yorinasub17
Copy link
Contributor

Thanks for addressing the comments and apologies for the delay in getting to this. I've been buried with other tasks and only now getting back to terragrunt again.

The updates LGTM! I'll kick off a regression build and if it passes, we can merge this in.

Copy link
Contributor

@yorinasub17 yorinasub17 left a comment

Choose a reason for hiding this comment

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

Build passed, so will go ahead and merge this in! Thanks again for your contribution!

@yorinasub17 yorinasub17 merged commit 15c9206 into gruntwork-io:master Jan 13, 2022
@rhoboat
Copy link
Contributor

rhoboat commented Jan 14, 2022

+1 to this add! Thank you!

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.

3 participants