From 202de3a05ee6f1a5a63d5c88ef7be7d1ac11a39b Mon Sep 17 00:00:00 2001 From: Jan Larwig Date: Sat, 1 Feb 2025 15:57:23 +0100 Subject: [PATCH] apply review suggestions --- main.go | 2 +- pkg/apis/options/load.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index d9fc406b..2a09b3ce 100644 --- a/main.go +++ b/main.go @@ -70,7 +70,7 @@ func main() { func loadConfiguration(config, yamlConfig string, extraFlags *pflag.FlagSet, args []string) (*options.Options, error) { opts, err := loadLegacyOptions(config, extraFlags, args) if err != nil { - return nil, err + return nil, fmt.Errorf("couldn't load legacy options: %w", err) } if yamlConfig != "" { diff --git a/pkg/apis/options/load.go b/pkg/apis/options/load.go index 22e775a8..878199ed 100644 --- a/pkg/apis/options/load.go +++ b/pkg/apis/options/load.go @@ -83,12 +83,11 @@ func Decode(input interface{}, result interface{}) error { DecodeHook: mapstructure.ComposeDecodeHookFunc(toDurationHookFunc()), Metadata: nil, // Don't track any metadata Result: result, // Decode the result into the prefilled options - TagName: "json", // Parse all fields that use the yaml tag + TagName: "json", // Parse all fields that use the json tag ZeroFields: false, // Don't clean the default values from the result map (options) ErrorUnused: true, // Throw an error if keys have been used that aren't mapped to any struct fields - IgnoreUntaggedFields: true, // Ignore fields in structures that aren't tagged with yaml + IgnoreUntaggedFields: true, // Ignore fields in structures that aren't tagged with json }) - if err != nil { return fmt.Errorf("error creating decoder for config: %w", err) }