canonical / rockcraft

Tool to create OCI Images using the language from Snapcraft and Charmcraft.
GNU General Public License v3.0
37 stars 44 forks source link

fix: improve `platforms.<platform>.build-on` validation #633

Closed aznashwan closed 4 months ago

aznashwan commented 4 months ago

Provide a helpful error message if rockcraft.yaml contains a platforms.<platform>.build-on which is not a list.

Fixes #632.

* my employing organization should have signed it AFAIK.

Example of change

Given this snipped of a rockcraft.yaml:

...
platforms:
  arm64:
    build-on: amd64
...

Before:

$ rockcraft build --debug
Bad rockcraft.yaml content:
- error for platform entry 'arm64': value is not a valid list (in field 'platforms')                                                                 
For more information, check out: https://documentation.ubuntu.com/rockcraft/en/stable/reference/rockcraft.yaml

After:

$ rockcraft build --debug
Bad rockcraft.yaml content:
- error for platform entry 'arm64': 'build-on' field must be a list of strings. (in field 'platforms')
For more information, check out: https://documentation.ubuntu.com/rockcraft/en/stable/reference/rockcraft.yaml
aznashwan commented 4 months ago

For the record, I am also open to modifying the Pydantic spec for build-on to automatically convert standalone strings to a list of one single string similar to how it's done for platforms.<platform>.build-for.

aznashwan commented 4 months ago

Just noticed the formatting issues and fixed them now, feel free to re-run the checks at your leisure!

aznashwan commented 4 months ago

Coincidentally fixed by https://github.com/canonical/rockcraft/pull/567.

Closing this PR now, thank you for everything!