summaryrefslogtreecommitdiff
path: root/cloudinit/safeyaml.py
Commit message (Collapse)AuthorAgeFilesLines
* cli: schema also validate vendordata*.Chad Smith2023-02-091-1/+45
| | | | | | | | | | | | | | | | cloud-init schema --annotate now walks any valid user-data, vendor-data and vendor2-data to report whether any of these cloud-config files provide invalid or deprecated schema values. Also, fix a bug in nested mapping annotations to properly report the full nested indexed schema path. The following now can be annotated without KeyErrors: users: - default - lock-passwd: false name: root
* Drop mypy excluded files (#1454)Alberto Contreras2022-05-231-1/+1
| | | | | | | | | - Add types to let mypy pass. - Add mypy flags: - detect unused ignores - redundant casts - Drop support of `ConfigParser` in Python 2 - Harden DataSourceLXD.network_config - Convert old-style commented types to proper types.
* schema: render schema paths from _CustomSafeLoaderWithMarks (#1391)Chad Smith2022-05-101-2/+126
| | | | | | | | | | | | | Use a custom yaml.SafeLoader to track SchemaMarks to define start and end row/column values of each object within the original cloud-config content. Fixes KeyError from cloud-init devel schema --annotate when encountering invalid nested list values under a dict key. Also default to yaml.dumper.SafeDumper when safeyaml.dumps does not provide noalias=True. Fixes: SC-929
* Adopt Black and isort (SC-700) (#1157)James Falcon2021-12-151-11/+14
| | | | | Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
* tox: bump the pinned flake8 and pylint version (#1029)Paride Legovini2021-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tox: bump the pinned flake8 and pylint version * pylint: fix W1406 (redundant-u-string-prefix) The u prefix for strings is no longer necessary in Python >=3.0. * pylint: disable W1514 (unspecified-encoding) From https://www.python.org/dev/peps/pep-0597/ (Python 3.10): The new warning stems form https://www.python.org/dev/peps/pep-0597, which says: Developers using macOS or Linux may forget that the default encoding is not always UTF-8. [...] Even Python experts may assume that the default encoding is UTF-8. This creates bugs that only happen on Windows. The warning could be fixed by always specifying encoding='utf-8', however we should be careful to not break environments which are not utf-8 (or explicitly state that only utf-8 is supported). Let's silence the warning for now. * _quick_read_instance_id: cover the case where load_yaml() returns None Spotted by pylint: - E1135 (unsupported-membership-test) - E1136 (unsubscriptable-object) LP: #1944414
* Fix usages of yaml, and move yaml_dump to safeyaml.dumps.Scott Moser2019-10-241-0/+15
| | | | | | | | | | Here we replace uses of the pyyaml module directly with functions provided by cloudinit.safeyaml. Also, change/move cloudinit.util.yaml_dumps to cloudinit.safeyaml.dumps LP: #1849640
* netplan: Don't render yaml aliases when dumping netplanRyan Harper2019-02-071-0/+7
| | | | | | | | | | | | | | | | Cloud-init rendered netplan with duplicate aliases if a network config included "global" nameserver/search values. Netplan uses can read yaml files which do use aliaes but cloud-init did not render a single yaml dictionary, instead it combined yaml sections into a single document which sometimes resulted in duplicate aliases being present. This branch introduces a yaml SafeDumper class which can set the 'ignore_aliases' attribute. This is not enabled by default but callers to util.yaml_dumps can pass a boolean to toggle this. The netplan render uses noalias=True and the resulting yaml output does not contain any aliases. LP: #1815051
* LICENSE: Allow dual licensing GPL-3 or Apache 2.0Jon Grimm2016-12-221-15/+5
| | | | | | | | | | | | | | | | | | This has been a recurring ask and we had initially just made the change to the cloud-init 2.0 codebase. As the current thinking is we'll just continue to enhance the current codebase, its desirable to relicense to match what we'd intended as part of the 2.0 plan here. - put a brief description of license in LICENSE file - put full license versions in LICENSE-GPLv3 and LICENSE-Apache2.0 - simplify the per-file header to reference LICENSE - tox: ignore H102 (Apache License Header check) Add license header to files that ship. Reformat headers, make sure everything has vi: at end of file. Non-shipping files do not need the copyright header, but at the moment tests/ have it.
* pep8: fix style errors reported by pycodestyle 2.1.0Scott Moser2016-11-101-0/+1
| | | | | | pycodestyle 2.1.0 is in Ubuntu zesty, and complained about the changes made here. Simple style changes. This makes 'make pep8' pass again when built in a zesty build system with proposed enabled.
* fix pep8 and pylintScott Moser2012-09-281-0/+1
|
* add 'safeyaml' to cloudinitScott Moser2012-09-281-0/+31
In 0.7.0 we started using yaml.safe_load to load data rather than yaml.load. Some producers (namely, ubuntu MAAS created) have produced cloud-config data in the past that included python unicode types. This creates a specialized safe_loader that is basically safe_load + support for python unicode.