Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added error unused decoder setting #177

Merged
merged 2 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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