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: Post selector with Go templates in ApplicationSet #13584

Merged
merged 4 commits into from May 27, 2023

Conversation

m13t
Copy link
Contributor

@m13t m13t commented May 14, 2023

This PR fixes #12524 by allow users to reference nested properties when using Go template syntax in application sets. Previously only top-level string keys could be used as post selectors. When matching labels, this PR will now allow referencing nested keys by concatenating each key with a dot (.).

The original match values tests have been duplicated with Go templates enabled to provide more extensive tests.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

@m13t m13t force-pushed the fix/labels-with-go-templates branch from 9d55774 to ff72202 Compare May 14, 2023 15:31
@codecov
Copy link

codecov bot commented May 14, 2023

Codecov Report

Patch coverage: 47.36% and project coverage change: -0.02 ⚠️

Comparison is base (0a8a71e) 49.17% compared to head (e90a476) 49.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13584      +/-   ##
==========================================
- Coverage   49.17%   49.16%   -0.02%     
==========================================
  Files         248      248              
  Lines       42872    42881       +9     
==========================================
- Hits        21084    21083       -1     
- Misses      19687    19695       +8     
- Partials     2101     2103       +2     
Impacted Files Coverage Δ
...licationset/generators/generator_spec_processor.go 59.18% <47.36%> (-7.11%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@m13t
Copy link
Contributor Author

m13t commented May 14, 2023

I've made a slight addition to my original commit for this to create a generic map flattening function as this would also be useful for supporting nested keys in the merge generator mergeKeys as this also has issues when using Go templates. Assuming this PR is okay I'll look to tackle that as a separate PR.

@crenshaw-dev
Copy link
Collaborator

Thanks so much for this PR! And yes, fixing mergeKeys would also be huge.

@m13t m13t force-pushed the fix/labels-with-go-templates branch 4 times, most recently from 541bef1 to 6a0ab9f Compare May 19, 2023 09:13
@m13t
Copy link
Contributor Author

m13t commented May 19, 2023

@crenshaw-dev I've rebased this PR and there looks to be some issues with the recently merged in test changes you did on the matrix generator as part of m13t@fafee48.

Can't understand why the changes in the PR you merged worked but do not in my branch. Seems as though the non-go template variables are not being interpolated. Any ideas?

m13t and others added 4 commits May 25, 2023 11:38
Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
…ng function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
@m13t m13t force-pushed the fix/labels-with-go-templates branch from 6a0ab9f to e90a476 Compare May 25, 2023 10:38
@m13t
Copy link
Contributor Author

m13t commented May 25, 2023

@crenshaw-dev rebased and all working again now. This is good to go.

Copy link
Collaborator

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Beautiful, thanks @m13t!

@crenshaw-dev crenshaw-dev merged commit 74839c8 into argoproj:master May 27, 2023
24 checks passed
@crenshaw-dev
Copy link
Collaborator

/cherry-pick release-2.7

@gcp-cherry-pick-bot
Copy link

Cherry-pick failed with Merge error 74839c88214605918e9fc47a63ff9fdfd3651aa0 into temp-cherry-pick-022040-release-2.7

@crenshaw-dev
Copy link
Collaborator

/cherry-pick release-2.6

@gcp-cherry-pick-bot
Copy link

Cherry-pick failed with Merge error 74839c88214605918e9fc47a63ff9fdfd3651aa0 into temp-cherry-pick-022040-release-2.6

@crenshaw-dev
Copy link
Collaborator

/cherry-pick release-2.5

@gcp-cherry-pick-bot
Copy link

Cherry-pick failed with Merge error 74839c88214605918e9fc47a63ff9fdfd3651aa0 into temp-cherry-pick-022040-release-2.5

@crenshaw-dev
Copy link
Collaborator

@m13t would you mind opening PRs against release-2.5, release-2.6, and release-2.7? Cherry-pick bot is finicky.

m13t added a commit to m13t/argo-cd that referenced this pull request May 30, 2023
…roj#13584)

* fixes argoproj#12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
m13t added a commit to m13t/argo-cd that referenced this pull request May 30, 2023
…roj#13584)

* fixes argoproj#12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
m13t added a commit to m13t/argo-cd that referenced this pull request May 30, 2023
…roj#13584)

* fixes argoproj#12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
@m13t
Copy link
Contributor Author

m13t commented May 30, 2023

@crenshaw-dev manual cherry-picked PRs are in

crenshaw-dev added a commit that referenced this pull request May 30, 2023
…y-pick #13584) (#13822)

* fix(appset): Post selector with Go templates in ApplicationSet (#13584)

* fixes #12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* fix merge

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* re-add deleted test

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
crenshaw-dev pushed a commit that referenced this pull request Jun 1, 2023
…y-pick #13584) (#13823)

* fix(appset): Post selector with Go templates in ApplicationSet (#13584)

* fixes #12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* fixed tests

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
crenshaw-dev pushed a commit that referenced this pull request Jun 1, 2023
…y-pick #13584) (#13824)

* fix(appset): Post selector with Go templates in ApplicationSet (#13584)

* fixes #12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* fixed tests

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* fixed missing import

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
schakrad pushed a commit to schakrad/argo-cd that referenced this pull request Jul 24, 2023
…y-pick argoproj#13584) (argoproj#13822)

* fix(appset): Post selector with Go templates in ApplicationSet (argoproj#13584)

* fixes argoproj#12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* fix merge

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

* re-add deleted test

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: schakrad <58915923+schakrad@users.noreply.github.com>
yyzxw pushed a commit to yyzxw/argo-cd that referenced this pull request Aug 9, 2023
…roj#13584)

* fixes argoproj#12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
tesla59 pushed a commit to tesla59/argo-cd that referenced this pull request Dec 16, 2023
…roj#13584)

* fixes argoproj#12524

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* refactor keepOnlyStringLabels function into more generic map flattening function

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>

* updated USERS.md

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

* use flatten library to replace custom flatten function

Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>

---------

Signed-off-by: Lewis Marsden-Lambert <lewis.lambert@zserve.co.uk>
Signed-off-by: Lewis Marsden-Lambert <lewis.marsden-lambert@smartpension.co.uk>
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.

Post selectors broken when using goTemplate: true
2 participants