fix: Duplicate project name issue and reintroduce logging changes #3047
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.
This change reintroduces the changes that were initially made in #3003 but reverted due to production issues. I have reworked the initial changes after finding various issues with the project path/naming.
The crux of the matter comes from the paths used/defined in config files. Before this change paths were made relative to the paths defined in the config file. For example, take the following config file:
Any paths found under
foo
orbar
would be made relative to their parent path, e.g.foo/path/one
would bepath/one
. This is incorrect as technically the project path should be relative to the repository path. e.g.foo/path/one
.This also exposed a bug in the
AddMetadata
methods for both theTerragruntHCLProvider
andTerraformHCLProvider
. In these cases thebasePath
could andpath
used to create aterraformModulePath
would occasionally result in errors as thebasePath
path would not be within thepath
or thepath
was made absolute through Terragrunts internals. In order to fix this I've changed the module path logic to use the standardisedRelativePath
logic that uses paths that we've initially built from theProjectLocator
.I've also switched the logic of the
Config.RepoPath
(nowConfig.WorkingDirectory
) to use theos.WorkingDir
if a--config-file
is used. This fixes a bug where if a config file path was used outside the root of the repo the path returned would be incorrect.The final change I've made is to rework some of the path naming around the codebase to make it easier to understand what is what.
RepoPath
has now moved toStartingPath
to better ilustrate that this is an autodetect starting point, and can be different from the repo root/working directory.InitialPath/Path
has moved toDetectedPath
to illustrate this is the detected path of a project. I've also introduced/changed reference of the top levelRepoPath
toWorkingDirectory
to highlight this is the path the cli is working within (either through --path or the wd of the current binary).relevant changes are in the e284d85 commit