From 850fe65f4b52fa817feb1cb180746964f5c58b26 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 3 Nov 2021 11:39:23 +0100 Subject: [PATCH] comments for mappings --- proxy/pkg/config/env_mapping.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/proxy/pkg/config/env_mapping.go b/proxy/pkg/config/env_mapping.go index 77c999921..6e34a3a2d 100644 --- a/proxy/pkg/config/env_mapping.go +++ b/proxy/pkg/config/env_mapping.go @@ -8,6 +8,23 @@ import ( gofig "github.com/gookit/config/v2" ) +// mappings holds a record of how to get an env variable's value onto a config.Config value. Field selectors are made via +// the `tagName` field. For instance having the following value: +// type example struct { +// enable `mapstructure:"enable"` +// } +// +// e := example{enable: false} +// +// we can link the field `e.enable` with the environment variable EXTENSION_ENABLE by adding an entry in this mappings: +// { +// gType: "bool", +// envName: "EXTENSION_ENABLE", +// tagName: "enable", +// } +// +// so when a config is parsed the value is read from the environment, parsed and loaded onto whatever destination +// has the tagName. var mappings = []struct { gType string // expected type, used for decoding. It is the type expected from gookit. envName string // name of the env var