canonical / canonical/cloud-init
[enhancement]: rethink cloud-init schema cli UI
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
# Enhancement
Currently `cloud-init schema --annotate` has useful output. However, `cloud-init schema`'s output has much to be desired. Compare:
annotate
```
# cloud-init schema --system --annotate
Found cloud-config data types: user-data, network-config
1. user-data at /var/lib/cloud/instances/cb88d1af-f827-4381-bc89-4fad787bcaaf/cloud-config.txt:
#cloud-config
# from 1 files
# part-001
---
grub-dpkg: # D1
enabled: false
users:
- lock-passwd: false # D2
name: osadmin
ssh-authorized-keys: # D3
- ssh-rsa "AAAAB3NzaC1yc2EAAAADAQABAAABAQCc/K1T62elOkJKc94sWovn06RE7D274Fxx5n+eT/oClAwk7632awMtWjO+lIRpzOlEcYCR6wexlmL9mZNEFJoROMMRyCxRilNAiDKOq0X5j1HXY2ky9KjtLxo2b8yXFRBcYKK4W8aHU94NkNek81jdi9lC+L6jUrZ25d7xylqnEbd4TgrBphiowdh5B3RY+j6ePthLWWhHopRcVDgq91yYacelCCIfSDaGBya9iXPZSwoKtPin4n5PdSGmSOA3fIkvV5JjLS1QbuY5tzhXKuH9MdAqrvutF1bprs/GDf0IY8DO7DDoo8rXjhhgGtCdg1i5UitZIAM3hn/Vk5F//5eJ
JOOS8312@EB-OR6120158"
sudo:
- ALL=(ALL) NOPASSWD:ALL
...
# Deprecations: -------------
# D1: An alias for ``grub_dpkg`` Deprecated in version 22.2. Use ``grub_dpkg`` instead.
# D2: Default: ``true`` Deprecated in version 22.3. Use ``lock_passwd`` instead.
# D3: Deprecated in version 18.3. Use ``ssh_authorized_keys`` instead.
Valid schema user-data
2. network-config at /var/lib/cloud/instances/cb88d1af-f827-4381-bc89-4fad787bcaaf/network-config.json:
Valid schema network-config
```
non-annotate
```
# cloud-init schema --system
Found cloud-config data types: user-data, network-config
1. user-data at /var/lib/cloud/instances/cb88d1af-f827-4381-bc89-4fad787bcaaf/cloud-config.txt:
Cloud config schema deprecations: grub-dpkg: An alias for ``grub_dpkg`` Deprecated in version 22.2. Use ``grub_dpkg`` instead., users.0.lock-passwd: Default: ``true`` Deprecated in version 22.3. Use ``lock_passwd`` instead., users.0.ssh-authorized-keys: Deprecated in version 18.3. Use ``ssh_authorized_keys`` instead.
Valid schema user-data
2. network-config at /var/lib/cloud/instances/cb88d1af-f827-4381-bc89-4fad787bcaaf/network-config.json:
Valid schema network-config
```
Without `--annotate`, the output prints the keys that are invalid and the annotations, but for some reason also prints the unrendered message output. Adding the command message _might_ be useful, but the purpose of this command is validating inputs, not telling the user what the purpose of input keys is.
I would recommend the following improvements:
1) deprecate the `--annotate` flag, and make this behavior the default
2) remove the file path - this is an implementation detail that the user doesn't need access to and is a distraction to the task at hand: *validate inputs*
3) remove markdown characters from output - the double backticks all over the place are harsh on the eyes
4) add color - a flag `--color=[auto|always|never]` which defaults to `auto` and adds color to the output when stdout is a tty could make this look really nice (a common default in tools like grep). Something that makes the `# D1` a different color from the message text and possibly even some basic yaml syntax highlighting could make this tool a pleasure to work with, not just "does the job". Consider how much easier the following highlighted version is on the eyes compared to the above (intentionally not highlighted) tools.
```yaml
# cloud-init schema --system --annotate
Found cloud-config data types: user-data, network-config
1. user-data at /var/lib/cloud/instances/cb88d1af-f827-4381-bc89-4fad787bcaaf/cloud-config.txt:
#cloud-config
# from 1 files
# part-001
---
grub-dpkg: # D1
enabled: false
users:
- lock-passwd: false # D2
name: osadmin
ssh-authorized-keys: # D3
- ssh-rsa "AAAAB3NzaC1yc2EAAAADAQABAAABAQCc/K1T62elOkJKc94sWovn06RE7D274Fxx5n+eT/oClAwk7632awMtWjO+lIRpzOlEcYCR6wexlmL9mZNEFJoROMMRyCxRilNAiDKOq0X5j1HXY2ky9KjtLxo2b8yXFRBcYKK4W8aHU94NkNek81jdi9lC+L6jUrZ25d7xylqnEbd4TgrBphiowdh5B3RY+j6ePthLWWhHopRcVDgq91yYacelCCIfSDaGBya9iXPZSwoKtPin4n5PdSGmSOA3fIkvV5JjLS1QbuY5tzhXKuH9MdAqrvutF1bprs/GDf0IY8DO7DDoo8rXjhhgGtCdg1i5UitZIAM3hn/Vk5F//5eJ
JOOS8312@EB-OR6120158"
sudo:
- ALL=(ALL) NOPASSWD:ALL
...
# Deprecations: -------------
# D1: An alias for ``grub_dpkg`` Deprecated in version 22.2. Use ``grub_dpkg`` instead.
# D2: Default: ``true`` Deprecated in version 22.3. Use ``lock_passwd`` instead.
# D3: Deprecated in version 18.3. Use ``ssh_authorized_keys`` instead.
Valid schema user-data
2. network-config at /var/lib/cloud/instances/cb88d1af-f827-4381-bc89-4fad787bcaaf/network-config.json:
Valid schema network-config
```
Contributor guide
Assessment
This issue has not been assessed yet.