Skip to content

Instantly share code, notes, and snippets.

@TobiG77
Last active July 29, 2020 20:47
Show Gist options
  • Save TobiG77/ef031b645183b821081a378866b03419 to your computer and use it in GitHub Desktop.
Save TobiG77/ef031b645183b821081a378866b03419 to your computer and use it in GitHub Desktop.
validate payload with cue vet
payload.json:
{
"resource_id": "/subscription/.../...",
"version": "2020-07-21",
"type": "Linux",
"properties": {
"custom_log_files": [
"/var/log/dmesg",
"/var/log/messages"
]
}
}
rules.cue:
#LoggingLinuxVM: {
resource_id: #NonEmptyString
version: =~"2020-07-21"
type: =~"Linux"
properties: #LoggingPropertiesLinuxVM
}
#LoggingPropertiesLinuxVM: {
CustomLogFiles: [...#NonEmptyString]
}
#NonEmptyString: string & !=""
$: cue vet payload.json rules.cue ; echo $?
# passes for invalid payloads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment