Repository: Kong/kubernetes-ingress-controller
Pull request #6889 (2024-12-20 16:24:22)

chore(refactor): dedicated rels package
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#the-pull-request-submit-process and developer guide https://github.com/kubernetes/community/blob/master/contributors/devel/development.md
2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
3. Follow the instructions for writing a release note: https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md and ensure your changes are being reflected in CHANGELOG.md for the next upcoming release
-->

**What this PR does / why we need it**:

Address comment/fulfill promise 

- https://github.com/Kong/kubernetes-ingress-controller/pull/6814#discussion_r1883719468

of putting relations-related code into a separate package. Name `rels` has been chosen to not be too long and not to steal great variable names like `relation`, `relations` and `rel`. 




codecov[bot]: ## [Codecov](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) Report
Attention: Patch coverage is `80.76923%` with `5 lines` in your changes missing coverage. Please review.
> Project coverage is 76.4%. Comparing base [(`b14df00`)](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/commit/b14df00de20973a969c34c9d858d3388ce31cea3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) to head [(`5504b84`)](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/commit/5504b84c6e3067fd5c50fb5afd27f71e1470ed88?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong).
> Report is 2 commits behind head on main.

| [Files with missing lines](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) | Patch % | Lines |
|---|---|---|
| [internal/dataplane/kongstate/kongstate.go](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?src=pr&el=tree&filepath=internal%2Fdataplane%2Fkongstate%2Fkongstate.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong#diff-aW50ZXJuYWwvZGF0YXBsYW5lL2tvbmdzdGF0ZS9rb25nc3RhdGUuZ28=) | 82.3% | [3 Missing :warning: ](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) |
| [internal/dataplane/kongstate/customentity.go](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?src=pr&el=tree&filepath=internal%2Fdataplane%2Fkongstate%2Fcustomentity.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong#diff-aW50ZXJuYWwvZGF0YXBsYW5lL2tvbmdzdGF0ZS9jdXN0b21lbnRpdHkuZ28=) | 77.7% | [2 Missing :warning: ](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong) |

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff            @@
##            main   #6889      +/-   ##
========================================
+ Coverage   59.0%   76.4%   +17.3%     
========================================
  Files        210     212       +2     
  Lines      25241   25246       +5     
========================================
+ Hits       14917   19297    +4380     
+ Misses      9030    4928    -4102     
+ Partials    1294    1021     -273     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/Kong/kubernetes-ingress-controller/pull/6889?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Kong).


Patch:
diff --git a/internal/dataplane/kongstate/customentity.go b/internal/dataplane/kongstate/customentity.go
index 5536ea673..b40c8bb21 100644
--- a/internal/dataplane/kongstate/customentity.go
+++ b/internal/dataplane/kongstate/customentity.go
@@ -17,7 +17,7 @@ import (
 
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/failures"
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/store"
-	"github.com/kong/kubernetes-ingress-controller/v3/internal/util"
+	"github.com/kong/kubernetes-ingress-controller/v3/internal/util/rels"
 )
 
 // EntityFieldType represents type of a Kong entity field.
@@ -370,13 +370,13 @@ func findCustomEntityForeignFields(
 		return nil, nil
 	}
 	// Get the relations with other entities of the plugin.
-	rels, ok := pluginRelEntities.RelatedEntities[pluginKey]
+	relations, ok := pluginRelEntities.RelatedEntities[pluginKey]
 	if !ok {
 		return nil, nil
 	}
 
 	var (
-		foreignRelations      util.ForeignRelations
+		foreignRelations      rels.ForeignRelations
 		foreignServiceFields  []string
 		foreignRouteFields    []string
 		foreignConsumerFields []string
@@ -390,22 +390,22 @@ func findCustomEntityForeignFields(
 		switch field.Reference {
 		case string(kong.EntityTypeServices):
 			foreignServiceFields = append(foreignServiceFields, fieldName)
-			foreignRelations.Service = getServiceIDFromPluginRels(logger, rels, pluginRelEntities.RouteAttachedService, workspace)
+			foreignRelations.Service = getServiceIDFromPluginRels(logger, relations, pluginRelEntities.RouteAttachedService, workspace)
 		case string(kong.EntityTypeRoutes):
 			foreignRouteFields = append(foreignRouteFields, fieldName)
-			foreignRelations.Route = lo.FilterMap(rels.Routes, func(r *Route, _ int) (util.FR, bool) {
+			foreignRelations.Route = lo.FilterMap(relations.Routes, func(r *Route, _ int) (rels.FR, bool) {
 				if err := r.FillID(workspace); err != nil {
-					return util.FR{}, false
+					return rels.FR{}, false
 				}
-				return util.FR{Identifier: *r.ID, Referer: k8sEntity}, true
+				return rels.FR{Identifier: *r.ID, Referer: k8sEntity}, true
 			})
 		case string(kong.EntityTypeConsumers):
 			foreignConsumerFields = append(foreignConsumerFields, fieldName)
-			foreignRelations.Consumer = lo.FilterMap(rels.Consumers, func(c *Consumer, _ int) (util.FR, bool) {
+			foreignRelations.Consumer = lo.FilterMap(relations.Consumers, func(c *Consumer, _ int) (rels.FR, bool) {
 				if err := c.FillID(workspace); err != nil {
-					return util.FR{}, false
+					return rels.FR{}, false
 				}
-				return util.FR{Identifier: *c.ID, Referer: k8sEntity}, true
+				return rels.FR{Identifier: *c.ID, Referer: k8sEntity}, true
 			})
 		} // end of switch
 	}
diff --git a/internal/dataplane/kongstate/kongstate.go b/internal/dataplane/kongstate/kongstate.go
index addc3c64b..33f5d4f0a 100644
--- a/internal/dataplane/kongstate/kongstate.go
+++ b/internal/dataplane/kongstate/kongstate.go
@@ -29,6 +29,7 @@ import (
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/logging"
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/store"
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/util"
+	"github.com/kong/kubernetes-ingress-controller/v3/internal/util/rels"
 )
 
 // KongState holds the configuration that should be applied to Kong.
@@ -381,9 +382,9 @@ type NamespacedKongPlugin struct {
 
 func (ks *KongState) getPluginRelations(
 	cacheStore store.Storer, log logr.Logger, failuresCollector *failures.ResourceFailuresCollector,
-) map[string]util.ForeignRelations {
+) map[string]rels.ForeignRelations {
 	// KongPlugin key (KongPlugin's name:namespace) to corresponding associations
-	pluginRels := map[string]util.ForeignRelations{}
+	pluginRels := map[string]rels.ForeignRelations{}
 
 	type entityRelationType int
 	const (
@@ -416,9 +417,9 @@ func (ks *KongState) getPluginRelations(
 		pluginKey := namespace + ":" + plugin.Name
 		relations, ok := pluginRels[pluginKey]
 		if !ok {
-			relations = util.ForeignRelations{}
+			relations = rels.ForeignRelations{}
 		}
-		fr := util.FR{
+		fr := rels.FR{
 			Identifier: identifier,
 			Referer:    referrer,
 		}
@@ -500,7 +501,7 @@ func buildPlugins(
 	logger logr.Logger,
 	s store.Storer,
 	failuresCollector *failures.ResourceFailuresCollector,
-	pluginRels map[string]util.ForeignRelations,
+	pluginRels map[string]rels.ForeignRelations,
 ) []Plugin {
 	var plugins []Plugin
 
@@ -516,8 +517,8 @@ func buildPlugins(
 		}
 		// For non-existing plugin push failure K8s Events for all K8s object that reference it.
 		if !pluginFound {
-			for _, rel := range relations.GetCombinations() {
-				for _, ref := range rel.ToList() {
+			for _, relation := range relations.GetCombinations() {
+				for _, ref := range relation.ToList() {
 					if !ref.IsEmpty() {
 						failuresCollector.PushResourceFailure(
 							fmt.Sprintf("referenced KongPlugin or KongClusterPlugin %q does not exist", kongPluginName),
@@ -731,37 +732,37 @@ func maybeLogKongIngressDeprecationError(logger logr.Logger, services []*corev1.
 // getServiceIDFromPluginRels returns the ID of the services which a plugin refers to in RelatedEntitiesRef.
 // It fills the IDs of services directly referred, and IDs of services where referred routes attaches to.
 func getServiceIDFromPluginRels(
-	log logr.Logger, rels RelatedEntitiesRef, routeAttachedService map[string]*Service, workspace string,
-) []util.FR {
+	log logr.Logger, rer RelatedEntitiesRef, routeAttachedService map[string]*Service, workspace string,
+) []rels.FR {
 	// Return IDs of directly referred services.
-	if len(rels.Services) > 0 {
-		return lo.FilterMap(rels.Services, func(s *Service, _ int) (util.FR, bool) {
+	if len(rer.Services) > 0 {
+		return lo.FilterMap(rer.Services, func(s *Service, _ int) (rels.FR, bool) {
 			if err := s.FillID(workspace); err != nil {
 				log.Error(err, "failed to fill ID for service")
-				return util.FR{}, false
+				return rels.FR{}, false
 			}
-			return util.FR{Identifier: *s.ID, Referer: s.Parent}, true
+			return rels.FR{Identifier: *s.ID, Referer: s.Parent}, true
 		})
 	}
 	// Returns IDs of services where the referred routes attaches.
 	serviceIDs := lo.FilterMap(
-		rels.Routes,
-		func(r *Route, _ int) (util.FR, bool) {
+		rer.Routes,
+		func(r *Route, _ int) (rels.FR, bool) {
 			svc, ok := routeAttachedService[*r.Name]
 			if !ok {
-				return util.FR{}, false
+				return rels.FR{}, false
 			}
 			if err := svc.FillID(workspace); err != nil {
 				log.Error(err, "failed to fill ID for service")
-				return util.FR{}, false
+				return rels.FR{}, false
 			}
-			return util.FR{
+			return rels.FR{
 				Identifier: *svc.ID,
 				Referer:    svc.Parent,
 			}, true
 		},
 	)
-	return lo.UniqBy(serviceIDs, func(fr util.FR) string {
+	return lo.UniqBy(serviceIDs, func(fr rels.FR) string {
 		return fr.Identifier
 	})
 }
diff --git a/internal/util/relations.go b/internal/util/rels/relations.go
similarity index 99%
rename from internal/util/relations.go
rename to internal/util/rels/relations.go
index bcf9c155e..93eb85551 100644
--- a/internal/util/relations.go
+++ b/internal/util/rels/relations.go
@@ -1,4 +1,4 @@
-package util
+package rels
 
 import "sigs.k8s.io/controller-runtime/pkg/client"
 


Test patch:
diff --git a/internal/dataplane/kongstate/kongstate_test.go b/internal/dataplane/kongstate/kongstate_test.go
index 211ebed5c..1d3ce07fc 100644
--- a/internal/dataplane/kongstate/kongstate_test.go
+++ b/internal/dataplane/kongstate/kongstate_test.go
@@ -36,6 +36,7 @@ import (
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/labels"
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/store"
 	"github.com/kong/kubernetes-ingress-controller/v3/internal/util"
+	"github.com/kong/kubernetes-ingress-controller/v3/internal/util/rels"
 )
 
 var kongConsumerTypeMeta = metav1.TypeMeta{
@@ -234,7 +235,7 @@ func ensureAllKongStateFieldsAreCoveredInTest(t *testing.T, testedFields []strin
 func TestGetPluginRelations(t *testing.T) {
 	type data struct {
 		inputState              KongState
-		expectedPluginRelations map[string]util.ForeignRelations
+		expectedPluginRelations map[string]rels.ForeignRelations
 	}
 	tests := []struct {
 		name string
@@ -244,7 +245,7 @@ func TestGetPluginRelations(t *testing.T) {
 			name: "empty state",
 			data: data{
 				inputState:              KongState{},
-				expectedPluginRelations: map[string]util.ForeignRelations{},
+				expectedPluginRelations: map[string]rels.ForeignRelations{},
 			},
 		},
 		{
@@ -270,9 +271,9 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
-						"ns1:foo": {Consumer: []util.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer}}},
-						"ns1:bar": {Consumer: []util.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer}}},
+					expectedPluginRelations: map[string]rels.ForeignRelations{
+						"ns1:foo": {Consumer: []rels.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer}}},
+						"ns1:bar": {Consumer: []rels.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer}}},
 					},
 				}
 			}(),
@@ -300,9 +301,9 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
-						"ns1:foo": {ConsumerGroup: []util.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup}}},
-						"ns1:bar": {ConsumerGroup: []util.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup}}},
+					expectedPluginRelations: map[string]rels.ForeignRelations{
+						"ns1:foo": {ConsumerGroup: []rels.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup}}},
+						"ns1:bar": {ConsumerGroup: []rels.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup}}},
 					},
 				}
 			}(),
@@ -332,9 +333,9 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
-						"ns1:foo": {Service: []util.FR{{Identifier: "foo-service", Referer: k8sService}}},
-						"ns1:bar": {Service: []util.FR{{Identifier: "foo-service", Referer: k8sService}}},
+					expectedPluginRelations: map[string]rels.ForeignRelations{
+						"ns1:foo": {Service: []rels.FR{{Identifier: "foo-service", Referer: k8sService}}},
+						"ns1:bar": {Service: []rels.FR{{Identifier: "foo-service", Referer: k8sService}}},
 					},
 				}
 			}(),
@@ -373,9 +374,9 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
-						"ns2:foo": {Route: []util.FR{{Identifier: "foo-route", Referer: &k8sIngress}}},
-						"ns2:bar": {Route: []util.FR{{Identifier: "foo-route", Referer: &k8sIngress}}},
+					expectedPluginRelations: map[string]rels.ForeignRelations{
+						"ns2:foo": {Route: []rels.FR{{Identifier: "foo-route", Referer: &k8sIngress}}},
+						"ns2:bar": {Route: []rels.FR{{Identifier: "foo-route", Referer: &k8sIngress}}},
 					},
 				}
 			}(),
@@ -426,10 +427,10 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
-						"ns2:foo": {Route: []util.FR{{Identifier: "foo-route", Referer: k8sIngress}}},
-						"ns2:bar": {Route: []util.FR{{Identifier: "foo-route", Referer: k8sIngress}, {Identifier: "bar-route", Referer: k8sIngress}}},
-						"ns2:baz": {Route: []util.FR{{Identifier: "bar-route", Referer: k8sIngress}}},
+					expectedPluginRelations: map[string]rels.ForeignRelations{
+						"ns2:foo": {Route: []rels.FR{{Identifier: "foo-route", Referer: k8sIngress}}},
+						"ns2:bar": {Route: []rels.FR{{Identifier: "foo-route", Referer: k8sIngress}, {Identifier: "bar-route", Referer: k8sIngress}}},
+						"ns2:baz": {Route: []rels.FR{{Identifier: "bar-route", Referer: k8sIngress}}},
 					},
 				}
 			}(),
@@ -584,33 +585,33 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
+					expectedPluginRelations: map[string]rels.ForeignRelations{
 						"ns1:foo": {
-							Consumer:      []util.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer1FooBar}},
-							ConsumerGroup: []util.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup1FooBar}},
-							Service:       []util.FR{{Identifier: "foo-service", Referer: k8sService}},
+							Consumer:      []rels.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer1FooBar}},
+							ConsumerGroup: []rels.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup1FooBar}},
+							Service:       []rels.FR{{Identifier: "foo-service", Referer: k8sService}},
 						},
 						"ns1:bar": {
-							Consumer:      []util.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer1FooBar}},
-							ConsumerGroup: []util.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup1FooBar}},
-							Service:       []util.FR{{Identifier: "foo-service", Referer: k8sService}},
+							Consumer:      []rels.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer1FooBar}},
+							ConsumerGroup: []rels.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup1FooBar}},
+							Service:       []rels.FR{{Identifier: "foo-service", Referer: k8sService}},
 						},
 						"ns1:foobar": {
-							Consumer: []util.FR{{Identifier: "bar-consumer", Referer: &k8sKongConsumer1Foobar}},
+							Consumer: []rels.FR{{Identifier: "bar-consumer", Referer: &k8sKongConsumer1Foobar}},
 						},
 						"ns2:foo": {
-							Consumer:      []util.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer2FooBar}},
-							ConsumerGroup: []util.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup2FooBar}},
-							Route:         []util.FR{{Identifier: "foo-route", Referer: k8sIngress}},
+							Consumer:      []rels.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer2FooBar}},
+							ConsumerGroup: []rels.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup2FooBar}},
+							Route:         []rels.FR{{Identifier: "foo-route", Referer: k8sIngress}},
 						},
 						"ns2:bar": {
-							Consumer:      []util.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer2FooBar}},
-							ConsumerGroup: []util.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup2FooBar}, {Identifier: "bar-consumer-group", Referer: &k8sKongConsumerGroup2BarBaz}},
-							Route:         []util.FR{{Identifier: "foo-route", Referer: k8sIngress}, {Identifier: "bar-route", Referer: k8sIngress}},
+							Consumer:      []rels.FR{{Identifier: "foo-consumer", Referer: &k8sKongConsumer2FooBar}},
+							ConsumerGroup: []rels.FR{{Identifier: "foo-consumer-group", Referer: &k8sKongConsumerGroup2FooBar}, {Identifier: "bar-consumer-group", Referer: &k8sKongConsumerGroup2BarBaz}},
+							Route:         []rels.FR{{Identifier: "foo-route", Referer: k8sIngress}, {Identifier: "bar-route", Referer: k8sIngress}},
 						},
 						"ns2:baz": {
-							Route:         []util.FR{{Identifier: "bar-route", Referer: k8sIngress}},
-							ConsumerGroup: []util.FR{{Identifier: "bar-consumer-group", Referer: &k8sKongConsumerGroup2BarBaz}},
+							Route:         []rels.FR{{Identifier: "bar-route", Referer: k8sIngress}},
+							ConsumerGroup: []rels.FR{{Identifier: "bar-consumer-group", Referer: &k8sKongConsumerGroup2BarBaz}},
 						},
 					},
 				}
@@ -665,8 +666,8 @@ func TestGetPluginRelations(t *testing.T) {
 							},
 						},
 					},
-					expectedPluginRelations: map[string]util.ForeignRelations{
-						"default:rate-limiting-1": {Consumer: []util.FR{{Identifier: "1234-1234", Referer: &k8sKongConsumer}}},
+					expectedPluginRelations: map[string]rels.ForeignRelations{
+						"default:rate-limiting-1": {Consumer: []rels.FR{{Identifier: "1234-1234", Referer: &k8sKongConsumer}}},
 					},
 				}
 			}(),
@@ -1405,7 +1406,7 @@ func TestKongState_BuildPluginsCollisions(t *testing.T) {
 	for _, tt := range []struct {
 		name       string
 		in         []*kongv1.KongPlugin
-		pluginRels map[string]util.ForeignRelations
+		pluginRels map[string]rels.ForeignRelations
 		want       []string
 	}{
 		{
@@ -1420,11 +1421,11 @@ func TestKongState_BuildPluginsCollisions(t *testing.T) {
 					InstanceName: "test",
 				},
 			},
-			pluginRels: map[string]util.ForeignRelations{
+			pluginRels: map[string]rels.ForeignRelations{
 				"default:foo-plugin": {
 					// this shouldn't happen in practice, as all generated route names are unique
 					// however, it's hard to find a SHA256 collision with two different inputs
-					Route: []util.FR{{Identifier: "collision"}, {Identifier: "collision"}},
+					Route: []rels.FR{{Identifier: "collision"}, {Identifier: "collision"}},
 				},
 			},
 			want: []string{
@@ -1443,10 +1444,10 @@ func TestKongState_BuildPluginsCollisions(t *testing.T) {
 					InstanceName: "test",
 				},
 			},
-			pluginRels: map[string]util.ForeignRelations{
+			pluginRels: map[string]rels.ForeignRelations{
 				"default:foo-plugin": {
-					Route:         []util.FR{{Identifier: "route1"}, {Identifier: "route2"}, {Identifier: "route3"}},
-					ConsumerGroup: []util.FR{{Identifier: "group1"}},
+					Route:         []rels.FR{{Identifier: "route1"}, {Identifier: "route2"}, {Identifier: "route3"}},
+					ConsumerGroup: []rels.FR{{Identifier: "group1"}},
 				},
 			},
 			want: []string{
@@ -1466,10 +1467,10 @@ func TestKongState_BuildPluginsCollisions(t *testing.T) {
 					InstanceName: "test",
 				},
 			},
-			pluginRels: map[string]util.ForeignRelations{
+			pluginRels: map[string]rels.ForeignRelations{
 				"default:foo-plugin": {
-					Route:    []util.FR{{Identifier: "route1"}, {Identifier: "route2"}, {Identifier: "route3"}},
-					Consumer: []util.FR{{Identifier: "consumer1"}},
+					Route:    []rels.FR{{Identifier: "route1"}, {Identifier: "route2"}, {Identifier: "route3"}},
+					Consumer: []rels.FR{{Identifier: "consumer1"}},
 				},
 			},
 			want: []string{
@@ -1489,10 +1490,10 @@ func TestKongState_BuildPluginsCollisions(t *testing.T) {
 					InstanceName: "test",
 				},
 			},
-			pluginRels: map[string]util.ForeignRelations{
+			pluginRels: map[string]rels.ForeignRelations{
 				"default:foo-plugin": {
-					Service:  []util.FR{{Identifier: "service1"}, {Identifier: "service2"}, {Identifier: "service3"}},
-					Consumer: []util.FR{{Identifier: "consumer1"}},
+					Service:  []rels.FR{{Identifier: "service1"}, {Identifier: "service2"}, {Identifier: "service3"}},
+					Consumer: []rels.FR{{Identifier: "consumer1"}},
 				},
 			},
 			want: []string{
diff --git a/internal/util/relations_test.go b/internal/util/rels/relations_test.go
similarity index 99%
rename from internal/util/relations_test.go
rename to internal/util/rels/relations_test.go
index aa223518e..af5e7875f 100644
--- a/internal/util/relations_test.go
+++ b/internal/util/rels/relations_test.go
@@ -1,4 +1,4 @@
-package util
+package rels
 
 import (
 	"testing"