Documentation ¶
Index ¶
- func CaptureReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan ReconcileCall)
- func CaptureWebhook(mgr manager.Manager, inner admission.Handler) (admission.Handler, chan HandleCall)
- func CreateNamespace(clientset *kubernetes.Clientset) (string, func())
- func Drain(calls chan ReconcileCall)
- func HandleResource(namespace, name string) types.GomegaMatcher
- func MustController(ctrl controller.Controller, err error) controller.Controller
- func MustWebhook(wh *admission.Webhook, err error) *admission.Webhook
- func NewServer(mgr manager.Manager, awhs ...*admission.Webhook) *webhook.Server
- func ReconcileNoRetry() types.GomegaMatcher
- func ReconcileResource(namespace, name string) types.GomegaMatcher
- func ReconcileResourceSuccess(namespace, name string) types.GomegaMatcher
- func ReconcileSuccessfully() types.GomegaMatcher
- func StartAPIServer(crdDirectoryPath string) (*rest.Config, *envtest.Environment, *kubernetes.Clientset)
- func StartTestManager(ctx context.Context, cfg *rest.Config) manager.Manager
- type HandleCall
- type ReconcileCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureReconcile ¶
func CaptureReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan ReconcileCall)
CaptureReconcile wraps the given reconciler and returns a channel that emits all reconciliation calls that the inner reconciler has received.
func CaptureWebhook ¶
func CaptureWebhook(mgr manager.Manager, inner admission.Handler) (admission.Handler, chan HandleCall)
CaptureWebhook wraps the given handler and returns a handler that, when called, will send a record of the request and response it received down the given channel. This can be used to test webhooks inside of integration tests.
func CreateNamespace ¶
func CreateNamespace(clientset *kubernetes.Clientset) (string, func())
CreateNamespace creates a test namespace with a random name for use in integration tests. We return the name of the namespace and a closure that can be used to destroy the namespace.
func Drain ¶
func Drain(calls chan ReconcileCall)
Drain can be used to drain all calls from the channel before continuing with a test
func HandleResource ¶
func HandleResource(namespace, name string) types.GomegaMatcher
func MustController ¶
func MustController(ctrl controller.Controller, err error) controller.Controller
MustController cleans up tests when you just want to create a controller and don't care what the error might be.
func MustWebhook ¶
MustWebhook cleans up tests when you just want to create a webhook and don't care what the error might be.
func NewServer ¶
NewServer generates a webhook server attached to the given manager that listens on an ephemeral localhost port. It should be used in integration tests to register webhooks into the api-server that point at localhost, allowing us to test the functionality against a local server.
The value in using NewServer is to provide a simple API to install webhooks into a cluster and ensure that once called, both the server and webhooks are all running correctly.
func ReconcileNoRetry ¶
func ReconcileNoRetry() types.GomegaMatcher
func ReconcileResource ¶
func ReconcileResource(namespace, name string) types.GomegaMatcher
func ReconcileResourceSuccess ¶
func ReconcileResourceSuccess(namespace, name string) types.GomegaMatcher
func ReconcileSuccessfully ¶
func ReconcileSuccessfully() types.GomegaMatcher
func StartAPIServer ¶
func StartAPIServer(crdDirectoryPath string) (*rest.Config, *envtest.Environment, *kubernetes.Clientset)
StartAPIServer creates a fake Kubernetes API server that can be used for integration testing Kubernetes controllers. Returns the rest.Config that can be used to connect to the API server.
Types ¶
type HandleCall ¶
HandleCall is a record of each request received and response provided by a webhook handler. This can be used to assert against the behaviour of a webhook handler from outside of the manager.
type ReconcileCall ¶
ReconcileCall is a record of each requested reconciliation, both the request and the returned response/error. This can be used to assert against the behaviour of a reconciliation loop.