2021-11-13 07:25:55 -05:00
## Experimenting with `k8s.io/client-go` and Go generics
2021-09-09 12:29:21 -04:00
2021-12-15 12:18:41 -05:00
[](https://github.com/imjasonh/client-go2/actions/workflows/build.yaml)
2025-07-27 17:28:22 -04:00
This is an experimental type-parameter-aware client that wraps [`k8s.io/client-go/rest` ](https://pkg.go.dev/k8s.io/client-go/rest ), in [about 500 lines of mostly-vibe-coded Go ](./generic/client.go ).
2021-09-09 12:29:21 -04:00
2025-07-23 11:41:20 -04:00
## Features
- **Type-safe generic client** - Work with strongly-typed Kubernetes objects instead of `unstructured.Unstructured`
2025-07-23 16:33:24 -04:00
- **Zero code generation** - Uses Go generics instead of code generation
2025-07-23 11:41:20 -04:00
- **Full CRUD operations** - List, Get, Create, Update, Delete, and Patch support
- **Informer support** - Watch for changes with type-safe event handlers
2025-07-23 16:33:24 -04:00
- **Automatic GVR inference** - No need to manually specify GroupVersionResource for standard Kubernetes types
2025-07-23 11:41:20 -04:00
## Usage
2025-07-27 17:28:22 -04:00
See [the example ](./main.go )
2025-07-23 11:41:20 -04:00
2025-07-27 17:28:22 -04:00
## Testing
2025-07-23 11:41:20 -04:00
2025-07-27 17:28:22 -04:00
Unit tests against a mock REST client:
2021-09-09 12:29:21 -04:00
```
2025-07-27 17:28:22 -04:00
make test
2025-07-23 11:41:20 -04:00
```
2025-07-27 17:28:22 -04:00
End-to-end tests against a real K8s cluster:
2025-07-23 11:41:20 -04:00
```
2025-07-27 17:28:22 -04:00
make e2e
2021-09-09 12:29:21 -04:00
```
2025-07-27 17:28:22 -04:00
# ⚠️ THIS IS AN EXPERIMENT
This is just for demo purposes.
2021-09-09 12:29:21 -04:00
The name `client-go2` is a placeholder, and a joke.