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: handle repo creation when secret does not have proper label #7617

Merged
merged 3 commits into from Nov 5, 2021

Conversation

leoluz
Copy link
Collaborator

@leoluz leoluz commented Nov 4, 2021

Signed-off-by: Leonardo Luz Almeida leonardo_almeida@intuit.com

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

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: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
@leoluz leoluz requested a review from alexmt November 4, 2021 03:08
Comment on lines 44 to 45
msg := "secret %q doesn't have the proper %q label: please fix the secret or delete it"
return nil, status.Errorf(codes.InvalidArgument, msg, secName, common.LabelKeySecretType)
Copy link
Member

Choose a reason for hiding this comment

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

This is just a nitpick, but for the compiler (and/or linter) to catch issues with the format string, I think it would be wiser to either have msg := fmt.Sprintf(...) and use status.Error(), or just get rid of the intermediate variable msg and use status.Errorf() with the format string literal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason why I did that was to avoid having a too long line and avoid scrolling. Too bad the linter is not smart enough to verify the code with variables as well. I picked your first suggestion as it has better code readability. 👍🏻

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 @leoluz! LGTM with three minor things (one of them in a separate comment above):

  • Linter is unhappy about import order, please fix

  • While I appreciate embedding the test data (I suppose they don't end up in the binaries we distribute, and only get embedded in the binaries used for testing?), I think this would be a fine separate PR and shouldn't come with this one.

@leoluz
Copy link
Collaborator Author

leoluz commented Nov 4, 2021

@jannfis

Linter is unhappy about import order, please fix

Issue with goimports fixed. Didn't know that we have to run it with -local github.com/argoproj/argo-cd flag. Tks!

While I appreciate embedding the test data (I suppose they don't end up in the binaries we distribute, and only get embedded in the binaries used for testing?), I think this would be a fine separate PR and shouldn't come with this one.

A go binary only includes code reachable from its main() entry point. For test binaries main() is the test runner. So unless someone imports the testdata package in a code that is reachable from one of the command's main() this won't be added to the binaries that we distribute. The reason why I added this code in this PR is because it was impacting delve when I was trying to debug the tests. The previous code was reading test data with relative path expecting the CWD to be defined where the test file is located. The current code doesn't have this limitation and is refactoring friendly.

Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
@leoluz leoluz requested a review from jannfis November 4, 2021 14:30
@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #7617 (0064d8a) into master (6036e9b) will increase coverage by 0.04%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7617      +/-   ##
==========================================
+ Coverage   41.39%   41.44%   +0.04%     
==========================================
  Files         161      161              
  Lines       21686    21787     +101     
==========================================
+ Hits         8978     9030      +52     
- Misses      11444    11487      +43     
- Partials     1264     1270       +6     
Impacted Files Coverage Δ
util/db/repository_secrets.go 69.68% <77.77%> (+1.61%) ⬆️
pkg/apis/application/v1alpha1/types.go 54.99% <0.00%> (-2.29%) ⬇️
cmd/argocd/commands/admin/app.go 30.50% <0.00%> (-0.40%) ⬇️
util/settings/settings.go 46.83% <0.00%> (-0.26%) ⬇️
controller/appcontroller.go 53.03% <0.00%> (-0.06%) ⬇️
controller/state.go 68.02% <0.00%> (ø)
cmd/argocd/commands/app.go 0.53% <0.00%> (ø)
cmd/argocd/commands/projectwindows.go 0.00% <0.00%> (ø)
util/rbac/rbac.go 77.04% <0.00%> (+0.64%) ⬆️
cmd/util/app.go 37.95% <0.00%> (+0.76%) ⬆️
... and 3 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 6036e9b...0064d8a. Read the comment docs.

Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
@leoluz
Copy link
Collaborator Author

leoluz commented Nov 4, 2021

@jannfis PR updated.

Moved the GPG test data refactoring to #7625

Please review

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

@alexmt alexmt merged commit b0278c4 into argoproj:master Nov 5, 2021
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

3 participants