diff options
author | Brett Holman <bholman.devel@gmail.com> | 2021-12-06 15:27:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-06 15:27:12 -0700 |
commit | bedac77e9348e7a54c0ec364fb61df90cd893972 (patch) | |
tree | 73a0ddaada5ceb256e22c053fec50db82671d14c /cloudinit/config/cc_zypper_add_repo.py | |
parent | f428ed1611bdb685598832dd42495f0bcda40ec4 (diff) | |
download | vyos-cloud-init-bedac77e9348e7a54c0ec364fb61df90cd893972.tar.gz vyos-cloud-init-bedac77e9348e7a54c0ec364fb61df90cd893972.zip |
Add Strict Metaschema Validation (#1101)
Improve schema validation.
This adds strict validation of config module definitions at testing
time, with plumbing included for future runtime validation. This
eliminates a class of bugs resulting from schemas that have definitions
that are incorrect, but get interpreted by jsonschema as
"additionalProperties" that are therefore ignored.
- Add strict meta-schema for jsonschema unit test validation
- Separate schema from module metadata structure
- Improve type annotations for various functions and data types
Cleanup:
- Remove unused jsonschema "required" elements
- Eliminate manual memoization in schema.py:get_schema(),
reference module.__doc__ directly
Diffstat (limited to 'cloudinit/config/cc_zypper_add_repo.py')
-rw-r--r-- | cloudinit/config/cc_zypper_add_repo.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cloudinit/config/cc_zypper_add_repo.py b/cloudinit/config/cc_zypper_add_repo.py index 05855b0c..bf1638fb 100644 --- a/cloudinit/config/cc_zypper_add_repo.py +++ b/cloudinit/config/cc_zypper_add_repo.py @@ -9,14 +9,14 @@ import configobj import os from textwrap import dedent -from cloudinit.config.schema import get_schema_doc +from cloudinit.config.schema import get_meta_doc from cloudinit import log as logging from cloudinit.settings import PER_ALWAYS from cloudinit import util distros = ['opensuse', 'sles'] -schema = { +meta = { 'id': 'cc_zypper_add_repo', 'name': 'ZypperAddRepo', 'title': 'Configure zypper behavior and add zypper repositories', @@ -51,6 +51,9 @@ schema = { # any setting in /etc/zypp/zypp.conf """)], 'frequency': PER_ALWAYS, +} + +schema = { 'type': 'object', 'properties': { 'zypper': { @@ -86,14 +89,13 @@ schema = { /etc/zypp/zypp.conf'""") } }, - 'required': [], 'minProperties': 1, # Either config or repo must be provided 'additionalProperties': False, # only repos and config allowed } } } -__doc__ = get_schema_doc(schema) # Supplement python help() +__doc__ = get_meta_doc(meta, schema) # Supplement python help() LOG = logging.getLogger(__name__) |