Skip to content

Commit 0e5a1ed

Browse files
committed
fix add config function
1 parent 6bce126 commit 0e5a1ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/config/config_new.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func New() (*ConfigHandler, error) {
4141
}
4242

4343
// AddConfig adds a configuration parameter to both Cobra and Viper with options
44-
func (c *ConfigHandler) AddConfig(cmd *cobra.Command, opts ConfigOptions) error {
44+
func (c *ConfigHandler) AddConfig(cmd *cobra.Command, opts ConfigOptions) {
4545
key := opts.Key
4646
defaultValue := opts.DefaultValue
4747
// Set default value in Viper
@@ -66,12 +66,12 @@ func (c *ConfigHandler) AddConfig(cmd *cobra.Command, opts ConfigOptions) error
6666
case []string:
6767
flagSet.StringSlice(flagName, defaultValue.([]string), opts.Description)
6868
default:
69-
return fmt.Errorf("unsupported type for key %s", key)
69+
panic(fmt.Errorf("unsupported type for key %s", key))
7070
}
7171

7272
// Bind the flag to Viper
7373
if err := c.v.BindPFlag(key, flagSet.Lookup(flagName)); err != nil {
74-
return fmt.Errorf("failed to bind %s: %w", key, err)
74+
panic(fmt.Errorf("failed to bind %s: %w", key, err))
7575
}
7676

7777
// Handle environment variable binding
@@ -85,7 +85,7 @@ func (c *ConfigHandler) AddConfig(cmd *cobra.Command, opts ConfigOptions) error
8585
}
8686
}
8787

88-
return nil
88+
return
8989
}
9090

9191
// load reads and merges the configuration

0 commit comments

Comments
 (0)