Skip to content
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

Add support for multiple runtimes in service #530

Closed
wants to merge 5 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/validate.js
Expand Up @@ -96,8 +96,11 @@ module.exports = {
_.merge(entries, entry);
} else {
_.forEach(functions, (func, index) => {
const entry = getEntryForFunction.call(this, functions[index], this.serverless.service.getFunction(func));
_.merge(entries, entry);
const functionDef = this.serverless.service.getFunction(func);
if (_.startsWith(functionDef.runtime, 'node')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the global runtime is node and the runtime is not specified per function?

const entry = getEntryForFunction.call(this, functions[index], functionDef);
_.merge(entries, entry);
}
});
}

Expand Down
31 changes: 25 additions & 6 deletions tests/validate.test.js
Expand Up @@ -407,7 +407,8 @@ describe('validate', () => {
path: 'func1path'
}
}
]
],
runtime: 'node10.x'
},
func2: {
handler: 'module2.func2handler',
Expand All @@ -422,7 +423,8 @@ describe('validate', () => {
{
nonhttp: 'non-http'
}
]
],
runtime: 'node10.x'
},
func3: {
handler: 'handlers/func3/module2.func3handler',
Expand All @@ -431,7 +433,8 @@ describe('validate', () => {
{
nonhttp: 'non-http'
}
]
],
runtime: 'node10.x'
},
func4: {
handler: 'handlers/module2/func3/module2.func3handler',
Expand All @@ -440,7 +443,18 @@ describe('validate', () => {
{
nonhttp: 'non-http'
}
]
],
runtime: 'node10.x'
},
func5: {
handler: 'com.serverless.Handler',
artifact: 'target/hello-dev.jar',
events: [
{
nonhttp: 'non-http'
}
],
runtime: 'java8'
}
};

Expand All @@ -454,19 +468,24 @@ describe('validate', () => {
path: 'func1path'
}
}
]
],
runtime: 'node10.x'
}
};

it('should expose all functions if `options.function` is not defined', () => {
it('should expose all node functions if `options.function` is not defined', () => {
const testOutPath = 'test';
const testConfig = {
entry: 'test',
context: 'testcontext',
output: {
path: testOutPath
},
getFunction: func => {
return testFunctionsConfig[func];
}
};

_.set(module.serverless.service, 'custom.webpack.config', testConfig);
module.serverless.service.functions = testFunctionsConfig;
globSyncStub.callsFake(filename => [_.replace(filename, '*', 'js')]);
Expand Down