Skip to content

Added support for entryPoint option, to explicitly define the exporte… #98

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions package/lib/compileFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module.exports = {
funcTemplate.properties.timeout = _.get(funcObject, 'timeout')
|| _.get(this, 'serverless.service.provider.timeout')
|| '60s';
funcTemplate.properties.entryPoint = _.get(funcObject, 'entryPoint')
|| _.get(funcTemplate, 'properties.function');
funcTemplate.properties.labels = _.assign({},
_.get(this, 'serverless.service.provider.labels') || {},
_.get(funcObject, 'labels') || {},
Expand Down
48 changes: 47 additions & 1 deletion package/lib/compileFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 1024,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -148,6 +149,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 1024,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand All @@ -165,7 +167,43 @@ describe('CompileFunctions', () => {
});
});

it('should set the timout based on the functions configuration', () => {
it('should set entryPoint based on the functions configuration', () => {
googlePackage.serverless.service.functions = {
func1: {
handler: 'func1',
entryPoint: 'entry1',
events: [
{ http: 'foo' },
],
},
};
googlePackage.serverless.service.provider.memorySize = 1024;

const compiledResources = [{
type: 'cloudfunctions.v1beta2.function',
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'entry1',
availableMemoryMb: 1024,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
httpsTrigger: {
url: 'foo',
},
labels: {},
},
}];

return googlePackage.compileFunctions().then(() => {
expect(consoleLogStub.calledOnce).toEqual(true);
expect(googlePackage.serverless.service.provider.compiledConfigurationTemplate.resources)
.toEqual(compiledResources);
});
});

it('should set the timeout based on the functions configuration', () => {
googlePackage.serverless.service.functions = {
func1: {
handler: 'func1',
Expand All @@ -182,6 +220,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '120s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -216,6 +255,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '120s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -252,6 +292,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -290,6 +331,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -332,6 +374,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -368,6 +411,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down Expand Up @@ -419,6 +463,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func1',
entryPoint: 'func1',
availableMemoryMb: 256,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand All @@ -436,6 +481,7 @@ describe('CompileFunctions', () => {
properties: {
location: 'us-central1',
function: 'func2',
entryPoint: 'func2',
availableMemoryMb: 256,
timeout: '60s',
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
Expand Down