-
Notifications
You must be signed in to change notification settings - Fork 89
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
Update to use ComputeClient from gcp-plugin-core. #140
Update to use ComputeClient from gcp-plugin-core. #140
Conversation
cloud.getClient().terminateInstance(cloud.getProjectId(), remote.getZone(), instanceName); | ||
cloud | ||
.getClient() | ||
.terminateInstanceAsync(cloud.getProjectId(), remote.getZone(), instanceName); |
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 changes the logic from a synchronous action to an async one, without verifying the termination was successful. Suggest either using a synchronous method, or else capturing the async operation and blocking/verifying the result.
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 was actually asynchronous previously, see https://github.com/jenkinsci/google-compute-engine-plugin/pull/140/files#diff-3a1816b899650c36d00ea7935022fe36L362 . However, this information wasn't included in the method names of the original client which is why the name has been changed in the gcp-plugin-core client.
src/main/java/com/google/jenkins/plugins/computeengine/ComputeEngineInstance.java
Outdated
Show resolved
Hide resolved
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.
A few minor notes, but otherwise LGTM.
Great work!
src/main/java/com/google/jenkins/plugins/computeengine/client/ClientUtil.java
Outdated
Show resolved
Hide resolved
private static final String APPLICATION_NAME = "jenkins-google-compute-plugin"; | ||
|
||
/** | ||
* Creates a {@link ClientFactory} for generating the GCP api clients. |
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.
s/api/API
src/main/java/com/google/jenkins/plugins/computeengine/client/ClientUtil.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/jenkins/plugins/computeengine/client/ClientUtil.java
Outdated
Show resolved
Hide resolved
@@ -49,6 +48,32 @@ | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class ComputeEngineCloudTest { | |||
|
|||
public static final PrivateKey PRIVATE_KEY; |
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.
Do these need to be public? Also, please remove the extra '\n' on line 50.
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.
No, they were public when these values were shared between ClientFactoryTest.java and this file, now that they are isolated to this file I've fixed that. And removed the extra '\n'
@@ -141,7 +142,10 @@ private static String loadCredentialsString() { | |||
} | |||
|
|||
static Credentials initCredentials(JenkinsRule r) throws Exception { | |||
ServiceAccountConfig sac = new StringJsonServiceAccountConfig(CREDENTIALS); | |||
SecretBytes bytes = SecretBytes.fromBytes(CREDENTIALS.getBytes(StandardCharsets.UTF_8)); |
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 logic seems to be repeated in a few places throughout the code. Does it make sense to consolidate?
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
Suggest also adding a similar note to the README about OAuth v0.9 compatibility. |
I love any PR with a -1392 delta ;) |
…om this and the previous pull request to changelog, and update snapshot version to 4.0.0
Depends on: