https://github.com/uthark/dynakube
Kubernetes Test client with dynamic behavior
https://github.com/uthark/dynakube
Last synced: 6 months ago
JSON representation
Kubernetes Test client with dynamic behavior
- Host: GitHub
- URL: https://github.com/uthark/dynakube
- Owner: uthark
- License: apache-2.0
- Created: 2020-12-03T02:43:43.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T18:36:44.000Z (over 1 year ago)
- Last Synced: 2025-03-28T19:38:23.065Z (over 1 year ago)
- Language: Go
- Size: 233 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dynakube
Kubernetes Test client with dynamic behavior
This client simplifies testing controllers with dynamic behaviour.
## How to use
```
// initial state of the store.
d := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Name: "foo",
},
}
client := dynakube.NewDynamicClient(clientScheme, d)
// register custom reactors if you want to customize the behavior.
client.PrependReactor("update", "deployments", func(action t.Action) (bool, runtime.Object, error) {
return true, nil, &errors.StatusError{ErrStatus: metav1.Status{Code: 500}}
})
// run your reconciler.
r := NewReconciler(client)
name := types.NamespacedName{Namespace: "test", Name: "foo"}
_, err := r.Reconcile(context.Background(), controllers.Request{NamespacedName: name})
Expect(err).ToNot(BeNil())
```
## Notes
This project reuses code from [k8s.io/client-go](https://github.com/kubernetes/client-go) package.