cburschka / cadence

A strophe.js-powered XMPP web client for chatrooms.
6 stars 2 forks source link

Better handling of profiles. #441

Closed cburschka closed 7 years ago

cburschka commented 7 years ago

The latest build update added the concept of a YAML "profile" replacing .config.vars, derived from the template install.dist.yml.

However, the install.yml name is still hardcoded in several places, and it is also not possible to re-run an incremental configuration against an existing profile. That last part is useful if you need to, eg., switch out the conference server without touching the other values (especially if there are manual additions in the profile, which would be overwritten).

This patch would fix both of these, and also make it easily possible to build from an arbitrary profile with make profile=custom.yml. Without an argument, the profile would default to the last one used (stored in .profile) or install.yml.

cburschka commented 7 years ago

Not completely done yet - thanks to the logic of merge_object, install.yml cannot add config overrides that aren't defined in install.dist.yml.

Change merge_object to allow adding new keys. This is not like the JS-based merge_object function which does need to whitelist keys in order to avoid leaving outdated cruft in people's config storage.

Best use a flag, because the eventual end goal is a NodeJS build process where the same merging algorithm handles both tasks.

cburschka commented 7 years ago

Extend merge_object to support three modes:

The first mode is used when loading a stored user configuration object. Keys must always match the template.

The second mode is used to compare an installation profile's config overrides to the template. Keys must match the template, but only the overrides should be in the resulting profile.

cburschka commented 7 years ago

... actually, that's kind of unnecessary, if only unintentionally.

The object merge code isn't equipped to deal with CommentedMap objects, so it just replaces the default profile completely. Still kind of a bug, but there's nothing preventing anyone from overwriting config keys.