Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support slice type values #66

Open
YafimK opened this issue Sep 5, 2020 · 8 comments
Open

Support slice type values #66

YafimK opened this issue Sep 5, 2020 · 8 comments
Labels
enhancement New feature or request feedback Gathering feedback for an issue

Comments

@YafimK
Copy link
Contributor

YafimK commented Sep 5, 2020

Is this a bug? Please provide steps to reproduce, a failing test etc.

Add support to load slice field types - allowing to put slice type values in consul as lists.

Describe the solution

load the slice by the slice type (which must be one of the supported types implementing cfg type).

@mantzas
Copy link
Contributor

mantzas commented Sep 5, 2020

@YafimK keep in mind that you have to support also all the other ways of setting it up like env vars, flags etc...

@c0nstantx
Copy link
Contributor

@YafimK This can also be achieved using a custom type, instead of list specific one. I think we should stick to the bare minimum (int, float, string) types and use a custom struct for whatever is more complicated.

@YafimK
Copy link
Contributor Author

YafimK commented Sep 7, 2020

hmm I understand there is some complexity to it, but I do think that slice are really bare minimal support type.. as they are widely used, for example, passing list of addresses and etc. Making customization for basic golang supported type feels a bit strange. I'd be happy to any help of course.

@mantzas
Copy link
Contributor

mantzas commented Sep 7, 2020

Since we have to support also other sources like env vars which are only strings we have to find a unique delimiter for each value, split the string based on that and parse based on the underlying slice type (int, float,etc.). Correct?
In order to support lists in Harvester as it is now the above has to be done by the developer by hand using a string as the data type and using a custom type.
If we can automate the whole process would be a nice addition which could solve the repeated... I am worried about the delimiter... What should It be? Or should we support different delimiters and a default one?

@c0nstantx c0nstantx added enhancement New feature or request feedback Gathering feedback for an issue labels Sep 8, 2020
@c0nstantx
Copy link
Contributor

@YafimK, we won't move on with this issue as we don't think at the moment that this can be part of the library. We have created custom types support for these cases.
We will keep it open to get enough feedback if there is a need to add it as native type.
Thank you very much for the proposal.

@YafimK
Copy link
Contributor Author

YafimK commented Sep 9, 2020

  1. I do still think that slice is a basic type for golang and moreover for configs as it represents lists. We can use the same idioms used by common unmarshellers such as yaml and json for separators and etc.
    2.Sadly, AFAIK the custom type won't work here since it requires changes in "parser.go". I've made some progress, you can take a look here for an example of the changes (only begining - still need to solve the reflection there) - master...YafimK:add_support_slice

@siavashs
Copy link

siavashs commented Mar 17, 2021

I think it's useful to add slice types, the delimiter(s) can be defined also as a tag delimiter:";" or delimiters:",;".

@mantzas
Copy link
Contributor

mantzas commented Sep 15, 2022

Let's support int, float and string slice. We use a comma separated for the values.
@YafimK WDYT?
String slice is already implemented in this PR,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback Gathering feedback for an issue
Projects
None yet
Development

No branches or pull requests

4 participants