Repository: Kong/kubernetes-ingress-controller
Pull request #2361 (2022-03-23 15:12:18)

chore: move k8s utils under internal/util
**What this PR does / why we need it**:

When I originally made these k8s utils I should have nested them under utils so it was better understood they are general utility functions and not packages for core kubernetes functionality in the KIC.


Patch:
diff --git a/Dockerfile b/Dockerfile
index da75cd2cd..d4dfa1461 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -41,7 +41,7 @@ COPY internal/ internal/
 ARG TAG
 ARG COMMIT
 ARG REPO_INFO
-RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager -ldflags "-s -w -X github.com/kong/kubernetes-ingress-controller/v2/internal/metadata.Release=$TAG -X github.com/kong/kubernetes-ingress-controller/v2/internal/metadata.Commit=$COMMIT -X github.com/kong/kubernetes-ingress-controller/v2/internal/metadata.Repo=$REPO_INFO" ./internal/fipscmd/main.go
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager -ldflags "-s -w -X github.com/kong/kubernetes-ingress-controller/v2/internal/metadata.Release=$TAG -X github.com/kong/kubernetes-ingress-controller/v2/internal/metadata.Commit=$COMMIT -X github.com/kong/kubernetes-ingress-controller/v2/internal/metadata.Repo=$REPO_INFO" ./internal/cmd/fips/main.go
 
 # Build a manager binary with debug symbols and download Delve
 FROM builder as builder-delve
diff --git a/go.mod b/go.mod
index 166f7a4f2..d90add2cf 100644
--- a/go.mod
+++ b/go.mod
@@ -14,7 +14,7 @@ require (
 	github.com/google/uuid v1.3.0
 	github.com/kong/deck v1.11.0
 	github.com/kong/go-kong v0.28.1
-	github.com/kong/kubernetes-testing-framework v0.13.1
+	github.com/kong/kubernetes-testing-framework v0.13.2
 	github.com/lithammer/dedent v1.1.0
 	github.com/miekg/dns v1.1.47
 	github.com/mitchellh/mapstructure v1.4.3
@@ -56,7 +56,7 @@ require (
 	github.com/containerd/containerd v1.6.1 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/docker/distribution v2.8.0+incompatible // indirect
-	github.com/docker/docker v20.10.12+incompatible // indirect
+	github.com/docker/docker v20.10.13+incompatible // indirect
 	github.com/docker/go-connections v0.4.0 // indirect
 	github.com/docker/go-units v0.4.0 // indirect
 	github.com/evanphx/json-patch v4.12.0+incompatible // indirect
diff --git a/go.sum b/go.sum
index 58f616fa3..87115de1b 100644
--- a/go.sum
+++ b/go.sum
@@ -391,8 +391,8 @@ github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4Kfc
 github.com/docker/distribution v2.8.0+incompatible h1:l9EaZDICImO1ngI+uTifW+ZYvvz7fKISBAKpg+MbWbY=
 github.com/docker/distribution v2.8.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
 github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
-github.com/docker/docker v20.10.12+incompatible h1:CEeNmFM0QZIsJCZKMkZx0ZcahTiewkrgiwfYD+dfl1U=
-github.com/docker/docker v20.10.12+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v20.10.13+incompatible h1:5s7uxnKZG+b8hYWlPYUi6x1Sjpq2MSt96d15eLZeHyw=
+github.com/docker/docker v20.10.13+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y=
 github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
 github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
@@ -829,8 +829,8 @@ github.com/kong/deck v1.11.0 h1:qq21lY1cKuVxqjyc9+k9HL11vLXo7dhopElT5ml06wE=
 github.com/kong/deck v1.11.0/go.mod h1:pt7i/oXWUMs041YKSevCHJIN1fgmcsabJQLSrUpgBqo=
 github.com/kong/go-kong v0.28.1 h1:H23LDJSF17hfPuow5f5ts7LYeyWQHaS7aEc2wv/IOF4=
 github.com/kong/go-kong v0.28.1/go.mod h1:6FYUYx6hAkMfDbtRWw78Bfbx1cak2KsEHKkVyNWQm9I=
-github.com/kong/kubernetes-testing-framework v0.13.1 h1:Olz0Nn8n3m6xG0cdor6gmOL76TiHuWPBEjYnG+hndDk=
-github.com/kong/kubernetes-testing-framework v0.13.1/go.mod h1:BJBNAqiNqeFdWDN3T7xty2P8r3zFAEPW8cFNpCb9YFY=
+github.com/kong/kubernetes-testing-framework v0.13.2 h1:D8ve1cUx3U0RtnseqDNLn/wEAYpvzxkT5N29uimG9qM=
+github.com/kong/kubernetes-testing-framework v0.13.2/go.mod h1:LjPyW8qEarmtCnkikCHRB7h1O1ITFo1POD3JJcukXFE=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
diff --git a/hack/generators/controllers/networking/main.go b/hack/generators/controllers/networking/main.go
index c66c60793..6392f942b 100644
--- a/hack/generators/controllers/networking/main.go
+++ b/hack/generators/controllers/networking/main.go
@@ -416,8 +416,8 @@ import (
 
 	ctrlutils "github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/utils"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane"
-	"github.com/kong/kubernetes-ingress-controller/v2/internal/kubernetes/object/status"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
+	"github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object/status"
 	kongv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
 	kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
 )
diff --git a/internal/fipscmd/main.go b/internal/cmd/fips/main.go
similarity index 100%
rename from internal/fipscmd/main.go
rename to internal/cmd/fips/main.go
diff --git a/internal/controllers/configuration/zz_generated_controllers.go b/internal/controllers/configuration/zz_generated_controllers.go
index 1a9cf5546..43d45792e 100644
--- a/internal/controllers/configuration/zz_generated_controllers.go
+++ b/internal/controllers/configuration/zz_generated_controllers.go
@@ -45,8 +45,8 @@ import (
 
 	ctrlutils "github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/utils"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane"
-	"github.com/kong/kubernetes-ingress-controller/v2/internal/kubernetes/object/status"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
+	"github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object/status"
 	kongv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
 	kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
 )
diff --git a/internal/dataplane/kong_client.go b/internal/dataplane/kong_client.go
index bd4a6ce16..acf3714e8 100644
--- a/internal/dataplane/kong_client.go
+++ b/internal/dataplane/kong_client.go
@@ -15,11 +15,11 @@ import (
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/deckgen"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/parser"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane/sendconfig"
-	k8sobj "github.com/kong/kubernetes-ingress-controller/v2/internal/kubernetes/object"
-	"github.com/kong/kubernetes-ingress-controller/v2/internal/kubernetes/object/status"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/metrics"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/store"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
+	k8sobj "github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object"
+	"github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object/status"
 )
 
 // -----------------------------------------------------------------------------
diff --git a/internal/manager/controllerdef.go b/internal/manager/controllerdef.go
index 23772516c..6e68cc0e4 100644
--- a/internal/manager/controllerdef.go
+++ b/internal/manager/controllerdef.go
@@ -15,7 +15,7 @@ import (
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/gateway"
 	ctrlutils "github.com/kong/kubernetes-ingress-controller/v2/internal/controllers/utils"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane"
-	"github.com/kong/kubernetes-ingress-controller/v2/internal/kubernetes/object/status"
+	"github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object/status"
 	konghqcomv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
 )
 
diff --git a/internal/manager/run.go b/internal/manager/run.go
index 99fe83cd2..5ec2763d5 100644
--- a/internal/manager/run.go
+++ b/internal/manager/run.go
@@ -18,10 +18,10 @@ import (
 	gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
 
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/dataplane"
-	"github.com/kong/kubernetes-ingress-controller/v2/internal/kubernetes/object/status"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/manager/metadata"
 	mgrutils "github.com/kong/kubernetes-ingress-controller/v2/internal/manager/utils"
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/util"
+	"github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object/status"
 	konghqcomv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
 	configurationv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
 )


Test patch:
diff --git a/internal/kubernetes/object/set.go b/internal/util/kubernetes/object/set.go
similarity index 100%
rename from internal/kubernetes/object/set.go
rename to internal/util/kubernetes/object/set.go
diff --git a/internal/kubernetes/object/set_test.go b/internal/util/kubernetes/object/set_test.go
similarity index 100%
rename from internal/kubernetes/object/set_test.go
rename to internal/util/kubernetes/object/set_test.go
diff --git a/internal/kubernetes/object/status/queue.go b/internal/util/kubernetes/object/status/queue.go
similarity index 100%
rename from internal/kubernetes/object/status/queue.go
rename to internal/util/kubernetes/object/status/queue.go
diff --git a/internal/kubernetes/object/status/queue_test.go b/internal/util/kubernetes/object/status/queue_test.go
similarity index 100%
rename from internal/kubernetes/object/status/queue_test.go
rename to internal/util/kubernetes/object/status/queue_test.go
diff --git a/internal/test/util/controller_manager.go b/internal/util/test/controller_manager.go
similarity index 99%
rename from internal/test/util/controller_manager.go
rename to internal/util/test/controller_manager.go
index b62364db2..2a2cbcea2 100644
--- a/internal/test/util/controller_manager.go
+++ b/internal/util/test/controller_manager.go
@@ -1,4 +1,4 @@
-package util
+package test
 
 import (
 	"context"
diff --git a/internal/test/util/crds.go b/internal/util/test/crds.go
similarity index 99%
rename from internal/test/util/crds.go
rename to internal/util/test/crds.go
index 86e4d6a55..af9364c6b 100644
--- a/internal/test/util/crds.go
+++ b/internal/util/test/crds.go
@@ -1,4 +1,4 @@
-package util
+package test
 
 import (
 	"bytes"
diff --git a/internal/test/util/webhooks.go b/internal/util/test/webhooks.go
similarity index 99%
rename from internal/test/util/webhooks.go
rename to internal/util/test/webhooks.go
index 9449f4d39..abfcd76e4 100644
--- a/internal/test/util/webhooks.go
+++ b/internal/util/test/webhooks.go
@@ -1,4 +1,4 @@
-package util
+package test
 
 const (
 	// KongSystemServiceCert is a testing TLS certificate with SAN *.kong-system.svc.
diff --git a/test/conformance/suite_test.go b/test/conformance/suite_test.go
index 83f583ab3..4cff95791 100644
--- a/test/conformance/suite_test.go
+++ b/test/conformance/suite_test.go
@@ -16,7 +16,7 @@ import (
 	"github.com/kong/kubernetes-testing-framework/pkg/clusters/types/kind"
 	"github.com/kong/kubernetes-testing-framework/pkg/environments"
 
-	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/test/util"
+	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/util/test"
 )
 
 var (
diff --git a/test/e2e/istio_test.go b/test/e2e/istio_test.go
index dd1a6fb7f..709db7bbd 100644
--- a/test/e2e/istio_test.go
+++ b/test/e2e/istio_test.go
@@ -28,7 +28,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
-	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/test/util"
+	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/util/test"
 	kongv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
 	"github.com/kong/kubernetes-ingress-controller/v2/pkg/clientset"
 )
diff --git a/test/integration/suite_test.go b/test/integration/suite_test.go
index cbeb76079..cb235e43e 100644
--- a/test/integration/suite_test.go
+++ b/test/integration/suite_test.go
@@ -22,7 +22,7 @@ import (
 	"k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
-	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/test/util"
+	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/util/test"
 )
 
 // -----------------------------------------------------------------------------
diff --git a/test/integration/webhook_test.go b/test/integration/webhook_test.go
index 1b7fb8794..038bbaa8a 100644
--- a/test/integration/webhook_test.go
+++ b/test/integration/webhook_test.go
@@ -22,7 +22,7 @@ import (
 	"k8s.io/apimachinery/pkg/util/intstr"
 
 	"github.com/kong/kubernetes-ingress-controller/v2/internal/annotations"
-	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/test/util"
+	testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/util/test"
 	kongv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
 	"github.com/kong/kubernetes-ingress-controller/v2/pkg/clientset"
 )