Skip to content
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

Ordering of charm config items #568

Open
sparkiegeek opened this issue Jan 24, 2019 · 3 comments
Open

Ordering of charm config items #568

sparkiegeek opened this issue Jan 24, 2019 · 3 comments

Comments

@sparkiegeek
Copy link

In my config.yaml, I carefully order items so that related config is next to each other and newer config keys which replace others are 'above' the deprecated ones.

However, when I look at the charm details page, the config items are seemingly randomly ordered.

I note that the Juju CLI and Juju GUI order the values asciibetically, which whilst not perfect, is at least understandable.

@hatched
Copy link

hatched commented Jan 24, 2019

So it turns out that the GUI isn't sorting these values after all, but instead presenting them in the same order it's returned from the charmstore so I'm not sure why one api call is returning them sorted and another returning them as-is in the config.yaml.

@frankban
Copy link

I think this happens because internally, in both juju and the charm store, charm options are represented as a map (see [1]) which is an unordered collection. I think the charm store should be patched to be consistent with juju by reordering the fields alphabetically on the meta endpoint.

[1] https://github.com/juju/charm/blob/v6/config.go#L78

@frankban
Copy link

frankban commented Jan 25, 2019

After further investigation, it seems that the charm store already sorts the options alphabetically (see [1]). So second guess is that it depends on how js and python decode a JSON map by default: js into an object in which fields ordering is accidentally kept, python into a dict which is unordered.
Quickest fix going forward is rendering the options in alphabetical order in the jinja template of the store front. On a more medium/long term, json schema options would solve this and other charm config related annoyances, like not having enums.

[1] https://api.jujucharms.com/charmstore/v5/~juju-gui/jujushell/meta/charm-config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants