Skip to content

Commit

Permalink
fix: add kokoro config for composer-storage-trigger (#1321)
Browse files Browse the repository at this point in the history
* Upgrade composer sample to Node 8

* fix: Add CI test config
  • Loading branch information
leahecole authored May 29, 2019
1 parent 359ddc5 commit c00c94f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions .kokoro/functions/composer-storage-trigger.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Set the folder in which the tests are run
env_vars: {
key: "PROJECT"
value: "functions/composer-storage-trigger"
}

# Tell the trampoline which build file to use.
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-docs-samples/.kokoro/build.sh"
}
12 changes: 6 additions & 6 deletions functions/composer-storage-trigger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const FormData = require('form-data');
* and
* https://cloud.google.com/iap/docs/authentication-howto
*
* @param {!Object} event The Cloud Functions event.
* @param {!Object} data The Cloud Functions event data.
* @returns {Promise}
*/
exports.triggerDag = async event => {
exports.triggerDag = async data => {
// Fill in your Composer environment information here.

// The project that holds your function
Expand All @@ -47,7 +47,7 @@ exports.triggerDag = async event => {
// Other constants
const WEBSERVER_URL = `https://${WEBSERVER_ID}.appspot.com/api/experimental/dags/${DAG_NAME}/dag_runs`;
const USER_AGENT = 'gcf-event-trigger';
const BODY = {conf: JSON.stringify(event.data)};
const BODY = {conf: JSON.stringify(data)};

// Make the request
try {
Expand Down Expand Up @@ -86,7 +86,7 @@ const authorizeIap = async (clientId, projectId, userAgent) => {
headers: {'User-Agent': userAgent, 'Metadata-Flavor': 'Google'},
}
);
const tokenResponse = res.json();
const tokenResponse = await res.json();
if (tokenResponse.error) {
return Promise.reject(tokenResponse.error);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ const authorizeIap = async (clientId, projectId, userAgent) => {
},
}
);
const blobJson = blob.json();
const blobJson = await blob.json();
if (blobJson.error) {
return Promise.reject(blobJson.error);
}
Expand All @@ -132,7 +132,7 @@ const authorizeIap = async (clientId, projectId, userAgent) => {
method: 'POST',
body: form,
});
const tokenJson = token.json();
const tokenJson = await token.json();
if (tokenJson.error) {
return Promise.reject(tokenJson.error);
}
Expand Down

0 comments on commit c00c94f

Please sign in to comment.