Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for paths in config #166

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wjt
Copy link
Member

@wjt wjt commented Jun 21, 2024

Previously, if a filename referred to in the configuration does not exist, that would only be discovered when the hook which uses that key runs, which may be minutes or hours into the build.

Add a way to specify in the schema that certain keys must be set to a single path to an extant file, or a list of paths to extant files.

Add key_type = path(s) annotations to the schema for all (I think) of the file-like keys used by hooks in this repo.

https://phabricator.endlessm.com/T35517

@wjt
Copy link
Member Author

wjt commented Jun 21, 2024

I should be clear that this is only very lightly tested. I aimed to spend no more time on it than the image builder spent on a doomed image build overnight :)

@wjt wjt marked this pull request as draft June 21, 2024 14:09
@wjt
Copy link
Member Author

wjt commented Jun 21, 2024

So lightly tested that it fails its tests!

wjt added 2 commits June 21, 2024 16:55
Previously, if a filename referred to in the configuration does not
exist, that would only be discovered when the hook which uses that key
runs, which may be minutes or hours into the build.

Add a way to specify in the schema that certain keys must be set to a
single path to an extant file, or a list of paths to extant files.

https://phabricator.endlessm.com/T35517
Based on a quick review of the hooks in this repo, I think this covers
all the likely candidates.

https://phabricator.endlessm.com/T35517
@wjt wjt force-pushed the T35517-validate-paths-in-config branch from 47d111e to 0775b73 Compare June 21, 2024 15:56
@wjt
Copy link
Member Author

wjt commented Jun 21, 2024

Oh I guess I can't use match unless we bump our minimum Python version to 3.10 (i.e. Endless OS 6 is required).

@dbnicholson I'm curious what you think about this approach, before I mess with going back to if/elif etc.

Of course this wouldn't catch the error at PR time – I think the way to do that would be to have a list of known combinations of fields and have a GitHub Actions job which validates the config for all those. (And a similar job in the private config repo which is where the error occurred.) My old idea there is to again abuse the schema. Add the following to the config:

[build]
configtuple = ${product}-${arch}-${platform}-${personality}

and then add to the schema:

[build]
configtuple_values = eos-amd64-amd64-base
                     eos-amd64-amd64-en
                     # ... etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant