← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~chad.smith/cloud-init:schema-subcommand into cloud-init:master


The proposal to merge ~chad.smith/cloud-init:schema-subcommand into cloud-init:master has been updated.

Description changed to:

schema cli: Add schema subcommand to cloud-init cli and cc_runcmd schema

This branch adds an jsonschema definition for the cc_runcmd module. cc_ntp is the only other module with a schema defined currently. Since jsonschema isn't a mandatory requirement, schema validation will only result in schema warnings at cloud-init runtime if python-jsonschema is installed. Otherwise it's a no-op for existing systems.

The branch also publishes "devel" subcommand from which "schema" can be called to validate the schema of a cloud-config file locally instead of having to actually deploy an instance. We also move analyze under devel subcommand and only optionally import devel subparser to save file load cycles when devel is not specified.

To perform validation of runcmd and ntp sections of a cloud-config file:
$ cat > cloud.cfg <<EOF
runcmd: bogus

$ python -m cloudinit.cmd.main devel schema --config-file cloud.cfg

Once jsonschema is defined for all ~50 cc modules, we will move this schema subcommand up as a proper subcommand of the cloud-init CLI.

To test:

$ cat > invalid-cloud.cfg <<EOF
runcmd: bogus

$ python -m cloudinit.cmd.main devel schema --config-file invalid-cloud.cfg

# print docs as manpages
$ python -m cloudinit.cmd.main  devel schema --doc | rst2man | man -l -

# generate docs and check modules topic
tox -e doc

For more details, see:
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:schema-subcommand into cloud-init:master.