-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
support gcp authentication refresh token #1810
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Welcome @jhbae200! |
@jhbae200 thank you for kicking this off! can you resign your commit by properly setting up your git workspace? git config user.name ..
git config user.email ... |
Signed-off-by: jhbae200 <jhbae200@gmail.com>
Signed-off-by: jhbae200 <jhbae200@gmail.com>
/check-cla |
/assign @yue9944882 |
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.
@jhbae200 can you run mvn spotless:apply
before submitting the changes? thanks!
import java.time.Instant; | ||
import java.util.Date; | ||
import java.util.Map; | ||
import java.util.*; |
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.
wildcard import will fail the lint checker
Process process = new ProcessBuilder().command(commandList).start(); | ||
process.waitFor(10, TimeUnit.SECONDS); | ||
if(process.exitValue() != 0) { | ||
throw new IOException("Process exit code: "+process.exitValue()); |
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'm not sure that IOException is right here. IllegalStateException(...)
?
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.
Also, please make the message more descriptive and include the stderr to make the exception more debuggable.
String stderr = IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8)
throw new IllegalStateException("Failed to get token (" + process.exitValue() + ") " + stderr
Some small comments. Generally looks good. Needs linter formatting to conform to the style guide. |
Signed-off-by: jhbae200 <jhbae200@gmail.com>
Updated the code. am i right? |
Code looks great. Can you add a unit test for this new functionality (sorry, I should have mentioned that before). Once it is tested (and passing) we can merge. |
Signed-off-by: jhbae200 <jhbae200@gmail.com>
I think need to mock the ProcessBuilder to test the refresh method.
|
Signed-off-by: jhbae200 <jhbae200@gmail.com>
Thanks for adding the test! I think it is simpler if you just make the ProcessBuilder an optional constructor parameter, e.g. public GCPAuthenticator() {
this(new ProcessBuilder());
}
public GCPAuthenticator(ProcessBuilder pb) {
this.pb = pb;
}
.... |
Signed-off-by: jhbae200 <jhbae200@gmail.com>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, jhbae200 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Great to have it implemented! Are there any plans to release it in the near future? |
It took me a while to discover that this existed and was released. Any chance this can be added to the documentation for those coming after me? Thanks |
Related Issues:
I wrote a "refresh" function because it seems to be using "cmd-path", "cmd-args", "expiry-key", "token-key" to refresh the token.
Need to check that it works on various os platforms.