lewispeckover / consulator

Import and synchronize your Consul KV data from JSON and YAML
MIT License
32 stars 13 forks source link

Support for array of objects #9

Closed prologic closed 5 years ago

prologic commented 5 years ago

It looks like consulator doesn't understand hot to import the following:

config:
  foo:
    rules:
      - foo: bar
        exp:
          type: A

You end up with an err rlike:

Error: Invalid type map[string]interface {} in array. Only strings, numbers and boolean values are supported.

Is this a KP or intentional?

prologic commented 5 years ago

I've narrowed it down to array of objects:

Example:

AAPL:
  - shares: -75.088
    date: 11/27/2015
  - shares: 75.088
    date: 11/26/2015

This fails to import.

lewispeckover commented 5 years ago

Currently, it's intentionally not supported. If it were to be supported, how would you expect it to be represented in Consul?

prologic commented 5 years ago

As a tree of key/value(s) of course :) -- My consumer here is Consul Template and I was trying to use the {{ tree "<prefix>" }} function but since consulator can't import such things I've opted for:

config:
  nested_json: |
    <json here>
lewispeckover commented 5 years ago

What do you mean by a "a tree of key/value(s)"?

What would the structure look like? Are you suggesting it should create a path component from the index of your array, like this?

AAPL/0/shares: -75.088
AAPL/0/date: 11/27/2015
AAPL/1/shares: 75.088
AAPL/1/date: 11/26/2015

Or something different?

Consul can only store simple values at a given path, so I don't see a logical way to do this... Sorry if I'm missing something obvious! :slightly_smiling_face:

prologic commented 5 years ago

No you are absolutely right! I don't know what I was thinking :P -- Long day!

It makes no sense to import an array of objects. Thanks for confirming my silliness :D