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

feat: allow substitutions in plugin env variables #6097

Merged
merged 5 commits into from
Jun 4, 2021
Merged

feat: allow substitutions in plugin env variables #6097

merged 5 commits into from
Jun 4, 2021

Conversation

ForsakenHarmony
Copy link
Contributor

@ForsakenHarmony ForsakenHarmony commented Apr 23, 2021

Related to #5293

Until there's a more robust solution for custom plugins I wanted to be able to pass specific args including e.g. the revision to tanka

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).
  • 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).

Signed-off-by: Leah <github.leah@hrmny.sh>
Signed-off-by: Leah <github.leah@hrmny.sh>
Signed-off-by: Leah <github.leah@hrmny.sh>
@ForsakenHarmony ForsakenHarmony marked this pull request as ready for review April 23, 2021 15:00
@codecov
Copy link

codecov bot commented Apr 27, 2021

Codecov Report

Merging #6097 (01c3cbc) into master (b6d5c23) will increase coverage by 0.09%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6097      +/-   ##
==========================================
+ Coverage   40.93%   41.03%   +0.09%     
==========================================
  Files         147      151       +4     
  Lines       19729    19960     +231     
==========================================
+ Hits         8077     8191     +114     
- Misses      10541    10640      +99     
- Partials     1111     1129      +18     
Impacted Files Coverage Δ
reposerver/repository/repository.go 60.85% <80.00%> (+0.08%) ⬆️
reposerver/cache/cache.go 67.44% <0.00%> (-12.56%) ⬇️
util/git/client.go 44.28% <0.00%> (-3.77%) ⬇️
controller/appcontroller.go 53.05% <0.00%> (-0.47%) ⬇️
controller/state.go 68.50% <0.00%> (-0.46%) ⬇️
util/argo/argo.go 61.63% <0.00%> (-0.21%) ⬇️
controller/cache/cache.go 10.74% <0.00%> (-0.13%) ⬇️
cmd/argocd-util/commands/argocd_util.go 14.51% <0.00%> (-0.12%) ⬇️
cmd/argocd/commands/cluster.go 2.59% <0.00%> (-0.10%) ⬇️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6d5c23...01c3cbc. Read the comment docs.

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution, @ForsakenHarmony!

I have some comments, see below.

for i, v := range env {
parsedVar, err := v1alpha1.NewEnvEntry(v)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Can you please create a custom error here using fmt.Errorf() instead of passing down err - because it might contain the value of the erroneous environment variable, which ends up in the logs eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think we should return here? It would be nice to know the name of the env var that failed, but I suppose that's not really possible without potentially compromising a secret

I'm also wondering if it's even possible for this to happen

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the error might contain env variable defined in ApplicationSource only, not the local env variables of the repo-server pod.

The ApplicationSource is not considered secret and already appears in repo-server logs, so I'm fine to keep it as is.

reposerver/repository/repository_test.go Show resolved Hide resolved
@@ -33,7 +33,7 @@ Commands have access to

1. The system environment variables
2. [Standard build environment](build-environment.md)
3. Variables in the application spec:
3. Variables in the application spec (you can substitute any of the variables from the last 2 points):
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking: I think it is hard to understand the meaning of this sentence, can we rephrase it a little? E.g. "References to system and build variables will get interpolated in the variables' values."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that sounds good, I wasn't happy with it either

Tried coming up with a nice way to phrase it 3 times, but that didn't work out, I'm adding your suggestion

Signed-off-by: Leah <github.leah@hrmny.sh>
Signed-off-by: Leah <github.leah@hrmny.sh>
Copy link
Collaborator

@alexmt alexmt left a comment

Choose a reason for hiding this comment

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

LGTM.

@jannfis , can you check my comment regarding logging the error? WDYT?

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the review concerns, @ForsakenHarmony

LGTM now!

@jannfis jannfis merged commit abb0c4b into argoproj:master Jun 4, 2021
@ForsakenHarmony ForsakenHarmony deleted the plugin-env-subst branch June 9, 2021 13:45
@jannfis jannfis self-assigned this Jun 25, 2021
@jannfis jannfis added the needs-verification PR requires pre-release verification label Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-verification PR requires pre-release verification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants