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

Update to use ComputeClient from gcp-plugin-core. #140

Merged
merged 10 commits into from
Sep 9, 2019

Conversation

stephenashank
Copy link
Contributor

@stephenashank stephenashank commented Aug 23, 2019

Depends on:

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved
cloud.getClient().terminateInstance(cloud.getProjectId(), remote.getZone(), instanceName);
cloud
.getClient()
.terminateInstanceAsync(cloud.getProjectId(), remote.getZone(), instanceName);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@craigdbarber craigdbarber left a 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!

private static final String APPLICATION_NAME = "jenkins-google-compute-plugin";

/**
* Creates a {@link ClientFactory} for generating the GCP api clients.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/api/API

@@ -49,6 +48,32 @@
@RunWith(MockitoJUnitRunner.class)
public class ComputeEngineCloudTest {

public static final PrivateKey PRIVATE_KEY;
Copy link
Contributor

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.

Copy link
Contributor Author

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));
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@craigdbarber
Copy link
Contributor

Suggest also adding a similar note to the README about OAuth v0.9 compatibility.

@craigdbarber
Copy link
Contributor

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

2 participants