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

fix: update nodejs and cloud functions #612

Merged
merged 2 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .kokoro/functions-helloworld.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ gcloud config set project $GCLOUD_PROJECT
function cleanup {
CODE=$?

gcloud beta functions delete helloHttp -q
gcloud beta functions delete helloGET -q
gcloud beta functions delete helloBackground -q
gcloud beta functions delete helloPubSub -q
gcloud beta functions delete helloGCS -q
gcloud beta functions delete helloError -q
gcloud beta functions delete helloError2 -q
gcloud beta functions delete helloError3 -q
gcloud beta functions delete helloTemplate -q
gcloud functions delete helloHttp -q
gcloud functions delete helloGET -q
gcloud functions delete helloBackground -q
gcloud functions delete helloPubSub -q
gcloud functions delete helloGCS -q
gcloud functions delete helloError -q
gcloud functions delete helloError2 -q
gcloud functions delete helloError3 -q
gcloud functions delete helloTemplate -q
}
trap cleanup EXIT

Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

machine:
node:
version: 6.14.1
version: 8.11.1

# Use for broader build-related configuration
general:
Expand All @@ -31,7 +31,7 @@ dependencies:
override:
- echo $KEYFILE > /home/ubuntu/nodejs-docs-samples/key.json
- gcloud auth activate-service-account --key-file /home/ubuntu/nodejs-docs-samples/key.json || true
- yarn global add ava nyc codecov semistandard @google-cloud/[email protected] @google-cloud/[email protected]alpha.29
- yarn global add ava nyc codecov semistandard @google-cloud/[email protected] @google-cloud/[email protected]beta.4
- yarn install
- yarn run lint
- samples test install -l=functions/background
Expand Down
12 changes: 6 additions & 6 deletions functions/datastore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ Functions for your project.

1. Deploy the "get" function with an HTTP trigger:

gcloud beta functions deploy get --trigger-http
gcloud functions deploy get --trigger-http

1. Deploy the "set" function with an HTTP trigger:

gcloud beta functions deploy set --trigger-http
gcloud functions deploy set --trigger-http

1. Deploy the "del" function with an HTTP trigger:

gcloud beta functions deploy del --trigger-http
gcloud functions deploy del --trigger-http

1. Call the "set" function to create a new entity:

gcloud beta functions call set --data '{"kind":"Task","key":"sampletask1","value":{"description":"Buy milk"}}'
gcloud functions call set --data '{"kind":"Task","key":"sampletask1","value":{"description":"Buy milk"}}'

or

Expand All @@ -48,7 +48,7 @@ Functions for your project.

1. Call the "get" function to read the newly created entity:

gcloud beta functions call get --data '{"kind":"Task","key":"sampletask1"}'
gcloud functions call get --data '{"kind":"Task","key":"sampletask1"}'

or

Expand All @@ -70,7 +70,7 @@ Functions for your project.

1. Call the "get" function again to verify it was deleted:

gcloud beta functions call get --data '{"kind":"Task","key":"sampletask1"}'
gcloud functions call get --data '{"kind":"Task","key":"sampletask1"}'

or

Expand Down
6 changes: 3 additions & 3 deletions functions/datastore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function getKeyFromRequestData (requestData) {
* Creates and/or updates a record.
*
* @example
* gcloud beta functions call set --data '{"kind":"Task","key":"sampletask1","value":{"description": "Buy milk"}}'
* gcloud functions call set --data '{"kind":"Task","key":"sampletask1","value":{"description": "Buy milk"}}'
*
* @param {object} req Cloud Function request context.
* @param {object} req.body The request body.
Expand Down Expand Up @@ -78,7 +78,7 @@ exports.set = (req, res) => {
* Retrieves a record.
*
* @example
* gcloud beta functions call get --data '{"kind":"Task","key":"sampletask1"}'
* gcloud functions call get --data '{"kind":"Task","key":"sampletask1"}'
*
* @param {object} req Cloud Function request context.
* @param {object} req.body The request body.
Expand Down Expand Up @@ -110,7 +110,7 @@ exports.get = (req, res) => {
* Deletes a record.
*
* @example
* gcloud beta functions call del --data '{"kind":"Task","key":"sampletask1"}'
* gcloud functions call del --data '{"kind":"Task","key":"sampletask1"}'
*
* @param {object} req Cloud Function request context.
* @param {object} req.body The request body.
Expand Down
4 changes: 2 additions & 2 deletions functions/datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"lint": "repo-tools lint",
"pretest": "npm run lint",
"e2e-test": "export FUNCTIONS_CMD='gcloud beta functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" ava -T 20s --verbose test/*.test.js",
"e2e-test": "export FUNCTIONS_CMD='gcloud functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" ava -T 20s --verbose test/*.test.js",
"system-test": "export FUNCTIONS_CMD='functions' && sh test/updateFunctions.sh && BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" ava -T 20s --verbose test/*.test.js",
"test": "npm run system-test"
},
Expand All @@ -23,7 +23,7 @@
"supertest": "^3.0.0"
},
"devDependencies": {
"@google-cloud/functions-emulator": "^1.0.0-alpha.29",
"@google-cloud/functions-emulator": "^1.0.0-beta.4",
"@google-cloud/nodejs-repo-tools": "2.2.1",
"ava": "0.25.0",
"proxyquire": "2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions functions/gcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Functions for your project.

1. Deploy the "wordCount" function with an HTTP trigger:

gcloud beta functions deploy wordCount --trigger-http
gcloud functions deploy wordCount --trigger-http

1. Call the "wordCount" function using the sample file:

gcloud beta functions call wordCount --data '{"bucket":"YOUR_BUCKET_NAME","file":"sample.txt"}'
gcloud functions call wordCount --data '{"bucket":"YOUR_BUCKET_NAME","file":"sample.txt"}'

* Replace `YOUR_BUCKET_NAME` with the name of your Cloud Storage Bucket.

Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"lint": "repo-tools lint",
"pretest": "npm run lint",
"e2e-test": "export FUNCTIONS_CMD='gcloud beta functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" ava -T 20s --verbose test/*.test.js",
"e2e-test": "export FUNCTIONS_CMD='gcloud functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" ava -T 20s --verbose test/*.test.js",
"test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && ava -T 20s --verbose -c 1 test/index.test.js test/*unit*test.js test/*integration*test.js",
"system-test": "export FUNCTIONS_CMD='functions-emulator' && sh test/updateFunctions.sh && export BASE_URL=\"http://localhost:8010/$GCLOUD_PROJECT/$GCF_REGION\" && ava -T 20s --verbose test/*.test.js"
},
Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld/test/sample.system.pubsub.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Pubsub = require(`@google-cloud/pubsub`);
const pubsub = Pubsub();

const topicName = process.env.FUNCTIONS_TOPIC;
const baseCmd = `gcloud beta functions`;
const baseCmd = `gcloud functions`;

test(`helloPubSub: should print a name`, async (t) => {
t.plan(1);
Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld/test/sample.system.storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const gcsFileName = `test-${uuid.v4()}.txt`;

const bucketName = process.env.BUCKET_NAME;
const bucket = storage.bucket(bucketName);
const baseCmd = `gcloud beta functions`;
const baseCmd = `gcloud functions`;

test.serial(`helloGCS: should print uploaded message`, async (t) => {
t.plan(1);
Expand Down
4 changes: 2 additions & 2 deletions functions/imagemagick/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Functions for your project.

1. Deploy the `blurOffensiveImages` function with a Storage trigger:

gcloud beta functions deploy blurOffensiveImages --trigger-bucket=YOUR_BUCKET_NAME
gcloud functions deploy blurOffensiveImages --trigger-bucket=YOUR_BUCKET_NAME

* Replace `YOUR_BUCKET_NAME` with the name of the Cloud Storage Bucket you created earlier.

Expand All @@ -36,7 +36,7 @@ Functions for your project.

1. Check the logs for the `blurOffensiveImages` function:

gcloud beta functions get-logs blurOffensiveImages
gcloud functions get-logs blurOffensiveImages

You should see something like this in your console:

Expand Down
6 changes: 3 additions & 3 deletions functions/pubsub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ can skip this step):

1. Deploy the `publish` function with an HTTP trigger:

gcloud beta functions deploy publish --trigger-http
gcloud functions deploy publish --trigger-http

1. Deploy the `subscribe` function with the Pub/Sub topic as a trigger:

gcloud beta functions deploy subscribe --trigger-topic YOUR_TOPIC_NAME
gcloud functions deploy subscribe --trigger-topic YOUR_TOPIC_NAME

* Replace `YOUR_TOPIC_NAME` with the name of your Pub/Sub Topic.

1. Call the `publish` function:

gcloud beta functions call publish --data '{"topic":"YOUR_TOPIC_NAME","message":"Hello World!"}'
gcloud functions call publish --data '{"topic":"YOUR_TOPIC_NAME","message":"Hello World!"}'

* Replace `YOUR_TOPIC_NAME` with the name of your Pub/Sub Topic.

Expand Down
4 changes: 2 additions & 2 deletions functions/uuid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Functions for your project.

1. Deploy the `uuid` function with an HTTP trigger:

gcloud beta functions deploy uuid --trigger-http
gcloud functions deploy uuid --trigger-http

1. Call the `uuid` function:

gcloud beta functions call uuid
gcloud functions call uuid

You should see something like this in your console:

Expand Down