Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
`charm build` with defined options overwrites instead of merging layer.yaml #85
Comments
marcoceppi
added
the
charm-build
label
Dec 31, 2015
marcoceppi
referenced this issue
in juju-solutions/layer-basic
Dec 31, 2015
Merged
Packages definition #18
|
This was actually intentional, because otherwise there would be no way to override or remove list values, since lists would only be additive. (You can override dict values by specifying the same key again, so deep merging dicts doesn't have the same issue.) However, particularly with the dash list YAML syntax, it's unexpected (I've seen it surprise people several times now, including myself) and there isn't a good way to handle this use-case. One way to handle this might be to support a custom schema setting that would indicate that a list value should be merged instead of overridden. The plus for this approach is that the schema seems a natural place to define this. The minuses are that it applies to the option for every layer (i.e., you couldn't merge by default but also support a layer flat-out overriding the list), that there's no way to remove an option from a merged list, and that it only works for layer opts. The first and second aren't issues for the package opt, because you really wouldn't want to remove a package that a lower layer depends on, but it might be a reasonable thing to do for some other list value. For the third, layer options are the most obvious and common use-case, but there might be others, e.g. the list of tags in Another approach might be to have a special (e.g.) |
|
I didn't realize the use case for removing values. If you ask me
I'll take a stab at this in the reactive library for a new type in the schema as I have a usecase for additive behavior. |
|
So, that's basically what I was suggesting with the first approach. And it would work pretty well for layer options, but doesn't address the issue with tags, which I agree should be additive which is why I called it out. Another area where this comes up which I think was the reason the override behavior was chosen is for Another point to consider is that there is support in Ideally, I'd like to have a single solution that covers all of the YAML files in a common, consistent way. I'd also like the modifications be as close to the values as possible; I'm a little unhappy with |
|
@johnsca Do you have a use case for when the override behaviour in lists is desirable? This might make it clear what the default behaviour should be (or if override should be supported at all). My naive assumption would be that options designed to be overridden would default to an empty list. Perhaps a list of software sources, where the layer provides defaults and consumers of the layer can tune it? Nah, the layer just needs to do 'if not config['sources']: sources = ['ppa:foo/bar']' and provide the default that way. |
|
Maybe software deps. If for example you want to change the default list of On Mon, Jan 4, 2016 at 9:09 AM Cory Johns notifications@github.com wrote:
|
|
@bcsaller Software dependencies is an interesting example. In this case, it is the charm using the layer that needs to decide if a list should be combined or overridden, rather than the layer insisting one way or the other. Does marco's solution allow the charm to decide the behaviour at build time, rather than it being hard coded in the layer? |
|
@stub42 It does not. Either the |
marcoceppi commentedDec 31, 2015
When supplying options in layer.yaml
and
the second layer wins with only
cowsaybeing selected. Expected output would be['tree', 'sl', 'cowsay']