-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "structured data" resource #981
Comments
Can you provide an example json and checks you're making? Goss has a gjson matcher, which may meet your needs. You can use it against the stdout of a command. |
I was not aware of gjson, looks incredible @aelsabbahy. json sample{
"model": {
"name": "welcome-k8s"
},
"applications": {
"am": {
"charm": "alertmanager-k8s",
"base": {
"name": "ubuntu",
"channel": "20.04"
},
"relations": {
"alerting": [
{
"related-application": "prom",
"interface": "alertmanager_dispatch",
"scope": "global"
}
],
"replicas": [
{
"related-application": "am",
"interface": "alertmanager_replica",
"scope": "global"
}
]
},
"version": "0.27.0"
},
"prom": {
"charm": "prometheus-k8s",
"base": {
"name": "ubuntu",
"channel": "20.04"
},
"relations": {
"alertmanager": [
{
"related-application": "am",
"interface": "alertmanager_dispatch",
"scope": "global"
}
],
"prometheus-peers": [
{
"related-application": "prom",
"interface": "prometheus_peers",
"scope": "global"
}
]
},
"version": "2.52.0"
}
}
}
} I tried to run the following: command:
app-names:
exec: juju status --format=json
exit-status: 0
stdout:
gjson:
applications:
and:
- {have-key: "prom"}
- {have-key: "am"}
application.prom.relations:
and:
- {have-key: "alertmanager"} But got a nil pointer deref.
Likely I got the syntax wrong? |
Oops, a typo on my part -application.prom.relations:
+applications.prom.relations: This works fine: command:
app-names:
exec: juju status --format=json
exit-status: 0
stdout:
gjson:
applications:
and:
- {have-key: "prom"}
- {have-key: "am"}
applications.prom.relations:
and:
- {have-key: "alertmanager"} |
Filed #982 with a minimal repro. |
Describe the feature:
Server validation often involves structured data, such as json/yaml/toml. Being able to assert against objects inside some structured data could obviate the need for bespoke goss resources.
Describe the solution you'd like
A general purpose resource for poking into structured data and making exact/contains assertions. For example:
Describe alternatives you've considered
While we can certainly use the
command
resource for those checks, on a larger scale it may result in checks that are not maintainable.The text was updated successfully, but these errors were encountered: