-
Notifications
You must be signed in to change notification settings - Fork 46
[DRAFT] Update DFIU to verify whether renovate is installed #1133
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
5ebf634
eaf7cda
1fb97c6
ebbb223
851b05b
53b2886
087f4e3
9685288
2594f38
4a4448a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ private Constants() { | |
| public static final String IGNORE_IMAGE_STRING = "x"; | ||
| public static final String FILE_NAMES_TO_SEARCH = "filenamestosearch"; | ||
| public static final String RATE_LIMIT_PR_CREATION = "rate_limit_pr_creations"; | ||
| public static final String RENOVATE_GITHUB_APP_ID = "appId"; | ||
|
||
| public static final String RENOVATE_GITHUB_APP_KEY = "appKey"; | ||
| public static final String DEBUG = "debug"; | ||
| //max number of PRs to be sent (or tokens to be added) per DEFAULT_RATE_LIMIT_DURATION(per hour in this case) | ||
| public static final long DEFAULT_RATE_LIMIT = 60; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||||
| package com.salesforce.dockerfileimageupdate.utils; | ||||||
|
|
||||||
| import com.auth0.jwt.JWT; | ||||||
| import com.auth0.jwt.algorithms.Algorithm; | ||||||
| import com.salesforce.dockerfileimageupdate.CommandLine; | ||||||
| import net.sourceforge.argparse4j.inf.Namespace; | ||||||
| import org.bouncycastle.util.io.pem.PemReader; | ||||||
| import org.kohsuke.github.GitHub; | ||||||
| import org.kohsuke.github.GitHubBuilder; | ||||||
| import org.kohsuke.github.HttpException; | ||||||
| import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | ||||||
|
|
||||||
| import java.io.File; | ||||||
| import java.io.FileReader; | ||||||
| import java.io.IOException; | ||||||
| import java.security.GeneralSecurityException; | ||||||
| import java.security.KeyFactory; | ||||||
| import java.security.Security; | ||||||
| import java.security.interfaces.RSAPrivateKey; | ||||||
| import java.security.spec.PKCS8EncodedKeySpec; | ||||||
| import java.time.Instant; | ||||||
| import java.util.Date; | ||||||
|
|
||||||
| public class RenovateUtil { | ||||||
|
||||||
| public class RenovateUtil { | |
| public class GithubAppCheck { |
Util is not a good descriptive name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these all need to be made final static is not a good practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to do ns.get() in this case instead of calling directly from Constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to call the CLI input to the Java code. The constant is the CLI identifier for the input.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make this more generic - to check for any app existance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the owner's open source, looks like it is using GHApp instead of GithubBuilder for this logic: https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GHApp.java
I don't see such getApp() function be mentioned in GithubBuilder: https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GitHubBuilder.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is the one: https://github.com/hub4j/github-api/blob/af5bde714c3f771f6793392343ff0187bd8180df/src/main/java/org/kohsuke/github/GitHub.java#L1184. We are calling the method from the object type Github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But github is a GithubBuilder object, not Github though, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls refer to https://github.com/AvvariSaiBharadwaj/dockerfile-image-update/blob/excludeRenovateRepos/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/GithubAppCheck.java#L45-L48. github is generated by githubBuilder.build() which returns a github object (https://github.com/hub4j/github-api/blob/main/src/main/java/org/kohsuke/github/GitHubBuilder.java#L508)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't IDs always integers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afalko It does not matter as it would be parsed as a parameter in a request API call to Github API to generate a JWT token. We have tested this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not have the parser do the parsing for you upfront here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afalko the reason for that is because appID will be parsed into the JWT token generation API call under the
.withIssuer(appId)subcall, and this has to be parsed as a string type. You can see more here: https://www.baeldung.com/java-auth0-jwtWe can change it to
Integertype if you truly think it is necessary and purposeful (to comply with the App ID integer type from Github App) and convert it to string when parsed into this API callUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha - pass-through might be fine, but it likely be a difficult error message to understand (vs. hey, you need an integer here). I think it is purposeful to make this integer for that release, but not necessary :)