diff --git a/internal/pkg/config/load.go b/internal/pkg/config/load.go index 5dc4b99..ae78374 100644 --- a/internal/pkg/config/load.go +++ b/internal/pkg/config/load.go @@ -74,7 +74,7 @@ func (fvp *FlagValuesProvider) ToKeyValues() map[string]interface{} { func (fvp *FlagValuesProvider) Read(name string) (val interface{}, found bool) { fl := fvp.flags.Lookup(name) - if fl == nil || !fl.Changed { + if fl == nil { return nil, false } diff --git a/internal/pkg/config/load_test.go b/internal/pkg/config/load_test.go index 64b9698..47ad7e4 100644 --- a/internal/pkg/config/load_test.go +++ b/internal/pkg/config/load_test.go @@ -331,19 +331,20 @@ func TestCollectParams(t *testing.T) { func TestFlagValuesProvider(t *testing.T) { fl := &pflag.FlagSet{} - fl.StringP("somekey", "s", "", "") + fl.StringP("somekey", "s", "test-default", "") flagValuesProv := CreateFlagValuesProvider(fl) - _, found := flagValuesProv.Read("somekey") - assert.False(t, found) + val, found := flagValuesProv.Read("somekey") + assert.True(t, found) + assert.Equal(t, "test-default", val) err := fl.Parse([]string{"--somekey", "someval"}) require.NoError(t, err) - val, found2 := flagValuesProv.Read("somekey") + val2, found2 := flagValuesProv.Read("somekey") assert.True(t, found2) - assert.Equal(t, "someval", val.(string)) + assert.Equal(t, "someval", val2) actualKeyValues := flagValuesProv.ToKeyValues() assert.Equal(t, map[string]interface{}{"somekey": "someval"}, actualKeyValues)