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 handling of data_overrides in project factory #2998

Merged
merged 8 commits into from
Apr 6, 2025

Conversation

wiktorn
Copy link
Collaborator

@wiktorn wiktorn commented Apr 1, 2025

coalesce([], ["a"]) == [] and coalesce({}, {a = 1}) == {}, so it's wrong default value for data_overrides. Changed that to null + added few comments and tests.

Allow multiple project files of the same name in factory, as long as they override the name. If duplicate is found, following error is raised:

Error: Duplicate object key

  on factory-projects.tf line 39, in locals:
  35:   _projects_input = {
  36:     # will raise error, if the same filename is raised multiple times
  37:     # and project name is not set via name in YAML
  38:     for k, v in merge(local._hierarchy_projects_full_path, local._projects_full_path) :
  39:     lookup(v, "name", basename(k)) => v
  40:   }

Two different items produced the key "automation" in this 'for' expression.
If duplicates are expected, use the ellipsis (...) after the value expression
to enable grouping by key.

Which hopefully will help users to understand where the error is.


Checklist

I applicable, I acknowledge that I have:

  • Read the contributing guide
  • Ran terraform fmt on all modified files
  • Regenerated the relevant README.md files using tools/tfdoc.py
  • Made sure all relevant tests pass

@wiktorn wiktorn marked this pull request as draft April 2, 2025 07:06
@wiktorn wiktorn force-pushed the wiktorn-fix-pf-coalesce branch from de287fd to 04c0d01 Compare April 2, 2025 19:55
@wiktorn wiktorn changed the title Fix coalesce on lists and maps Fix handling of data_overrides in project factory Apr 2, 2025
@wiktorn wiktorn marked this pull request as ready for review April 2, 2025 19:56
@wiktorn wiktorn force-pushed the wiktorn-fix-pf-coalesce branch 2 times, most recently from ad80d9f to 68ef8e6 Compare April 2, 2025 20:03
@wiktorn wiktorn marked this pull request as draft April 2, 2025 20:12
@wiktorn wiktorn marked this pull request as ready for review April 2, 2025 20:16
@wiktorn wiktorn force-pushed the wiktorn-fix-pf-coalesce branch from 8608c02 to b421a42 Compare April 6, 2025 13:45
@wiktorn wiktorn requested a review from ludoo April 6, 2025 14:11
@wiktorn wiktorn force-pushed the wiktorn-fix-pf-coalesce branch from 52e562b to b9e2cce Compare April 6, 2025 18:04
@wiktorn wiktorn enabled auto-merge (rebase) April 6, 2025 18:04
@wiktorn wiktorn merged commit 6d2173a into master Apr 6, 2025
19 checks passed
@wiktorn wiktorn deleted the wiktorn-fix-pf-coalesce branch April 6, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants