StackStorm / StackStorm/st2

Support for complex types (lists, dictionaries, integers) for dynamic config values

Open
#2,976 2 comments 4 reactions 1 assignee View on GitHub

@Kami is already working on this.

Since Oct 27, 2016.

complexity:medium enhancement
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

Problem Description

Right now dynamic configuration values (ones which are referenced using Jinja variable notation inside the config file and are read from the datastore) can only be strings (this limitation is of course clearly documented and pointed out inside the documentation, blog post, etc.). Non-string types are not supported directly.

In theory, users could handle the serialization of complex types themselves and then de-serialize it inside actions, but that's obviously not ideal (it's not consistent and each user who requires this functionality would need to re-invent the wheel, etc.).

Obviously that's quite limiting and it would make sense to also support other commonly used types such as lists, arrays, dictionaries and integers / numbers.

Background

First prototype of dynamic configuration values actually supported arbitrary types, but per discussion with @lakshmi-kannan and @dzimine we decided to simplify it and only support strings.

Proposed Solution

I propose the same approach as I already mostly implemented in the first prototype. This means we should provide a special API (and related CLI commands) to manage dynamic config values. This API would transparently read value type from the config schema, serialize the user value and store it inside the datastore. Similarly, when action is ran, we would de-serialize the value and pass it to the action (similar story for sensors).

To support that, we would need to implement APIs for managing (list, get, set, delete) the dynamic configuration values and also corresponding CLI commands:

st2 config list [--pack=<pack name>]
st2 config get [--decrypt] <pack name> <config item name>
st2 config set [--encrypt] <pack name> <config item name> <config item value>
st2 config delete <pack name> <config item name>

In short, it would be implemented as a thin-wrapper around datastore API which would handle serialization and de-serialization and some other things.

Backward Compatibility

We can make the change fully backward compatible by treating a value as a string if it's not serialized (those would be existing / old values).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.