Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit e7e9a6a

Browse files
committed
fix: Ignore functions defined with image
1 parent da36249 commit e7e9a6a

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ServerlessPythonRequirements {
102102
let inputOpt = this.serverless.processedInput.options;
103103
return inputOpt.function
104104
? [inputOpt.functionObj]
105-
: values(this.serverless.service.functions);
105+
: values(this.serverless.service.functions).filter((func) => !func.image);
106106
}
107107

108108
/**

test.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,8 @@ test(
15201520
{ skip: !hasPython(3.6) }
15211521
);
15221522

1523+
1524+
15231525
test(
15241526
'py3.6 can package flask with package individually & slim option',
15251527
async t => {
@@ -1769,6 +1771,40 @@ test(
17691771
{ skip: !hasPython(2.7) }
17701772
);
17711773

1774+
test(
1775+
'py2.7 can ignore functions defined with `image`',
1776+
async t => {
1777+
process.chdir('tests/base');
1778+
const path = npm(['pack', '../..']);
1779+
npm(['i', path]);
1780+
sls(['--individually=true', '--runtime=python2.7', 'package']);
1781+
1782+
t.true(
1783+
pathExistsSync('.serverless/hello.zip'),
1784+
'function hello is packaged'
1785+
);
1786+
t.true(
1787+
pathExistsSync('.serverless/hello2.zip'),
1788+
'function hello2 is packaged'
1789+
);
1790+
t.true(
1791+
pathExistsSync('.serverless/hello3.zip'),
1792+
'function hello3 is packaged'
1793+
);
1794+
t.true(
1795+
pathExistsSync('.serverless/hello4.zip'),
1796+
'function hello4 is packaged'
1797+
);
1798+
t.false(
1799+
pathExistsSync('.serverless/hello5.zip'),
1800+
'function hello5 is not packaged'
1801+
);
1802+
1803+
t.end();
1804+
},
1805+
{ skip: !hasPython(2.7) }
1806+
);
1807+
17721808
test(
17731809
'py3.6 can package only requirements of module',
17741810
async t => {
@@ -2234,3 +2270,38 @@ test(
22342270
},
22352271
{ skip: !canUseDocker() || !hasPython(3.6) || brokenOn('win32') }
22362272
);
2273+
2274+
test(
2275+
'py3.6 can ignore functions defined with `image`',
2276+
async t => {
2277+
process.chdir('tests/base');
2278+
const path = npm(['pack', '../..']);
2279+
npm(['i', path]);
2280+
sls(['--individually=true', 'package']);
2281+
2282+
2283+
t.true(
2284+
pathExistsSync('.serverless/hello.zip'),
2285+
'function hello is packaged'
2286+
);
2287+
t.true(
2288+
pathExistsSync('.serverless/hello2.zip'),
2289+
'function hello2 is packaged'
2290+
);
2291+
t.true(
2292+
pathExistsSync('.serverless/hello3.zip'),
2293+
'function hello3 is packaged'
2294+
);
2295+
t.true(
2296+
pathExistsSync('.serverless/hello4.zip'),
2297+
'function hello4 is packaged'
2298+
);
2299+
t.false(
2300+
pathExistsSync('.serverless/hello5.zip'),
2301+
'function hello5 is not packaged'
2302+
);
2303+
2304+
t.end();
2305+
},
2306+
{ skip: !hasPython(3.6) }
2307+
);

tests/base/serverless.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@ functions:
4949
package:
5050
include:
5151
- 'fn2/**'
52+
hello5:
53+
image: 000000000000.dkr.ecr.sa-east-1.amazonaws.com/test-lambda-docker@sha256:6bb600b4d6e1d7cf521097177dd0c4e9ea373edb91984a505333be8ac9455d38
54+
5255

5356

0 commit comments

Comments
 (0)