Merge lp:~dooferlad/linaro-image-tools/yaml-checker into lp:linaro-image-tools/11.11

Proposed by James Tunnicliffe
Status: Merged
Merged at revision: 544
Proposed branch: lp:~dooferlad/linaro-image-tools/yaml-checker
Merge into: lp:linaro-image-tools/11.11
Diff against target: 0 lines
To merge this branch: bzr merge lp:~dooferlad/linaro-image-tools/yaml-checker
Reviewer Review Type Date Requested Status
Milo Casagrande (community) Approve
Review via email: mp+117298@code.launchpad.net

Description of the change

Adds checking to make sure that V3 metadata files contain only keys that we expect, where we expect them.

To post a comment you must log in.
Revision history for this message
Milo Casagrande (milo) wrote :
Download full text (3.5 KiB)

Hello James,

thanks for working on this!

On Mon, Jul 30, 2012 at 7:04 PM, James Tunnicliffe
<email address hidden> wrote:
> +
> + def _validate_keys(self):
> + """Check the dictionary created by the YAML parser for unknown keys"""
> +
> + if not self._is_v3:
> + # We don't check V1 or V2 configurations in this way
> + return
> +

Actually this is nothing wrong, but I'm used to think in terms of
positive check, so I would have treated only the "if _is_v3". But
that's personal thinkging. :-)

> + # Create a layout that represents where keys are allowed.
> + # If a key has a value None, this indicates there is either a value or
> + # list of values that can be associated with it.
> + # If a key contains a dictionary, this means that the key can
> + # contain a dictionary.
> + # The string "root" indicates that the key can contain the root
> + # structure. This is used for the boards section, where each
> + # board can contain the full or partial layout, overwriting the global
> + # settings.
> + self._validate_keys_layout = {
> + FORMAT_FIELD: None,
> + NAME_FIELD: None,
> + ARCHITECTURES_FIELD: None,
> + ORIGIN_FIELD: None,
> + MAINTAINER_FIELD: None,
> + SUPPORT_FIELD: None,
> + ASSUME_INSTALLED_FIELD: None,
> + INCLUDE_DEBS_FIELD: None,
> + DTB_FILE_FIELD: None,
> + DTB_ADDR_FIELD: None,
> + SERIAL_TTY_FIELD: None,
> + EXTRA_SERIAL_OPTIONS_FIELD: None,
> + MMC_ID_FIELD: None,
> + PACKAGES_FIELD: None,
> + PARTITION_LAYOUT_FIELD: None,
> + KERNEL_FILE_FIELD: None,
> + KERNEL_ADDR_FIELD: None,
> + INITRD_FILE_FIELD: None,
> + INITRD_ADDR_FIELD: None,
> + LOAD_ADDR_FIELD: None,
> + BOOT_SCRIPT_FIELD: None,
> + LOADER_START_FIELD: None,
> + WIRED_INTERFACES_FIELD: None,
> + WIRELESS_INTERFACES_FIELD: None,
> + BOOT_MIN_SIZE_FIELD: None,
> + ROOT_MIN_SIZE_FIELD: None,
> + LOADER_MIN_SIZE_FIELD: None,
> + SAMSUNG_BL1_LEN_FIELD: None,
> + SAMSUNG_BL1_LEN_FIELD: None,
> + SAMSUNG_ENV_LEN_FIELD: None,
> + SAMSUNG_BL2_LEN_FIELD: None,
> + SNOWBALL_STARTUP_FILES_CONFIG_FIELD: None,
> + SOURCES_FIELD: None,
> + BOOTLOADERS_FIELD: {
> + "*": {
> + PACKAGE_FIELD: None,
> + FILE_FIELD: None,
> + IN_BOOT_PART_FIELD: None,
> + DD_FIELD: None,
> + EXTRA_BOOT_OPTIONS_FIELD: None,
> + SPL_PACKAGE_FIELD: None,
> + SPL_FILE_FIELD: None,
> + SPL_IN_BOOT_PART_FIELD: None,
> + SPL_DD_FIELD: None,
> + ENV_DD_FIELD: None,
> + }
> + },
> + BOARDS_FIELD: "root",
> + }
> +

I was thinking if it might be worth to move this structure inside the
h...

Read more...

Revision history for this message
Milo Casagrande (milo) :
review: Approve
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

On 31 July 2012 09:49, Milo Casagrande <email address hidden> wrote:
> On Mon, Jul 30, 2012 at 7:04 PM, James Tunnicliffe
> <email address hidden> wrote:
>> +
>> + def _validate_keys(self):
>> + """Check the dictionary created by the YAML parser for unknown keys"""
>> +
>> + if not self._is_v3:
>> + # We don't check V1 or V2 configurations in this way
>> + return
>> +
>
> Actually this is nothing wrong, but I'm used to think in terms of
> positive check, so I would have treated only the "if _is_v3". But
> that's personal thinkging. :-)

It is more an indentation thing for me, though I don't like having
more than one exit point from a function if I can avoid it.

>> + self._validate_keys_layout = {
...
>> + }

> I was thinking if it might be worth to move this structure inside the
> hwpack_fields.py file, where all the fields are specified.
> It is more a "logical" point of view: we keep the fields and their
> structure in the same place.

I completely agree - will move it before merging.

--
James Tunnicliffe

545. By James Tunnicliffe

Moved hwpack_v3_layout structure to hwpack_fields.py

Preview Diff

Empty

Subscribers

People subscribed via source and target branches