Commit 3f9da8e
authored
Adapt agama config to return error code when no validates (#3304)
## Problem
When running `agama config load`, `agama config generate` or `agama
config validate` it always returns `0` even when the profile is invalid.
- [*bsc#1256951*](https://bugzilla.suse.com/show_bug.cgi?id=1256951)
## Solution
Return Err (`return code 1`) in case of invalid profile.
## Testing
- *Tested manually*
### agama config generate
```bash
suse@vikingo-laptop:~$ ~/agama_not_fix/agama config generate profile.jsonnet || echo $?
{
"hostname": {
"static": "Agama"
},
"product": {
"ID": "Tumbleweed"
},
"scripts": {
"post": [
{
"chroot": true,
"content": "#!/usr/bin/env bash\necho 'PermitRootLogin yes' > /etc/ssh/sshd_config.d/root.conf\nsystemctl enable sshd\n",
"name": "enable root login"
}
]
}
}
✗ The profile is not valid. Please, check the following errors:
* Additional properties are not allowed ('ID' was unexpected). /product
* "id" is a required property. /product
suse@vikingo-laptop:~$ ~/agama_fix/agama config generate profile.jsonnet || echo $?
{
"hostname": {
"static": "Agama"
},
"product": {
"ID": "Tumbleweed"
},
"scripts": {
"post": [
{
"chroot": true,
"content": "#!/usr/bin/env bash\necho 'PermitRootLogin yes' > /etc/ssh/sshd_config.d/root.conf\nsystemctl enable sshd\n",
"name": "enable root login"
}
]
}
}
✗ The profile is not valid. Please, check the following errors:
* Additional properties are not allowed ('ID' was unexpected). /product
* "id" is a required property. /product
The profile is not valid
1
```
### agama config load
```bash
suse@vikingo-laptop:~$ ~/agama_not_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:
* Additional properties are not allowed ('ID' was unexpected). /product
* "id" is a required property. /product
suse@vikingo-laptop:~$ ~/agama_fix/agama config load profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:
* Additional properties are not allowed ('ID' was unexpected). /product
* "id" is a required property. /product
The profile is not valid
1
```
### agama config validate
```bash
suse@vikingo-laptop:~$ ~/agama_not_fix/agama config validate profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:
* Additional properties are not allowed ('ID' was unexpected). /product
* "id" is a required property. /product
suse@vikingo-laptop:~$ ~/agama_fix/agama config validate profile.json || echo $?
✗ The profile is not valid. Please, check the following errors:
* Additional properties are not allowed ('ID' was unexpected). /product
* "id" is a required property. /product
The profile is not valid
1
```2 files changed
+25
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
| |||
293 | 297 | | |
294 | 298 | | |
295 | 299 | | |
296 | | - | |
| 300 | + | |
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
| |||
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
| |||
364 | 367 | | |
365 | 368 | | |
366 | 369 | | |
367 | | - | |
368 | 370 | | |
369 | 371 | | |
370 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
371 | 378 | | |
372 | 379 | | |
373 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| |||
0 commit comments