-
Notifications
You must be signed in to change notification settings - Fork 70
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
base/v0_6_exp: Validate merged/replaced Ignition configs #476
base: main
Are you sure you want to change the base?
Conversation
5c5e3d1
to
9e622f7
Compare
The file extension doesn't matter. There's no requirement that Ignition configs have an 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 ? |
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 A few notes:
|
11a4472
to
7f78a08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thank you for working on this I just took a first pass at this.
I found some surface level questions for you.
I am planning on taking another deeper pass so see why your CI is failing.
base/v0_6_exp/validate.go
Outdated
@@ -29,10 +30,22 @@ func (rs Resource) Validate(c path.ContextPath) (r report.Report) { | |||
if rs.Local != nil { | |||
sources++ | |||
field = "local" | |||
_, report, err := exp.ParseCompatibleVersion([]byte(*rs.Local)) | |||
if err != nil { | |||
r.AddOnError(c.Append("ignition", "config", "merge", "local"), common.ErrTooManyResourceSources) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is ErrTooManyResourceSources
the only error that is relevant to ParseCompatibleVersion
? I ask because if not, we losing valuable debug info for the user.
Additionally, in the comment #275 (comment)
there was talk about catching ErrUnknownVersion
and instead of returning the error just warning in this case to work around ratcheting when butane / Ignition are undergoing stabilization.
ec4e35c
to
1198407
Compare
d1c334b
to
a6dcbda
Compare
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its getting really close, keep it up!
base/v0_6_exp/validate.go
Outdated
r.Merge(butaneReport) | ||
} | ||
if err != nil { | ||
if err == common.ErrNoFilesDir { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think we want to be returning any errors other than the special case. The special case in this instance is ErrUnknownVersion => #275 (comment)
base/v0_6_exp/validate.go
Outdated
return | ||
} | ||
|
||
func MapIgnitionReportToButane(ignitionReport report.Report) report.Report { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: wdyt about ConvertToButaneReport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in a perfect world we might make this a helper function ..
i.e func(report.report) toButane() report.Report {}
However def not scope for this PR as I am not sure where I would want to put that type of a utility.
func MapIgnitionReportToButane(ignitionReport report.Report) report.Report { | ||
var butaneRep report.Report | ||
for _, entry := range ignitionReport.Entries { | ||
butaneEntry := report.Entry{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure this is everything we need.
Looping through the entries and expanding them into a new report object with those entries is good.
The issue comes with the the entry.Context path the paths are different between the ignition package and the butane package. this is mostly because we are converting from json to yaml butane is human readable so their names change.
internal to butane it looks like we already have a similar issue, we have to translate to json from yaml the direction is the inverse of what we need now though.
It has a good test to explain this here => https://github.com/coreos/butane/blob/0244d31c627890b9af64b82e2a2224ac39bbb4d4/base/v0_6_exp/translate_test.go#L573C12-L573C12
986194b
to
bfdb07c
Compare
bfdb07c
to
8ee89ab
Compare
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