diff --git a/pkg/operators/v1alpha1/catalogsource_types.go b/pkg/operators/v1alpha1/catalogsource_types.go index 6f6199030..59dae89db 100644 --- a/pkg/operators/v1alpha1/catalogsource_types.go +++ b/pkg/operators/v1alpha1/catalogsource_types.go @@ -196,20 +196,20 @@ func (u *UpdateStrategy) UnmarshalJSON(data []byte) (err error) { if err = json.Unmarshal(data, &us); err != nil { return err } - if us.RegistryPoll != nil && us.RegistryPoll.Interval != nil { - registryPoll := &RegistryPoll{ - RawInterval: us.RegistryPoll.RawInterval, - } + // if us.RegistryPoll != nil && us.RegistryPoll.Interval != nil { + registryPoll := &RegistryPoll{ + RawInterval: us.RegistryPoll.RawInterval, + } - duration, err := time.ParseDuration(registryPoll.RawInterval) - if err != nil { - registryPoll.ParsingError = fmt.Sprintf("error parsing spec.updateStrategy.registryPoll.interval. Using the default value of %s instead. Error: %s", DefaultRegistryPollDuration, err) - registryPoll.Interval = &metav1.Duration{Duration: DefaultRegistryPollDuration} - } else { - registryPoll.Interval = &metav1.Duration{Duration: duration} - } - u.RegistryPoll = registryPoll + duration, err := time.ParseDuration(registryPoll.RawInterval) + if err != nil { + registryPoll.ParsingError = fmt.Sprintf("error parsing spec.updateStrategy.registryPoll.interval. Using the default value of %s instead. Error: %s", DefaultRegistryPollDuration, err) + registryPoll.Interval = &metav1.Duration{Duration: DefaultRegistryPollDuration} + } else { + registryPoll.Interval = &metav1.Duration{Duration: duration} } + u.RegistryPoll = registryPoll + // } return nil } diff --git a/pkg/operators/v1alpha1/types_test.go b/pkg/operators/v1alpha1/types_test.go index af3131145..966ae1f18 100644 --- a/pkg/operators/v1alpha1/types_test.go +++ b/pkg/operators/v1alpha1/types_test.go @@ -272,16 +272,9 @@ func TestUpdateStrategyUnmarshal(t *testing.T) { t.Run(tt.name, func(t *testing.T) { s := TestStruct{} err := json.Unmarshal(tt.in, &s) - if s.UpdateStrategy.RegistryPoll != nil { - require.Equal(t, tt.out.UpdateStrategy.RawInterval, s.UpdateStrategy.RawInterval) - } - if s.UpdateStrategy.RegistryPoll != nil && s.UpdateStrategy.Interval != nil { - require.Equal(t, tt.out.UpdateStrategy.Interval, s.UpdateStrategy.Interval) - } - - if s.UpdateStrategy.RegistryPoll != nil { - require.Equal(t, tt.out.UpdateStrategy.ParsingError, s.UpdateStrategy.ParsingError) - } + require.Equal(t, tt.out.UpdateStrategy.RawInterval, s.UpdateStrategy.RawInterval) + require.Equal(t, tt.out.UpdateStrategy.Interval, s.UpdateStrategy.Interval) + require.Equal(t, tt.out.UpdateStrategy.ParsingError, s.UpdateStrategy.ParsingError) require.Equal(t, tt.err, err) }) }