Skip to content

Commit

Permalink
Merge pull request #77 from ksimon1/validator-non-fatal-warning
Browse files Browse the repository at this point in the history
added description of justWarning flag into validation documentation
  • Loading branch information
ffromani authored Aug 7, 2019
2 parents 1655c8f + 77419d3 commit 550e155
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions templates/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ validations: |
"path”: "jsonpath::.some.json.path[*].leaf",
"rule”: "integer",
"message”: ".some.json.path[*].leaf must exists",
"min”: 1
"min”: 1,
"justWarning": true
},
{
"name": "validation-rule-02",
Expand Down Expand Up @@ -148,6 +149,7 @@ kind: Template
* `valid`: the rule must be *ignored* if the jsonpath given as value doesn't exist.
*PLEASE NOTE* that even if values of this key are required to be JSONPaths, you still need to use the `jsonpath::` prefix
as explained above.
* `justWarning`: violating rule with justWarning field set will emit a warning only instead of failing the validation.

### Rule arguments (optional keys)

Expand Down Expand Up @@ -258,6 +260,28 @@ kind: Template
]
```

### justWarning:
The validation normally fails when a rule is not satisfied. The behaviour can be changed per rule by setting the `justWarning` property of the rule. The validator will then emit a warning only and the overall result of the validation will be unaffected by the rule.
Example:
```yaml
apiVersion: v1
kind: Template
metadata:
name: windows-10
annotations:
validations: |
[
{
"name": "supported-bus",
"valid": "jsonpath::.spec.domain.devices.disks[*].disk",
"path": "jsonpath::.spec.domain.devices.disks[*].disk.bus",
"rule": "enum",
"message": "the disk bus type must be one of the supported values",
"values": ["virtio", "scsi"],
"justWarning": true
}
]
```

### Examples

Expand Down Expand Up @@ -296,7 +320,8 @@ kind: Template
"path": "jsonpath::.spec.domain.devices.disks[*].disk.bus",
"rule": "enum",
"message": "the disk bus type must be one of the supported values",
"values": ["virtio", "scsi"]
"values": ["virtio", "scsi"],
"justWarning": true
}
]
```
Expand Down

0 comments on commit 550e155

Please sign in to comment.