Skip to content

Commit 4f648ff

Browse files
NilayJeeltilva
Nilay
authored andcommitted
refactor: ♻️ add json schema validation for given property
1 parent ed0a7dd commit 4f648ff

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

index.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
/**
44
* Serverless Plugin to add a `RecursiveLoop` property to AWS Lambda functions.
@@ -22,6 +22,19 @@ class ServerlessRecursiveLoopPlugin {
2222
this.hooks = {
2323
"package:compileFunctions": this.addRecursiveLoopProperty.bind(this),
2424
};
25+
if (
26+
this.serverless.configSchemaHandler &&
27+
this.serverless.configSchemaHandler.defineFunctionProperties
28+
) {
29+
this.serverless.configSchemaHandler.defineFunctionProperties("aws", {
30+
properties: {
31+
recursiveLoop: {
32+
type: "string",
33+
enum: ["Allow", "Terminate"],
34+
},
35+
},
36+
});
37+
}
2538
}
2639

2740
/**
@@ -43,10 +56,6 @@ class ServerlessRecursiveLoopPlugin {
4356
this.provider.naming.getLambdaLogicalId(functionName)
4457
];
4558
functionResource.Properties.RecursiveLoop = recursiveLoop;
46-
} else {
47-
this.serverless.cli.log(
48-
`Invalid RecursiveLoop value in function ${functionName}. Allowed values are 'Allow' or 'Terminate'.`
49-
);
5059
}
5160
}
5261
}

0 commit comments

Comments
 (0)