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

Defaults do not work correctly with nested atributes #38

Closed
pgleyzer opened this Issue Aug 15, 2016 · 8 comments

Comments

Projects
None yet
3 participants
@pgleyzer
Copy link

pgleyzer commented Aug 15, 2016

Hi, it looks like defaults do not support nested attributes. For example:

default.yaml:
....cache:
........token:
............ttl: 15 minutes
............port: '5103'

development.yaml:
.....cache:
........token:
............ttl:10 minutes

My final attribute will be

.....cache:
........token:
............ttl:10 minutes

instead of:

.....cache:
........token:
............ttl:10 minutes
............port: '5103'

I am trying to use tiller since we are converting from chef environment, and I thought that I can just copy the erb templates and roles from chef into tiller with minimal changes. However, if defaults is not an option, that would make it a much harder effort.

@kydorn

This comment has been minimized.

Copy link
Contributor

kydorn commented Aug 15, 2016

I see your point, but IMHO if that gets implemented it shouldn't be a default behaviour, as sometimes you do not want to deep-merge the tree.

Maybe you could use different trees and then create a helper module to merge the config from those trees. That would require some changes in the erbs, though.

@pgleyzer

This comment has been minimized.

Copy link

pgleyzer commented Aug 15, 2016

Ok, thanks. It's just this is a default behavior for Chef. I thought it was commonplace. Also, a shallow merge of the tree would delete some of the attributes. I am not sure why you would want that.

@markround

This comment has been minimized.

Copy link
Owner

markround commented Aug 16, 2016

I could make this a configurable option, e.g. in common.yaml, include a deep_merge: true setting. Would that suit your needs ? For me, I can see that this behaviour (deep merging hashes) would be useful, but as it's not currently the default behaviour, we can look at making it the default in later (0.10.x) releases if it seems sensible.

@kydorn

This comment has been minimized.

Copy link
Contributor

kydorn commented Aug 16, 2016

We could do this to set the default behaviour, but I would still add a meta-variable in each tree node so we can override it.

For example:

default.yaml:
....deep_merge: true
....cache:
........token:
............ttl: 15 minutes
............port: '5103'
........token2:
............ttl: 15 minutes
............port: '5103'

development.yaml:
.....cache:
........token:
............ttl:10 minutes
........token:
............_deep_merge: false
............ttl:10 minutes

merged values:
....cache:
........token:
............ttl: 10 minutes
............port: '5103'
........token2:
............ttl: 10 minutes

These meta-values should be processed for all datasources.

What do you think?

@markround markround self-assigned this Aug 16, 2016

@markround

This comment has been minimized.

Copy link
Owner

markround commented Aug 16, 2016

I'm not keen on making it the default behaviour just now. However, it seems like it could be a sensible default ("principle of least surprise") but having just released a breaking 0.9.x, I'd like to let things settle a little before another major release. Then we can always review all these settings and decide what should be defaulted.

I also think adding stuff per- hash also complicates things, and I'm really not keen on increasing the cognitive overhead further. But as a solution to @pgleyzer 's issue, I have committed a proof-of-concept here : https://github.com/markround/tiller/tree/feature/deep_merge. This simply changes the data merging behaviour if you set deep_merge: true in common.yaml.

@pgleyzer

This comment has been minimized.

Copy link

pgleyzer commented Aug 16, 2016

@markround thanks. Yes, I think deep_merge: true will work just fine for me. I will try out that behavior and let you know. Thanks, again.

@markround

This comment has been minimized.

Copy link
Owner

markround commented Aug 17, 2016

Tiller 0.9.1 pushed with deep_merge feature. Thanks for reporting the issue!

@markround markround closed this Aug 17, 2016

@pgleyzer

This comment has been minimized.

Copy link

pgleyzer commented Aug 17, 2016

Great, thank you.

From: Mark Dastmalchi-Round notifications@github.com
Reply-To: markround/tiller reply@reply.github.com
Date: Wednesday, August 17, 2016 at 3:47 AM
To: markround/tiller tiller@noreply.github.com
Cc: Pasha Gleyzer pgleyzer@hotwire.com, Mention mention@noreply.github.com
Subject: Re: [markround/tiller] Defaults do not work correctly with nested atributes (#38)

Tiller 0.9.1 pushed with deep_merge feature. Thanks for reporting the issue!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//issues/38#issuecomment-240377378, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADfmzB5qPa-Zo87ToGzZxd9IcbnwD7x2ks5qgua9gaJpZM4Jkj4n.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment