fix: fix tags for shield config
Add mapstructure tags to parse shield config through viper in expected ways
@bsushmith can you explain the changes ?
Currently, the way the config is read and parsed is thru viper, and viper uses mapstructure tags and if those are not present, it uses the var names(lowercase) in the struct itself as the config key string to parse from config file.
https://github.com/odpf/salt/blob/main/config/config.go#L174 uses mapstructure tags to get the flattened keys. At the moment, we have mapstructure tags are present for all internal fields in the shield config, but not at the top level.
example:
type SpiceDBConfig struct {
Host string `yaml:"host"`
Port string `yaml:"port" default:"50051"`
PreSharedKey string `yaml:"pre_shared_key" mapstructure:"pre_shared_key"`
}
without these changes, the config for example spicedb would be expected as spicedb.pre_shared_key rather than spice_db.pre_shared_key which leads to confusion as to half of it is getting parsed using one way and other part in other way.
These changes will break the current env keys, we need to update the env keys to handle this change.
viper create different keys with yaml/json and mapstructure tags
ex. yaml spicedb will remove the underscore and create env SPICEDB
but with map structure, env keys preserve the underscore. SPICE_DB
These changes will break the current env keys, we need to update the env keys to handle this change. viper create different keys with
yaml/jsonandmapstructuretags ex.yaml spicedbwill remove the underscore and create envSPICEDBbut with map structure, env keys preserve the underscore.SPICE_DB
I think this is configurable.
This is already handled in a separate PR.