-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add envtests unit test for HTTPRouteReconciler
- Loading branch information
Showing
13 changed files
with
707 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/go-logr/logr" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
) | ||
|
||
type Reconciler interface { | ||
SetupWithManager(ctrl.Manager) error | ||
SetLogger(logr.Logger) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package gateway | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
k8sobj "github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object" | ||
) | ||
|
||
// DataPlane is a common interface that is used by reconcilers to interact | ||
// with the dataplane. | ||
// | ||
// TODO: This can probably be used in other reconcilers as well. | ||
// Related issue: https://github.com/Kong/kubernetes-ingress-controller/issues/3794 | ||
type DataPlane interface { | ||
DataPlaneClient | ||
|
||
AreKubernetesObjectReportsEnabled() bool | ||
KubernetesObjectConfigurationStatus(obj client.Object) k8sobj.ConfigurationStatus | ||
} | ||
|
||
// DataPlaneClient is a common client interface that is used by reconcilers to interact | ||
// with the dataplane to perform CRUD operations on provided objects. | ||
type DataPlaneClient interface { | ||
UpdateObject(obj client.Object) error | ||
DeleteObject(obj client.Object) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package gateway | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
k8sobj "github.com/kong/kubernetes-ingress-controller/v2/internal/util/kubernetes/object" | ||
) | ||
|
||
type DataplaneMock struct { | ||
KubernetesObjectReportsEnabled bool | ||
// Mapping namespace to name to status | ||
// Note: this will come in useful when implementing | ||
// https://github.com/Kong/kubernetes-ingress-controller/issues/3793 | ||
// which requires the status to be reported for route objects. | ||
ObjectsStatuses map[string]map[string]k8sobj.ConfigurationStatus | ||
} | ||
|
||
func (d DataplaneMock) UpdateObject(_ client.Object) error { | ||
return nil | ||
} | ||
|
||
func (d DataplaneMock) DeleteObject(_ client.Object) error { | ||
return nil | ||
} | ||
|
||
func (d DataplaneMock) AreKubernetesObjectReportsEnabled() bool { | ||
return d.KubernetesObjectReportsEnabled | ||
} | ||
|
||
func (d DataplaneMock) KubernetesObjectConfigurationStatus(obj client.Object) k8sobj.ConfigurationStatus { | ||
return d.ObjectsStatuses[obj.GetNamespace()][obj.GetName()] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.