Skip to content

Commit

Permalink
fix: ordering
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Choudhary <[email protected]>
  • Loading branch information
vishal-chdhry committed Jul 5, 2024
1 parent ca162eb commit c8d5587
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,37 +134,37 @@ func (c Config) migration(store storage.Interface) error {
switch event.Type {
case watch.Added:
cpolr := event.Object.(*v1alpha2.ClusterPolicyReport)
if cpolr.Annotations != nil {
if _, ok := cpolr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 140 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L128-L140

Added lines #L128 - L140 were not covered by tests
}
err := store.ClusterPolicyReports().Create(context.TODO(), *cpolr)
if err != nil {
klog.Error(err)
}
case watch.Modified:
cpolr := event.Object.(*v1alpha2.ClusterPolicyReport)
if cpolr.Annotations != nil {
if _, ok := cpolr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 151 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L142-L151

Added lines #L142 - L151 were not covered by tests
}
case watch.Modified:
cpolr := event.Object.(*v1alpha2.ClusterPolicyReport)
err := store.ClusterPolicyReports().Update(context.TODO(), *cpolr)
if err != nil {
klog.Error(err)
}
case watch.Deleted:
cpolr := event.Object.(*v1alpha2.ClusterPolicyReport)
if cpolr.Annotations != nil {
if _, ok := cpolr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 162 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L153-L162

Added lines #L153 - L162 were not covered by tests
}
case watch.Deleted:
cpolr := event.Object.(*v1alpha2.ClusterPolicyReport)
err := store.ClusterPolicyReports().Delete(context.TODO(), cpolr.Name)
if err != nil {
klog.Error(err)
}

Check warning on line 167 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L164-L167

Added lines #L164 - L167 were not covered by tests
if cpolr.Annotations != nil {
if _, ok := cpolr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}
}
}
}
}()
Expand Down Expand Up @@ -198,37 +198,37 @@ func (c Config) migration(store storage.Interface) error {
switch event.Type {
case watch.Added:
polr := event.Object.(*v1alpha2.PolicyReport)
if polr.Annotations != nil {
if _, ok := polr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 204 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L192-L204

Added lines #L192 - L204 were not covered by tests
}
err := store.PolicyReports().Create(context.TODO(), *polr)
if err != nil {
klog.Error(err)
}
case watch.Modified:
polr := event.Object.(*v1alpha2.PolicyReport)
if polr.Annotations != nil {
if _, ok := polr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 215 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L206-L215

Added lines #L206 - L215 were not covered by tests
}
case watch.Modified:
polr := event.Object.(*v1alpha2.PolicyReport)
err := store.PolicyReports().Update(context.TODO(), *polr)
if err != nil {
klog.Error(err)
}
case watch.Deleted:
polr := event.Object.(*v1alpha2.PolicyReport)
if polr.Annotations != nil {
if _, ok := polr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 226 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L217-L226

Added lines #L217 - L226 were not covered by tests
}
case watch.Deleted:
polr := event.Object.(*v1alpha2.PolicyReport)
err := store.PolicyReports().Delete(context.TODO(), polr.Name, polr.Namespace)
if err != nil {
klog.Error(err)
}

Check warning on line 231 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L228-L231

Added lines #L228 - L231 were not covered by tests
if polr.Annotations != nil {
if _, ok := polr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}
}
}
}
}()
Expand Down Expand Up @@ -261,37 +261,37 @@ func (c Config) migration(store storage.Interface) error {
switch event.Type {
case watch.Added:
cephr := event.Object.(*reportsv1.ClusterEphemeralReport)
if cephr.Annotations != nil {
if _, ok := cephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 267 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L255-L267

Added lines #L255 - L267 were not covered by tests
}
err := store.ClusterEphemeralReports().Create(context.TODO(), *cephr)
if err != nil {
klog.Error(err)
}
case watch.Modified:
cephr := event.Object.(*reportsv1.ClusterEphemeralReport)
if cephr.Annotations != nil {
if _, ok := cephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 278 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L269-L278

Added lines #L269 - L278 were not covered by tests
}
case watch.Modified:
cephr := event.Object.(*reportsv1.ClusterEphemeralReport)
err := store.ClusterEphemeralReports().Update(context.TODO(), *cephr)
if err != nil {
klog.Error(err)
}
case watch.Deleted:
cephr := event.Object.(*reportsv1.ClusterEphemeralReport)
if cephr.Annotations != nil {
if _, ok := cephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 289 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L280-L289

Added lines #L280 - L289 were not covered by tests
}
case watch.Deleted:
cephr := event.Object.(*reportsv1.ClusterEphemeralReport)
err := store.ClusterEphemeralReports().Delete(context.TODO(), cephr.Name)
if err != nil {
klog.Error(err)
}

Check warning on line 294 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L291-L294

Added lines #L291 - L294 were not covered by tests
if cephr.Annotations != nil {
if _, ok := cephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}
}
}
}
}()
Expand Down Expand Up @@ -323,37 +323,37 @@ func (c Config) migration(store storage.Interface) error {
switch event.Type {
case watch.Added:
ephr := event.Object.(*reportsv1.EphemeralReport)
if ephr.Annotations != nil {
if _, ok := ephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 329 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L317-L329

Added lines #L317 - L329 were not covered by tests
}
err := store.EphemeralReports().Create(context.TODO(), *ephr)
if err != nil {
klog.Error(err)
}
case watch.Modified:
ephr := event.Object.(*reportsv1.EphemeralReport)
if ephr.Annotations != nil {
if _, ok := ephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 340 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L331-L340

Added lines #L331 - L340 were not covered by tests
}
case watch.Modified:
ephr := event.Object.(*reportsv1.EphemeralReport)
err := store.EphemeralReports().Update(context.TODO(), *ephr)
if err != nil {
klog.Error(err)
}
case watch.Deleted:
ephr := event.Object.(*reportsv1.EphemeralReport)
if ephr.Annotations != nil {
if _, ok := ephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}

Check warning on line 351 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L342-L351

Added lines #L342 - L351 were not covered by tests
}
case watch.Deleted:
ephr := event.Object.(*reportsv1.EphemeralReport)
err := store.EphemeralReports().Delete(context.TODO(), ephr.Name, ephr.Namespace)
if err != nil {
klog.Error(err)
}

Check warning on line 356 in pkg/server/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/server/config.go#L353-L356

Added lines #L353 - L356 were not covered by tests
if ephr.Annotations != nil {
if _, ok := ephr.Annotations[api.ServedByReportsServerAnnotation]; ok {
return
}
}
}
}
}()
Expand Down

0 comments on commit c8d5587

Please sign in to comment.