Skip to content

Commit

Permalink
Merge pull request #177 from GreenmaskIO/fix/config_decoder_error_unused
Browse files Browse the repository at this point in the history
fix: added error unused decoder setting
  • Loading branch information
wwoytenko authored Aug 24, 2024
2 parents a2ecc2c + 69ac47e commit b64ad84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/greenmask/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func initConfig() {
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.StringToSliceHookFunc(","),
)
cfg.ErrorUnused = true
}

if err := viper.Unmarshal(Config, decoderCfg); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion internal/domains/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ type TransformerConfig struct {
// This cannot be parsed with mapstructure due to uncontrollable lowercasing
// https://github.com/spf13/viper/issues/373
// Instead we have to use workaround and parse it manually
Params toolkit.StaticParameters `mapstructure:"-" yaml:"-" json:"-"` // yaml:"params" json:"params,omitempty"`
//
// Params attribute decoding is dummy. It is replaced in the runtime internal/utils/config/viper_workaround.go
// But it is required to leave mapstruicture tag to avoid errors raised by viper and decoder setting
// ErrorUnused = true. It was set in PR #177 (https://github.com/GreenmaskIO/greenmask/pull/177/files)
Params toolkit.StaticParameters `mapstructure:"params" yaml:"params" json:"params"`
// MetadataParams - encoded transformer parameters - uses only for storing into storage
// TODO: You need to get rid of it by creating a separate structure for storing metadata in
// internal/db/postgres/storage/metadata_json.go
Expand Down

0 comments on commit b64ad84

Please sign in to comment.