mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Move reserved variable generation out of the endpoint builder and into the Endpoint class. Add an equivalent implementation for Event. Add the new reserved variables to sUtils.populate.
This commit is contained in:
parent
a38621ba8a
commit
a8096bc304
@ -46,7 +46,10 @@ module.exports = function(S) {
|
||||
}
|
||||
|
||||
toObject() {
|
||||
return S.utils.exportObject(_.cloneDeep(this));
|
||||
let clone = _.cloneDeep(this);
|
||||
clone.endpointName = this.getName();
|
||||
clone.name = this.getFunction().getName(); // TODO Remove, legacy tight coupling of functions with endpoints. Make supplying this contingent on coupling?
|
||||
return S.utils.exportObject(clone);
|
||||
}
|
||||
|
||||
toObjectPopulated(options) {
|
||||
@ -90,4 +93,4 @@ module.exports = function(S) {
|
||||
|
||||
return Endpoint;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
11
lib/Event.js
11
lib/Event.js
@ -32,7 +32,10 @@ module.exports = function(S) {
|
||||
}
|
||||
|
||||
toObject() {
|
||||
return S.utils.exportObject(_.cloneDeep(this));
|
||||
let clone = _.cloneDeep(this);
|
||||
clone.eventName = this.getName();
|
||||
clone.name = this.getFunction().getName(); // TODO Remove, legacy tight coupling of functions with endpoints. Make supplying this contingent on coupling?
|
||||
return S.utils.exportObject(clone);
|
||||
}
|
||||
|
||||
toObjectPopulated(options) {
|
||||
@ -57,6 +60,10 @@ module.exports = function(S) {
|
||||
return _.assign(this, data);
|
||||
}
|
||||
|
||||
getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
getProject() {
|
||||
return S.getProject();
|
||||
}
|
||||
@ -73,4 +80,4 @@ module.exports = function(S) {
|
||||
|
||||
return Event;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@ -139,9 +139,6 @@ module.exports = function(S) {
|
||||
|
||||
if (!_this.endpoint) BbPromise.reject(new SError(`Endpoint could not be found: ${_this.evt.options.endpointPath}#${_this.evt.options.endpointMethod}`));
|
||||
|
||||
// Set name variable in endpoint
|
||||
_this.endpoint.name = _this.endpoint.getFunction().name; // the name of the function is a reserved variable that may be used to populate a value within the endpoint
|
||||
|
||||
// Set function name
|
||||
_this.functionName = _this.endpoint.getFunction().getDeployedName({
|
||||
stage: _this.evt.options.stage,
|
||||
|
||||
@ -336,7 +336,10 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Reserved Variables
|
||||
if (variableName === 'name' && data.name) value = data.name;
|
||||
if (variableName === 'name' && data.name) value = data.name; // TODO Remove legacy variable that is semantically the functionName?
|
||||
if (variableName === 'functionName' && data.functionName) value = data.functionName;
|
||||
if (variableName === 'endpointName' && data.endpointName) value = data.endpointName;
|
||||
if (variableName === 'eventName' && data.eventName) value = data.eventName;
|
||||
|
||||
// Populate
|
||||
if (!value && !value !== "") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user