coreos / butane

Butane translates human-readable Butane Configs into machine-readable Ignition Configs.
https://coreos.github.io/butane/
Apache License 2.0
255 stars 70 forks source link

base/v0_6_exp: Validate merged/replaced Ignition configs #476

Open Adam0Brien opened 1 year ago

Adam0Brien commented 1 year ago

Fix #275

This PR introduces validation for local/inline fields when using the merge/replace feature in butane.

For this PR ignitions Parse function needs to be used so the vendor folder is has been updated to accommodate this

bgilbert commented 1 year ago

The file extension doesn't matter. There's no requirement that Ignition configs have an .ign extension. And, in the case of the inline directive, there isn't any file extension; the file contents are included directly in the parent config.

As #275 says, what we should do instead is validate the contents of the specified config using Ignition config validation.

Adam0Brien commented 1 year ago

As #275 says, what we should do instead is validate the contents of the specified config using Ignition config validation.

by ignition config validation do you mean https://github.com/coreos/butane/blob/main/vendor/github.com/coreos/ignition/v2/config/v3_5_experimental/types/resource.go#L34 ?

bgilbert commented 1 year ago

That's a validator that's invoked by the validation process. We need to run the validation process.

But thinking about it some more, we need to do more than just validation. The embedded Ignition config is in the form of text, not Go structs, so we also need to parse it. Ignition's config parsing function in config handles both parsing and validation, so we can just call that, and merge its report into ours.

A few notes:

travier commented 1 year ago

Let's split the vendor update into its own commit to make reviewing the change easier.

Adam0Brien commented 1 year ago

Let's split the vendor update into its own commit to make reviewing the change easier.

That's no problem!, but wont that break CI since validate.go wont be able to compile the parse function?