minder icon indicating copy to clipboard operation
minder copied to clipboard

Switch from hardcoded default values to querying viper store for binding config flags

Open Vyom-Yadav opened this issue 1 year ago • 0 comments

The current pattern followed by our CLIs is as follows:

https://github.com/stacklok/minder/blob/17412a2b32338d4b7ac2b234efee3124e565f20d/internal/config/common.go#L84-L95

The default value of the flag is hardcoded. A better pattern would be to query the viper store for the flag value after setting the default values using:

https://github.com/stacklok/minder/blob/17412a2b32338d4b7ac2b234efee3124e565f20d/internal/config/utils.go#L201-L203

Something like:

func RegisterReminderFlags(v *viper.Viper, flags *pflag.FlagSet) error {
	viperPath := "cursor_file"
	if err := config.BindConfigFlag(v, flags, viperPath, "cursor-file",
		v.GetString(viperPath), "DB Cursor file path for reminder", flags.String); err != nil {
		return err
	}

Vyom-Yadav avatar Apr 23 '24 06:04 Vyom-Yadav