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: add support for separate GitHub app credentials #649

Merged

Conversation

dlactin
Copy link
Contributor

@dlactin dlactin commented Dec 7, 2023

This PR adds support for separate GitHub app credentials using the pre-existing GitHub App functions

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (0252dae) 66.41% compared to head (7691eee) 66.27%.

Files Patch % Lines
pkg/argocd/gitcreds.go 38.88% 6 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #649      +/-   ##
==========================================
- Coverage   66.41%   66.27%   -0.14%     
==========================================
  Files          22       22              
  Lines        2138     2150      +12     
==========================================
+ Hits         1420     1425       +5     
- Misses        587      591       +4     
- Partials      131      134       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dlactin dlactin force-pushed the separate-github-app-credentials branch 2 times, most recently from 15573da to 5036e73 Compare December 7, 2023 06:42
@dlactin dlactin force-pushed the separate-github-app-credentials branch from 5036e73 to ad6d8a1 Compare December 7, 2023 06:54
@dlactin dlactin changed the title feat: add support for separate GitHub app credentials stored feat: add support for separate GitHub app credentials Dec 7, 2023
Copy link
Contributor

@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.

Change LGTM so far, thank you!

I have just one request regarding error handling.

Comment on lines 79 to 80
intGithubAppID, _ := strconv.ParseInt(string(githubAppID), 10, 64)
intGithubAppInstallationID, _ := strconv.ParseInt(string(githubAppInstallationID), 10, 64)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we really should check for error in string-to-number conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, meant to add that after testing. I'll add it now!

Copy link
Contributor

@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.

Small suggestion for returning the error, so that the error message may be more helpful to the user.

// converting byte array to string and ultimately int64 for NewGitHubAppCreds
intGithubAppID, err := strconv.ParseInt(string(githubAppID), 10, 64)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, err
return nil, fmt.Errorf("invalid value in field githubAppID: %w", err)

just a tiny improvement to help with troubleshooting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't sure if I could just commit the suggestions, so I added a new commit for these changes. Thank you!

}
intGithubAppInstallationID, _ := strconv.ParseInt(string(githubAppInstallationID), 10, 64)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, err
return nil, fmt.Errorf("invalid value in field githubAppInstallationID: %w", err)

just a tiny improvement to help with troubleshooting

Copy link
Contributor

@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.

LGTM!

Thanks a lot for this PR, @dlactin. Appreciate it much!

@jannfis jannfis merged commit 7d93c7a into argoproj-labs:master Dec 7, 2023
9 checks passed
dlactin added a commit to dlactin/argocd-image-updater that referenced this pull request May 9, 2024
)

* feat: add support for separate GitHub app credentials stored as Kubernetes secrets

Signed-off-by: Dustin Lactin <[email protected]>

* test: added tests for consuming GitHub app credentials from a secret

Signed-off-by: Dustin Lactin <[email protected]>

* fix: added GitHub App placeholder words to expect.txt

Signed-off-by: Dustin Lactin <[email protected]>

* fix: checking for errors when converting GitHub App and Installation IDs

Signed-off-by: Dustin Lactin <[email protected]>

* fix: added more descriptive error messages for string-to-number conversions

Signed-off-by: Dustin Lactin <[email protected]>

---------

Signed-off-by: Dustin Lactin <[email protected]>
sribiere-jellysmack pushed a commit to sribiere-jellysmack/argocd-image-updater that referenced this pull request Aug 13, 2024
)

* feat: add support for separate GitHub app credentials stored as Kubernetes secrets

Signed-off-by: Dustin Lactin <[email protected]>

* test: added tests for consuming GitHub app credentials from a secret

Signed-off-by: Dustin Lactin <[email protected]>

* fix: added GitHub App placeholder words to expect.txt

Signed-off-by: Dustin Lactin <[email protected]>

* fix: checking for errors when converting GitHub App and Installation IDs

Signed-off-by: Dustin Lactin <[email protected]>

* fix: added more descriptive error messages for string-to-number conversions

Signed-off-by: Dustin Lactin <[email protected]>

---------

Signed-off-by: Dustin Lactin <[email protected]>
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.

3 participants