Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
1.0.0-beta.1 (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry authored Feb 21, 2018
1 parent 9f4b0fa commit 04ec0b0
Show file tree
Hide file tree
Showing 44 changed files with 403 additions and 1,392 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
##### 1.0.0-beta.1 - 20 February 2017

###### Breaking changes
- Removed all support for gRPC.

###### Backwards compatible changes
- Added new `--event-type` and `--resource` flags to the `deploy` command.
- Added support for `generateUploadUrl`.

###### Bug fixes
- [#176](https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/176) - Wrong error message

###### Other
- Updated dependencies

##### 1.0.0-alpha.29 - 12 December 2017

###### Bug fixes
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@google-cloud/functions-emulator",
"description": "Google Cloud Functions Emulator",
"version": "1.0.0-alpha.29",
"version": "1.0.0-beta.1",
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
Expand Down Expand Up @@ -68,16 +68,14 @@
"dependencies": {
"@google-cloud/storage": "1.5.1",
"adm-zip": "0.4.7",
"ajv": "5.5.1",
"ajv": "5.5.2",
"body-parser": "1.18.2",
"cli-table2": "0.2.0",
"colors": "1.1.2",
"configstore": "3.1.1",
"express": "4.16.2",
"google-proto-files": "0.14.1",
"googleapis": "23.0.0",
"got": "8.0.1",
"grpc": "1.7.2",
"http-proxy": "1.16.2",
"lodash": "4.17.4",
"prompt": "1.0.0",
Expand All @@ -99,7 +97,7 @@
"proxyquire": "1.8.0",
"semistandard": "11.0.0",
"semistandard-format": "3.0.0",
"sinon": "4.1.2",
"sinon": "4.1.3",
"supertest": "3.0.0"
}
}
3 changes: 3 additions & 0 deletions scripts/upgrade-warning
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'use strict';

const message = `
If you're using the Emulator via the Firebase CLI, you can
disregard this message.
If you're upgrading @google-cloud/functions-emulator, these
are the recommended upgrade steps:
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exports.builder = (yargs) => {
requiresArg: true,
type: 'string'
}
}, _.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service'])))
}, _.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service'])))
.epilogue(`See ${'https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Calling-functions'.bold}`);

EXAMPLES['call'].forEach((e) => yargs.example(e[0], e[1]));
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.description = DESCRIPTION;
exports.builder = (yargs) => {
yargs
.usage(USAGE)
.options(_.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service']));
.options(_.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service']));

EXAMPLES['clear'].forEach((e) => yargs.example(e[0], e[1]));
};
Expand Down
26 changes: 18 additions & 8 deletions src/cli/commands/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,56 @@ const OPTIONS = require('../../../options');

const EPILOGUE = `Available configuration options:
${'CLI'.underline} - Manages the Emulator.
${'CLI'.underline} - Global settings.
${'projectId'.bold}
${OPTIONS.projectId.description}
${'region'.bold}
${OPTIONS.region.description}
${'service'.bold}
${OPTIONS.service.description}
${'storage'.bold}
${OPTIONS.storage.description}
${'CLI'.underline} - Manages the Emulator.
${'timeout'.bold}
${OPTIONS.timeout.description}
${'EMULATOR'.underline} - Emulates the Cloud Functions API.
${'bindHost'.bold}
${OPTIONS.bindHost.description}
${'grpcPort'.bold}
${OPTIONS.grpcPort.description}
${'host'.bold}
${OPTIONS.host.description}
${'idlePruneInterval'.bold}
${OPTIONS.idlePruneInterval.description}
${'logFile'.bold}
${OPTIONS.logFile.description}
${'maxIdle'.bold}
${OPTIONS.maxIdle.description}
${'restPort'.bold}
${OPTIONS.restPort.description}
${'supervisorPort'.bold}
${OPTIONS.supervisorPort.description}
${'tail'.bold}
${OPTIONS.tail.description}
${'useMocks'.bold}
${OPTIONS.useMocks.description}
${'verbose'.bold}
${OPTIONS.verbose.description}
${'tail'.bold}
${OPTIONS.tail.description}
${'watch'.bold}
${OPTIONS.watch.description}
${'watchIgnore'.bold}
${OPTIONS.watchIgnore.description}
See ${'https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Configuring-the-Emulator'.bold}
`;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports.builder = (yargs) => {
requiresArg: true,
type: 'number'
}
}, _.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service'])))
}, _.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service'])))
.epilogue(`See ${'https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Debugging-functions'.bold}`);

EXAMPLES['debug'].forEach((e) => yargs.example(e[0], e[1]));
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports.description = DESCRIPTION;
exports.builder = (yargs) => {
yargs
.usage(USAGE)
.options(_.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service']));
.options(_.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service']));

EXAMPLES['delete'].forEach((e) => yargs.example(e[0]));
};
Expand Down
58 changes: 34 additions & 24 deletions src/cli/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,10 @@ exports.description = DESCRIPTION;
exports.builder = (yargs) => {
yargs
.usage(USAGE)
.options(_.merge(_.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service']), {
'local-path': {
alias: 'l',
description: `Path to local directory with source code. ${'Default:'.bold} ${process.cwd().green} (the current working directory)`,
requiresArg: true,
type: 'string'
},
'trigger-bucket': {
alias: 'B',
description: `Google Cloud Storage bucket name. Every change in files in this bucket will trigger function execution. Short for --trigger-provider=cloud.storage --trigger-event=object.change --trigger-resource=<bucket>.`,
.options(_.merge(_.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service']), {
'source': {
alias: 'S',
description: `Location of source code to deploy. ${'Default:'.bold} ${process.cwd().green} (the current working directory). Location of the source can be one of the following: Source code in Google Cloud Storage or a local filesystem path. The value of the flag will be interpreted as a Cloud Storage location, if it starts with ${'gs://'.bold}. Otherwise, it will be interpreted as the local filesystem path.`,
requiresArg: true,
type: 'string'
},
Expand All @@ -62,11 +56,17 @@ exports.builder = (yargs) => {
description: `Every HTTP request to the function's endpoint will trigger function execution. Result of the function execution will be returned in response body.`,
requiresArg: false
},
'trigger-topic': {
alias: 'T',
description: `Name of Pub/Sub topic. Every message published in this topic will trigger function execution with message contents passed as input data. Short for --trigger-provider=cloud.pubsub --trigger-event=topic.publish --trigger-resource=<topic>.`,
'event-type': {
description: `The service that is sending an event and the kind of event that was fired. Must be of the form ${'PROVIDER.EVENT_TYPE'.bold}. ${'PROVIDER'.bold} must be one of: cloud.pubsub, cloud.storage, google.firebase.auth, google.firebase.database, google.firebase.analytics. ${'EVENT_TYPE'.bold} must be one of: topic.publish, object.change, user.create, user.delete, ref.write, ref.create, ref.update, ref.delete, event.log.`,
requiresArg: true,
type: 'string'
type: 'string',
required: false
},
'resource': {
description: `Which instance of the source's service should send events. E.g. for Pub/Sub this would be a Pub/Sub topic at 'projects/*/topics/*'. For Google Cloud Storage this would be a bucket at 'projects/*/buckets/*'. For any source that only supports one instance per-project, this should be the name of the project ('projects/*')`,
requiresArg: true,
type: 'string',
required: false
},
'entry-point': {
alias: 'e',
Expand All @@ -81,22 +81,34 @@ exports.builder = (yargs) => {
requiresArg: true,
type: 'string'
},
'trigger-bucket': {
alias: 'B',
description: `${'LEGACY'.yellow}: Google Cloud Storage bucket name. Every change in files in this bucket will trigger function execution. Short for --trigger-provider=cloud.storage --trigger-event=object.change --trigger-resource=<bucket>.`,
requiresArg: true,
type: 'string'
},
'trigger-topic': {
alias: 'T',
description: `${'LEGACY'.yellow}: Name of Pub/Sub topic. Every message published in this topic will trigger function execution with message contents passed as input data. Short for --trigger-provider=cloud.pubsub --trigger-event=topic.publish --trigger-resource=<topic>.`,
requiresArg: true,
type: 'string'
},
'trigger-event': {
choices: ['topic.publish', 'object.change', 'user.create', 'user.delete', 'ref.write', 'ref.create', 'ref.update', 'ref.delete', 'event.log', undefined],
description: 'Specifies which action should trigger the function. If omitted, a default EVENT_TYPE for --trigger-provider will be used if it is available. For a list of acceptable values, call functions event_types list. EVENT_TYPE must be one of: topic.publish, object.change, user.create, user.delete, ref.write, ref.create, ref.update, ref.delete, event.log.',
description: `${'LEGACY'.yellow}: Specifies which action should trigger the function. If omitted, a default EVENT_TYPE for --trigger-provider will be used if it is available. For a list of acceptable values, call functions event_types list. EVENT_TYPE must be one of: topic.publish, object.change, user.create, user.delete, ref.write, ref.create, ref.update, ref.delete, event.log.`,
requiresArg: true,
type: 'string',
required: false
},
'trigger-provider': {
choices: ['cloud.pubsub', 'cloud.storage', 'google.firebase.auth', 'google.firebase.database', 'google.firebase.analytics', undefined],
description: 'Trigger this function in response to an event in another service. For a list of acceptable values, call gcloud functions event-types list. PROVIDER must be one of: cloud.pubsub, cloud.storage, google.firebase.auth, google.firebase.database, google.firebase.analytics',
description: `${'LEGACY'.yellow}: Trigger this function in response to an event in another service. For a list of acceptable values, call gcloud functions event-types list. PROVIDER must be one of: cloud.pubsub, cloud.storage, google.firebase.auth, google.firebase.database, google.firebase.analytics`,
requiresArg: true,
type: 'string',
required: false
},
'trigger-resource': {
description: 'Specifies which resource from --trigger-provider is being observed. E.g. if --trigger-provider is cloud.storage, --trigger-resource must be a bucket name. For a list of expected resources, call functions event_types list.',
description: `${'LEGACY'.yellow}: Specifies which resource from --trigger-provider is being observed. E.g. if --trigger-provider is cloud.storage, --trigger-resource must be a bucket name. For a list of expected resources, call functions event_types list.`,
requiresArg: true,
type: 'string',
required: false
Expand All @@ -113,16 +125,14 @@ exports.builder = (yargs) => {
EXAMPLES['deploy'].forEach((e) => yargs.example(e[0]));
};
exports.handler = (opts) => {
opts.localPath || (opts.localPath = process.cwd());
opts.source || (opts.source = process.cwd());

if (opts.triggerBucket) {
opts.triggerProvider = 'cloud.storage';
opts.triggerEvent = 'object.change';
opts.triggerResource = opts.triggerBucket;
opts.eventType = 'google.storage.object.finalize';
opts.resource = opts.triggerBucket;
} else if (opts.triggerTopic) {
opts.triggerProvider = 'cloud.pubsub';
opts.triggerEvent = 'topic.publish';
opts.triggerResource = opts.triggerTopic;
opts.eventType = 'google.pubsub.topic.publish';
opts.resource = opts.triggerTopic;
}

const controller = new Controller(opts);
Expand Down
8 changes: 5 additions & 3 deletions src/cli/commands/describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const _ = require('lodash');
const Table = require('cli-table2');

const Controller = require('../controller');
const { CloudFunction } = require('../../model');
const EXAMPLES = require('../examples');
const OPTIONS = require('../../options');

Expand All @@ -44,7 +45,7 @@ exports.description = DESCRIPTION;
exports.builder = (yargs) => {
yargs
.usage(USAGE)
.options(_.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service']));
.options(_.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service']));

EXAMPLES['describe'].forEach((e) => yargs.example(e[0], e[1]));
};
Expand Down Expand Up @@ -82,8 +83,9 @@ exports.handler = (opts) => {
} else {
table.push(['Timeout', `60 seconds`]);
}
if (cloudfunction.serviceAccount) {
table.push(['Local path', cloudfunction.serviceAccount]);
const localdir = CloudFunction.getLocaldir(cloudfunction);
if (CloudFunction.getLocaldir(cloudfunction)) {
table.push(['Local path', localdir]);
}
table.push(['Archive', cloudfunction.sourceArchiveUrl]);

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports.builder = (yargs) => {
requiresArg: true,
type: 'number'
}
}, _.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service'])))
}, _.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service'])))
.epilogue(`See ${'https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Debugging-functions'.bold}`);

EXAMPLES['inspect'].forEach((e) => yargs.example(e[0], e[1]));
Expand Down
5 changes: 3 additions & 2 deletions src/cli/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const fs = require('fs');
const Table = require('cli-table2');

const Controller = require('../controller');
const { CloudFunction } = require('../../model');
const OPTIONS = require('../../options');

const COMMAND = `functions list ${'[options]'.yellow}`;
Expand Down Expand Up @@ -62,7 +63,7 @@ exports.description = DESCRIPTION;
exports.builder = (yargs) => {
yargs
.usage(USAGE)
.options(_.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service']));
.options(_.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service']));
};
exports.handler = (opts) => {
const controller = new Controller(opts);
Expand Down Expand Up @@ -92,7 +93,7 @@ exports.handler = (opts) => {
if (!resource) {
resource = 'None';
}
if (pathExists(cloudfunction.serviceAccount)) {
if (pathExists(CloudFunction.getLocaldir(cloudfunction))) {
table.push([
CloudFunctionStatus[cloudfunction.status] || CloudFunctionStatus['0'],
cloudfunction.shortName,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports.description = DESCRIPTION;
exports.builder = (yargs) => {
yargs
.usage(USAGE)
.options(_.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service']));
.options(_.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service']));
};
exports.handler = (opts) => {
const controller = new Controller(opts);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports.builder = (yargs) => {
description: `If ${'true'.bold}, keep the function's debugging settings, if any.`,
type: 'boolean'
}
}, _.pick(OPTIONS, ['grpcPort', 'host', 'projectId', 'region', 'restPort', 'service'])))
}, _.pick(OPTIONS, ['host', 'projectId', 'region', 'restPort', 'service'])))
.epilogue(`See ${'https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Debugging-functions'.bold}`);

EXAMPLES['reset'].forEach((e) => yargs.example(e[0], e[1]));
Expand Down
1 change: 0 additions & 1 deletion src/cli/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Description:

exports.options = [
'bindHost',
'grpcPort',
'host',
'idlePruneInterval',
'logFile',
Expand Down
1 change: 0 additions & 1 deletion src/cli/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ exports.handler = (opts) => {
table.push(['Worker PIDs', workerPids.join(', ')]);
}
table.push(['REST Service', `http://${config.host}:${config.restPort}/`]);
table.push(['gRPC Service', `http://${config.host}:${config.grpcPort}/`]);
table.push(['HTTP Triggers', `http://${config.host}:${config.supervisorPort}/${config.projectId}/${config.region}/:function`]);
table.push(['Log file', config.logFile]);
table.push(['Emulator Version', config.version]);
Expand Down
Loading

0 comments on commit 04ec0b0

Please sign in to comment.