Skip to content

Provide a mechanism for a config override to overwrite an array #113

@za419

Description

@za419

This is, in a way, related to #112, and could be considered an alternative to it (although I would not be opposed to doing both, as I think this is necessary either way)

Currently, an array in default-config will be merged through concatenation with an array in the override configuration. That's convenient, and I feel that it's a good default behavior - However, there are circumstances in which I can imagine an IA wanting to completely replace an array (for example, if deploying a bot not named "Cadence", it would be preferable to completely replace the default custom commands and autoselectable play channels).

Therefore, I think we should allow the override config file to specify when an array should be overwritten instead of concatenated.

In addition to the current syntax of providing an array ("key": [...]), which should continue to concatenate the arrays together, we should support one of the following syntaxes:

{
    "key": {
        "overwrite": true,
        "values": [...]
    }
}
{
    "key": {
        "strategy": "overwrite",
        "values": [...]
    }
}

Syntax 1 is a little more direct and slightly cleaner to implement, but it is less extensible than syntax 2 (which might allow us to provide new strategies in the future, such as a concatenateExcept sort of thing that allows an exceptions array to be removed).

If we go with syntax 1, we should permit overwrite to be false, and in syntax 2, we should allow the strategy to be set to concatenate. In both cases this would effectively be an extra-verbose way to state the default behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configIssues or pull requests which involve changes to configenhancementjavascriptIssues or pull requests which involve changes to the JS source code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions