Skip to content

Commit

Permalink
Skip container function with uri defined
Browse files Browse the repository at this point in the history
It looks like a container function defined with a `uri` shouldn't be handled by the plugin because the image won't be handled by Serverless itself.
So we just skip the function in that case.
  • Loading branch information
j0k3r committed Jun 10, 2021
1 parent 033f504 commit 4f0f8ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,15 @@ function splitLines(str) {

function getAllNodeFunctions() {
const functions = this.serverless.service.getAllFunctions();

return _.filter(functions, funcName => {
const func = this.serverless.service.getFunction(funcName);

// if `uri` is provided, it means the image isn't built by Serverless so we shouldn't take care of it
if (func.image && func.image.uri) {
return false;
}

const runtime = func.runtime || this.serverless.service.provider.runtime || 'nodejs';
return runtime.match(/node/);
});
Expand Down
17 changes: 16 additions & 1 deletion tests/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ describe('validate', () => {
},
dockerfunc: {
image: {
name: 'some-image-uri',
name: 'some-docker-image',
command: ['com.serverless.Handler']
},
events: [
Expand All @@ -518,6 +518,21 @@ describe('validate', () => {
}
}
]
},
dockerfuncuri: {
image: {
name: 'some-image-with-uri',
uri: 'http://hub.dock.er/image',
command: ['method.lambda']
},
events: [
{
http: {
method: 'POST',
path: 'mydockerfuncpath'
}
}
]
}
};

Expand Down

0 comments on commit 4f0f8ff

Please sign in to comment.