Skip to content

Commit

Permalink
Add sample demonstrating startup script (#80)
Browse files Browse the repository at this point in the history
Add sample demonstrating startup script

Add a sample that demonstrates how to create a VM
and install Apache and a custom homepage on startup.

Drive-by fix: Use lint config generated by repo-tools, do not use
Node 8 features like destructuring.
  • Loading branch information
fhinkel authored May 9, 2018
1 parent 679048d commit 7d026c3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions packages/google-cloud-compute/.cloud-repo-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"client_reference_url": "https://cloud.google.com/nodejs/docs/reference/compute/latest/",
"release_quality": "alpha",
"samples": [
{
"id": "startup",
"name": "Create Virtual Machine with Apache and Custom Homepage",
"ref": "startup-script/README.md",
"file": "startup-script/index.js",
"docs_link": "https://cloud.google.com/compute/docs"
},
{
"id": "vms",
"name": "List Virtual Machines",
Expand Down
1 change: 1 addition & 0 deletions packages/google-cloud-compute/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ has instructions for running the samples.

| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Create Virtual Machine with Apache and Custom Homepage | [source code](https://github.com/googleapis/nodejs-compute/blob/master/samples/startup-script/index.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/startup-script/index.js,samples/README.md) |
| List Virtual Machines | [source code](https://github.com/googleapis/nodejs-compute/blob/master/samples/vms.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms.js,samples/README.md) |

The [Compute Engine Node.js Client API Reference][client-docs] documentation
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-compute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
"lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/",
"prettier": "repo-tools exec -- prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"samples-test": "cd samples/ && npm link ../ && cd startup-script && npm link ../../ && cd ../ && npm test && cd ../",
"system-test": "repo-tools test run --cmd mocha -- system-test/*.js --no-timeouts",
"test-no-cover": "repo-tools test run --cmd mocha -- test/*.js --no-timeouts",
"test": "repo-tools test run --cmd npm -- run cover"
Expand Down
1 change: 0 additions & 1 deletion packages/google-cloud-compute/samples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
rules:
no-console: off
node/no-unsupported-features: off
14 changes: 11 additions & 3 deletions packages/google-cloud-compute/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

* [Before you begin](#before-you-begin)
* [Samples](#samples)
* [Create Virtual Machine with Apache and Custom Homepage](#create-virtual-machine-with-apache-and-custom-homepage)
* [List Virtual Machines](#list-virtual-machines)

## Before you begin
Expand All @@ -22,16 +23,23 @@ library's README.

## Samples

### Create Virtual Machine with Apache and Custom Homepage


View the [README](startup-script/README.md).



### List Virtual Machines

View the [source code][vms_0_code].
View the [source code][vms_1_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms.js,samples/README.md)

Get a list of virtual machine instances and log the first result.

[vms_0_docs]: https://cloud.google.com/compute/docs
[vms_0_code]: vms.js
[vms_1_docs]: https://cloud.google.com/compute/docs
[vms_1_code]: vms.js

[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/README.md
4 changes: 3 additions & 1 deletion packages/google-cloud-compute/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"node": ">=4.0.0"
},
"scripts": {
"test": "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js"
"system-test" : "repo-tools test run --cmd ava -- -T 20s --verbose system-test/*.test.js",
"startup-test": "repo-tools test run --cmd ava -- -T 200s --verbose startup-script/system-test/*.test.js",
"test": "npm run system-test && npm run startup-test"
},
"dependencies": {
"@google-cloud/compute": "0.10.0",
Expand Down

0 comments on commit 7d026c3

Please sign in to comment.