Skip to content

Commit fc1dbe2

Browse files
authored
fix: Revert breaking switch from v1 beta to v1 CloudFunctions (#207)
This reverts commit 59fe8ce.
1 parent 6d2cff5 commit fc1dbe2

File tree

4 files changed

+58
-103
lines changed

4 files changed

+58
-103
lines changed

info/lib/displayServiceInfo.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
};
3838

3939
_.forEach(resources.resources, resource => {
40-
if (resource.type === 'gcp-types/cloudfunctions-v1:projects.locations.functions') {
40+
if (resource.type === 'cloudfunctions.v1beta2.function') {
4141
const serviceFuncName = getFunctionNameInService(
4242
resource.name,
4343
this.serverless.service.service,
@@ -53,7 +53,7 @@ module.exports = {
5353
const region = this.options.region;
5454
const project = this.serverless.service.provider.project;
5555
const baseUrl = `https://${region}-${project}.cloudfunctions.net`;
56-
const path = serviceFunc.name; // NOTE this might change
56+
const path = serviceFunc.handler; // NOTE this might change
5757
funcResource = `${baseUrl}/${path}`;
5858
}
5959

info/lib/displayServiceInfo.test.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,8 @@ describe('DisplayServiceInfo', () => {
9696
const resources = {
9797
resources: [
9898
{ type: 'resource.which.should.be.filterered', name: 'someResource' },
99-
{
100-
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions',
101-
name: 'my-service-dev-func1',
102-
},
103-
{
104-
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions',
105-
name: 'my-service-dev-func2',
106-
},
99+
{ type: 'cloudfunctions.v1beta2.function', name: 'my-service-dev-func1' },
100+
{ type: 'cloudfunctions.v1beta2.function', name: 'my-service-dev-func2' },
107101
],
108102
};
109103

@@ -116,7 +110,7 @@ describe('DisplayServiceInfo', () => {
116110
functions: [
117111
{
118112
name: 'func1',
119-
resource: 'https://us-central1-my-project.cloudfunctions.net/my-service-dev-func1',
113+
resource: 'https://us-central1-my-project.cloudfunctions.net/handler',
120114
},
121115
{
122116
name: 'func2',
@@ -173,7 +167,7 @@ describe('DisplayServiceInfo', () => {
173167
functions: [
174168
{
175169
name: 'func1',
176-
resource: 'https://us-central1-my-project.cloudfunctions.net/my-service-dev-func1',
170+
resource: 'https://us-central1-my-project.cloudfunctions.net/handler',
177171
},
178172
{
179173
name: 'func2',
@@ -194,8 +188,7 @@ describe('DisplayServiceInfo', () => {
194188

195189
expectedOutput += `${chalk.yellow.underline('Deployed functions')}\n`;
196190
expectedOutput += `${chalk.yellow('func1')}\n`;
197-
expectedOutput +=
198-
' https://us-central1-my-project.cloudfunctions.net/my-service-dev-func1\n';
191+
expectedOutput += ' https://us-central1-my-project.cloudfunctions.net/handler\n';
199192
expectedOutput += `${chalk.yellow('func2')}\n`;
200193
expectedOutput += ' projects/*/topics/my-test-topic\n';
201194

package/lib/compileFunctions.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = {
1111
compileFunctions() {
1212
const artifactFilePath = this.serverless.service.package.artifact;
1313
const fileName = artifactFilePath.split(path.sep).pop();
14-
const projectName = _.get(this, 'serverless.service.provider.project');
1514

1615
this.serverless.service.package.artifactFilePath = `${this.serverless.service.package.artifactDirectoryName}/${fileName}`;
1716

@@ -26,7 +25,6 @@ module.exports = {
2625

2726
const funcTemplate = getFunctionTemplate(
2827
funcObject,
29-
projectName,
3028
this.serverless.service.provider.region,
3129
`gs://${this.serverless.service.provider.deploymentBucketName}/${this.serverless.service.package.artifactFilePath}`
3230
);
@@ -152,18 +150,17 @@ const validateVpcConnectorProperty = (funcObject, functionName) => {
152150
}
153151
};
154152

155-
const getFunctionTemplate = (funcObject, projectName, region, sourceArchiveUrl) => {
153+
const getFunctionTemplate = (funcObject, region, sourceArchiveUrl) => {
156154
//eslint-disable-line
157155
return {
158-
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions',
156+
type: 'cloudfunctions.v1beta2.function',
159157
name: funcObject.name,
160158
properties: {
161-
parent: `projects/${projectName}/locations/${region}`,
159+
location: region,
162160
availableMemoryMb: 256,
163161
runtime: 'nodejs8',
164162
timeout: '60s',
165-
entryPoint: funcObject.handler,
166-
function: funcObject.name,
163+
function: funcObject.handler,
167164
sourceArchiveUrl,
168165
},
169166
};

0 commit comments

Comments
 (0)