moby / tool

Temporary repository for the moby assembly tool used by the Moby project
Apache License 2.0
75 stars 65 forks source link

Overrides of some top levels do not nest #151

Closed ijc closed 7 years ago

ijc commented 7 years ago

If I specify a Runtime section in my yml then it overrides the entire runtime provided by the pkg in the org.mobyproject.config label on the image, even though the image defines only runtime.mkdir and the yml only overrides runtime.bindns.

Looking at the code in config.go it looks like oci.Linux is handled properly by unpacking one level. Should runtime do the same? It looks like Resources might be in a similar situation too.

I wonder if it would be possible to write a generic struct merger using reflection or if such a thing already exists.

justincormack commented 7 years ago

Yeah, I remember thinking about this when I did it and wasn't sure how it should be done. I think you are right and it makes sense for the next level of runtime to be treated individually not as a whole.

I don't know if it is worth trying to rewrite as a generic thing with reflection. It is only a few keys so fixing it up should be relatively easy as a first fix. But the code is a bit messy now.

ijc commented 7 years ago

I'll knock something up based on the existing pattern.

My main reason for thinking about reflection was so as to not have to add code to two places (struct and the assign func) when adding a field, also it could potentially make deeper nesting possible.

justincormack commented 7 years ago

this was resolved in #153