Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Implement create instance from instance template #500

Conversation

Alw3ys
Copy link
Contributor

@Alw3ys Alw3ys commented Sep 25, 2020

Implement missing creating of vm instance from template

Fixes #114 🦕

@Alw3ys Alw3ys requested a review from a team as a code owner September 25, 2020 11:47
@google-cla
Copy link

google-cla bot commented Sep 25, 2020

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no This human has *not* signed the Contributor License Agreement. label Sep 25, 2020
@codecov
Copy link

codecov bot commented Sep 25, 2020

Codecov Report

Merging #500 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #500   +/-   ##
=======================================
  Coverage   99.61%   99.61%           
=======================================
  Files          22       22           
  Lines       11840    11846    +6     
=======================================
+ Hits        11794    11800    +6     
  Misses         46       46           
Impacted Files Coverage Δ
src/zone.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9e6f9b...78159fa. Read the comment docs.

@sofisl
Copy link
Contributor

sofisl commented Sep 26, 2020

Hi @Alw3ys, would you mind adding tests for this method and signing a CLA?

@stephenplusplus, would you mind taking a look at this as well? Thanks in advance!

@product-auto-label product-auto-label bot added the api: compute Issues related to the googleapis/nodejs-compute API. label Sep 26, 2020
src/zone.js Outdated
@@ -593,6 +594,10 @@ class Zone extends common.ServiceObject {
},
config
);
if (body.sourceInstanceTemplate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you like the idea of mapping this to config.template? The createVM() method is trying to be very simple with the terminology, since the Compute API is so complex. I don't think there's another "template" concept the API would expect in this context, so the short hand should be easier to remember and intuitive from this layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm quite open for other suggestions, The reason I've chosen this way of going forward is since this is how I've seen it in other parts of this repository, and for the sake of keeping consistency, feels quite natural on my eyes to go this way.
Also I would expect something like this to pass the template id, but once again feel free to change it to something that you feel would be a better approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure I was being clear, I do think we should support the user passing a template reference for the request, I just thought template would be an easier name on the user to remember/type than sourceInstanceTemplate. As an example of similar shortcuts, config.http expands to {tags: {items: ['http-server']}}. Do you still think the full name the API recognizes is better? (I'm not convinced either way, just honestly interested)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I didn't understand it properly.
In this case, yes. I do agree with you. I'll push the changes with what you have mentioned :)

@google-cla google-cla bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Sep 30, 2020
@stephenplusplus
Copy link
Contributor

Thank you! It looks perfect to me. I just added a test, but can't push directly. Here's a diff you can apply directly:

$ curl "https://gist.githubusercontent.com/stephenplusplus/6d911fdfdadf904f329c590fc2fb2fdd/raw/8de2d6b201bed3803d21389c5a227661102f3025/compute-pr-500.diff" | git apply

@stephenplusplus stephenplusplus added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 30, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 30, 2020
@stephenplusplus stephenplusplus merged commit 62f33be into googleapis:master Sep 30, 2020
@stephenplusplus
Copy link
Contributor

Thanks again! 🥂

@stephenplusplus
Copy link
Contributor

Released under 2.2.0 👍🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: compute Issues related to the googleapis/nodejs-compute API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for instance templates when creating a new compute engine instance
4 participants