Skip to content

Commit

Permalink
13 adding interface to pluralizer to enable testing (#14)
Browse files Browse the repository at this point in the history
* feat: add interface to pluralizer

* chore: fixed wrong logging
  • Loading branch information
matteogastaldello authored Feb 12, 2025
1 parent d91ccf2 commit 5e3a9c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c *Controller) handleErr(err error, obj event.Event) {

if retries := c.queue.NumRequeues(obj); retries < maxRetries {
c.logger.WithValues("retries", retries).
WithValues("obj", fmt.Sprintf("%v", obj)).
WithValues("obj", fmt.Sprintf("%v", obj.EventType)).
Debug("processing event, retrying", "error", err)

dig := event.DigestForEvent(obj)
Expand All @@ -71,7 +71,7 @@ func (c *Controller) processItem(ctx context.Context, obj interface{}) error {

el, err := c.fetch(ctx, evt.ObjectRef, false)
if err != nil {
c.logger.Debug("Resolving unstructured object", "error", evt.ObjectRef.String())
// if the object is not found, we will not retry to process it and we not throw an error
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/pluralizer/pluralizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ type names struct {
Shorts []string `json:"shorts"`
}

type PluralizerInterface interface {
GVKtoGVR(gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
}

type Pluralizer struct {
urlPlurals *string
cli *http.Client
Expand Down

0 comments on commit 5e3a9c1

Please sign in to comment.