-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathconstraints.yaml
43 lines (33 loc) · 1.09 KB
/
constraints.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
tosca_definitions_version: tosca_simple_yaml_1_3
# To apply the constraints run:
# puccini-tosca compile --coerce examples/javascript/constraints.yaml
# Also see: functions.yaml
metadata:
template_name: JavaScript Constraints Example
template_author: Puccini
# Use metadata prefixed with "puccini.scriptlet:tosca.constraint."
# Your scriptlet must export a function named "validate"
# The first argument is always the value to validate
# Return "true" if valid
# If invalid, can return "false" or a string explaining the reason it is invalid
# (Note that this is different from "throw", which should be used for errors)
puccini.scriptlet:tosca.constraint.multiple_of: |-
exports.validate = function(value, multiple) {
if (arguments.length !== 2)
throw 'must have 1 argument';
return (value / multiple) % 1 == 0;
};
node_types:
Rack:
properties:
slots:
type: integer
constraints:
# Our custom constraint
- multiple_of: 4
topology_template:
node_templates:
rack:
type: Rack
properties:
slots: 8