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

fix: Duplicate project name issue and reintroduce logging changes #3047

Merged
merged 3 commits into from May 3, 2024

Conversation

hugorut
Copy link
Contributor

@hugorut hugorut commented Apr 29, 2024

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:

version: 0.1

projects
  - path: foo
  - path: bar

Any paths found under foo or bar would be made relative to their parent path, e.g. foo/path/one would be path/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 the TerragruntHCLProvider and TerraformHCLProvider. In these cases the basePath could and path used to create a terraformModulePath would occasionally result in errors as the basePath path would not be within the path or the path was made absolute through Terragrunts internals. In order to fix this I've changed the module path logic to use the standardised RelativePath logic that uses paths that we've initially built from the ProjectLocator.

I've also switched the logic of the Config.RepoPath (now Config.WorkingDirectory) to use the os.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 to StartingPath to better ilustrate that this is an autodetect starting point, and can be different from the repo root/working directory. InitialPath/Path has moved to DetectedPath to illustrate this is the detected path of a project. I've also introduced/changed reference of the top level RepoPath to WorkingDirectory 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

@hugorut hugorut self-assigned this Apr 29, 2024
@hugorut hugorut changed the title Revert "revert: logging changes (#3038)" fix: Duplicate project name issue and reintroduce logging changes Apr 29, 2024
@hugorut hugorut force-pushed the feat/logging-readd branch 8 times, most recently from 87e4742 to e284d85 Compare April 30, 2024 12:41
@hugorut hugorut marked this pull request as ready for review April 30, 2024 13:20
@hugorut hugorut requested a review from a team as a code owner April 30, 2024 13:20
@hugorut hugorut requested a review from aliscott April 30, 2024 13:20
Resolves issue where projects defined in config files returned a `RelativePath`
relative to the initial `path` provided in the config file project config.
@hugorut hugorut merged commit c205cb0 into master May 3, 2024
8 of 10 checks passed
@hugorut hugorut deleted the feat/logging-readd branch May 3, 2024 09:29
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