Skip to content

Issue:414 - Fix Individual deploy of functions #428

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 7 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ class ServerlessPythonRequirements {
}

get targetFuncs() {
let inputOpt = this.serverless.processedInput.options;
return inputOpt.function
? [inputOpt.functionObj]
: values(this.serverless.service.functions);
const inputOpt = this.serverless.processedInput.options;
if (inputOpt.function){
let singleFunction = inputOpt.functionObj;
// set the function name so we can use it later for individual deploys of functions
singleFunction.function = inputOpt.function
return [singleFunction];
} else {
return values(this.serverless.service.functions)
}

}

/**
Expand Down Expand Up @@ -143,6 +149,7 @@ class ServerlessPythonRequirements {
if (!args[1].functionObj || !args[1].functionObj.runtime) {
return true;
}

return args[1].functionObj.runtime.startsWith('python');
};

Expand Down Expand Up @@ -172,8 +179,9 @@ class ServerlessPythonRequirements {
.then(layerRequirements)
.then(() =>
injectAllRequirements.bind(this)(
arguments[1].functionObj &&
arguments[1].functionObj.package.artifact
arguments[1].functionObj &&
arguments[1].functionObj.package &&
arguments[1].functionObj.package.artifact
)
);
};
Expand Down
28 changes: 27 additions & 1 deletion lib/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,21 @@ function injectAllRequirements(funcArtifact) {
})
.map(func => {
if (func.module !== '.') {
const artifact = func.package ? func.package.artifact : funcArtifact;

let assumedFuncArtifact;

if (!funcArtifact){
assumedFuncArtifact = path.join(
'.serverless',
`${func.function}.zip`
)
}

if (!(func.package && func.package.artifact)){
func.package = {'artifact': assumedFuncArtifact }
}

const artifact = func.package ? func.package.artifact : assumedFuncArtifact;
const newArtifact = path.join(
'.serverless',
`${func.module}-${func.name}.zip`
Expand All @@ -119,6 +133,18 @@ function injectAllRequirements(funcArtifact) {
() => func
);
} else {
let assumedFuncArtifact;
if (!funcArtifact){
assumedFuncArtifact = path.join(
'.serverless',
`${func.function}.zip`
)
}

if (!(func.package && func.package.artifact)){
func.package = {'artifact': assumedFuncArtifact }
}

return func;
}
})
Expand Down