Skip to content

Commit

Permalink
temporary fix
Browse files Browse the repository at this point in the history
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
  • Loading branch information
rashmigottipati committed Jun 7, 2024
1 parent 4e5c8dc commit ab597a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
24 changes: 12 additions & 12 deletions pkg/operators/v1alpha1/catalogsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
13 changes: 3 additions & 10 deletions pkg/operators/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit ab597a9

Please sign in to comment.