You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After rethinking of #355, I came to a conclusion that it'd be useful to have the following approach to work with slices and maps in Kong:
A slice or map of struct (e.g. []SomeStruct or map[string]SomeStruct) isn't ignored by Kong as well as it isn't ignored if the struct has a slice or map field:
typeSomeStructstruct {
List []NestedStructDictmap[string]NestedStruct
}
typeNestedStructstruct {
CountintTextstring
}
Prefixes (prefix and envPrefix) should work the same way as for regular flags with one exception:
Symbols # and ? will be used for a slice index and map key respectively:
The vars with the same slice indexes (map keys) will refer to the same slice (map) element. I.e. COMMAND_DATA1_0_LIST_0_COUNT=5 and COMMAND_DATA1_0_LIST_0_TEXT="AAAAA" will fill up the same NestedStruct.
If a slice was prefilled with a resolver, the data from .env is appended to the slice so that the prefilled data can't be overridden (the indexes are just unique identifiers). On the contrary, map elements can be overridden.
Fields of every element of a slice or map should be validated with the specified Kong rules (enum, required etc.).
WDYT?
The text was updated successfully, but these errors were encountered:
After rethinking of #355, I came to a conclusion that it'd be useful to have the following approach to work with slices and maps in Kong:
A slice or map of struct (e.g.
[]SomeStruct
ormap[string]SomeStruct
) isn't ignored by Kong as well as it isn't ignored if the struct has a slice or map field:I.e. if we have:
Then we have the following flags (total 8):
Those flags should be displayed in the help.
Prefixes (
prefix
andenvPrefix
) should work the same way as for regular flags with one exception:Symbols
#
and?
will be used for a slice index and map key respectively:An example of
.env
:The vars with the same slice indexes (map keys) will refer to the same slice (map) element. I.e.
COMMAND_DATA1_0_LIST_0_COUNT=5
andCOMMAND_DATA1_0_LIST_0_TEXT="AAAAA"
will fill up the sameNestedStruct
.If a slice was prefilled with a resolver, the data from
.env
is appended to the slice so that the prefilled data can't be overridden (the indexes are just unique identifiers). On the contrary, map elements can be overridden.Fields of every element of a slice or map should be validated with the specified Kong rules (
enum
,required
etc.).WDYT?
The text was updated successfully, but these errors were encountered: