Documentation
¶
Overview ¶
Package cfgmap reads typed values out of the map[string]any form a connection configuration takes in the platform's connection_instances store.
A connection is stored as JSON and reaches a toolkit as a generic map, so every kind that parses one needs the same handful of tolerant readers: a value may arrive as the Go type the author intended (programmatic construction, YAML with a duration string) or as whatever JSON round-tripping produced (a float64 for an integer, a string for a bool). These readers absorb that spread in one place so two kinds cannot disagree about what `"call_timeout": 30` means.
Every reader is total: an absent key, a nil map or a value of an unrecognized type yields the supplied default (or the zero value) rather than an error. Required-field enforcement belongs to the caller's validation, not to reading.
Index ¶
- func Bool(cfg map[string]any, key string) bool
- func Duration(cfg map[string]any, key string, defaultVal time.Duration) time.Duration
- func Int64(cfg map[string]any, key string, defaultVal int64) int64
- func String(cfg map[string]any, key string) string
- func StringDefault(cfg map[string]any, key, defaultVal string) string
- func StringMap(cfg map[string]any, key string) map[string]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool reads a boolean flag. Absent or unrecognized values yield false. A string is parsed leniently (strconv.ParseBool) so YAML or JSON that round-trips a flag as "true"/"false" is honored alongside a native bool.
func Duration ¶
Duration reads a duration. A string is parsed with time.ParseDuration ("30s", "5m"); a bare number is read as seconds, which is the form a JSON round-trip of an operator's "30" produces. An unparseable string yields defaultVal rather than an error, so one malformed value cannot refuse a connection that is otherwise sound.
func Int64 ¶
Int64 reads an integer. float64 is accepted because encoding/json decodes every JSON number into one.
func StringDefault ¶
StringDefault reads a string value, falling back to defaultVal when the key is absent or holds an empty string. The empty-string fallback matters for admin-saved connections: a form that submits every field writes "" for the ones the operator left blank, and those must take the default rather than override it with emptiness.
func StringMap ¶
StringMap reads a map of strings. Accepts map[string]string (programmatic construction) or map[string]any (YAML/JSON unmarshaling); non-string values inside a map[string]any are skipped. An absent, empty or wholly non-string map yields nil, so callers can test the result with len() and need no separate "was it set" flag.
Types ¶
This section is empty.