From 04ecc7481eeb7f05620a0fe03e170280eaec0bd8 Mon Sep 17 00:00:00 2001 From: Xin Yi Date: Tue, 12 Mar 2019 19:07:49 -0700 Subject: [PATCH] Support gcloud serviceAccount --- package-lock.json | 7 +++++-- package/lib/compileFunctions.js | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 288bfd8..0bdb1ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1302,7 +1302,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "contains-path": { "version": "0.1.0", @@ -4615,6 +4616,7 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4624,7 +4626,8 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, diff --git a/package/lib/compileFunctions.js b/package/lib/compileFunctions.js index e667347..db59bbb 100644 --- a/package/lib/compileFunctions.js +++ b/package/lib/compileFunctions.js @@ -43,11 +43,18 @@ module.exports = { funcTemplate.properties.timeout = _.get(funcObject, 'timeout') || _.get(this, 'serverless.service.provider.timeout') || '60s'; + funcTemplate.properties.serviceAccount = _.get(funcObject, 'serviceAccount') + || _.get(this, 'serverless.service.provider.serviceAccount') + || ''; funcTemplate.properties.environmentVariables = _.merge( _.get(this, 'serverless.service.provider.environment'), funcObject.environment // eslint-disable-line comma-dangle ); + if (!funcTemplate.properties.serviceAccount) { + delete funcTemplate.properties.serviceAccount; + } + if (!_.size(funcTemplate.properties.environmentVariables)) { delete funcTemplate.properties.environmentVariables; }