easily add/remove values to existing tedge config properties of an array type #2864
Labels
idea
ideas/opportunities/feature requests which need to be further investigated before implementation
theme:cli
Theme: cli related topics
theme:configuration
Theme: Configuration management
Milestone
Is your feature request related to a problem? Please describe.
Editing tedge config values which are arrays is difficult to managed for users as it involves checking the initial value, and adding the new value only if it is not already included in the list. Most of the time the "thing" adding the new value does not care about the existing values, and just wants to make sure the value it cares about is added to the list without breaking any other components.
There are currently the following tedge config settings which expect an array:
The problem can be demonstrated via the tedge config
c8y.smartrest.templates
setting.Package 1 includes an operation handler which requires subscribing to a SmartREST template called
collection1
After adding the
collection1
template, the configuration get be retrieved using:$ tedge config get c8y.smartrest.templates ["collection1"]
Package 2 includes another operation handlers which requires subscribing to a different SmartREST template called
collection2
The package can't just run the following command, as it would overwrite the existing value from the previous step, so it requires more complex logic using jq to splice in a new value (below adds the new values, and then removes any duplicated template names)
Note If the user would not have
jq
then the logic was be more complex (and naive):Describe the solution you'd like
Add new subcommands for
tedge config
to "add" and "remove" values from an array.Below shows an example of some of the commands (and the result of the setting afterwards)
tedge config add {prop} {value}
tedge config set
)tedge config remove {prop} {value}
tedge config unset
)Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: