1
0
Fork 0
mirror of https://github.com/imjasonh/client-go2 synced 2026-07-18 06:37:34 +00:00

Add support for label and field selectors in informers

- Add InformOptions struct with ListOptions and ResyncPeriod fields
- Update all client methods to accept options parameters
- Add comprehensive examples in main.go demonstrating:
  - Label selector filtering (test=example)
  - Field selector filtering (status.phase=Running)
  - Custom resync periods
- Add tests for label and field selectors with mock query parameter support
- Fix nil pointer handling in all client methods
- Update mock transport to handle query parameters correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-07-27 17:13:22 -04:00
parent d2b0d467e5
commit e5071fc0cf
Failed to extract signature
6 changed files with 445 additions and 64 deletions

View file

@ -121,7 +121,7 @@ func TestNewClientE2E(t *testing.T) {
}
// Try to list pods in default namespace
pods, err := client.List(ctx, "default")
pods, err := client.List(ctx, "default", nil)
if err != nil {
t.Fatalf("failed to list pods: %v", err)
}
@ -136,7 +136,7 @@ func TestNewClientE2E(t *testing.T) {
}
// Try to list configmaps in default namespace
cms, err := client.List(ctx, "default")
cms, err := client.List(ctx, "default", nil)
if err != nil {
t.Fatalf("failed to list configmaps: %v", err)
}
@ -151,7 +151,7 @@ func TestNewClientE2E(t *testing.T) {
}
// Try to list services in default namespace
svcs, err := client.List(ctx, "default")
svcs, err := client.List(ctx, "default", nil)
if err != nil {
t.Fatalf("failed to list services: %v", err)
}
@ -226,7 +226,7 @@ func TestInformE2E(t *testing.T) {
},
}
client.Inform(ctx, handler)
client.Inform(ctx, handler, nil)
// Create a test ConfigMap
testCM := &corev1.ConfigMap{
@ -239,14 +239,14 @@ func TestInformE2E(t *testing.T) {
},
}
created, err := client.Create(ctx, "default", testCM)
created, err := client.Create(ctx, "default", testCM, nil)
if err != nil {
t.Fatalf("failed to create test configmap: %v", err)
}
testCM = created
defer func() {
// Clean up
if err := client.Delete(ctx, "default", testCM.Name); err != nil {
if err := client.Delete(ctx, "default", testCM.Name, nil); err != nil {
t.Logf("failed to delete test configmap: %v", err)
}
}()
@ -268,7 +268,7 @@ func TestInformE2E(t *testing.T) {
// Update the ConfigMap
testCM.Data["test"] = "updated"
updated, err := client.Update(ctx, "default", testCM)
updated, err := client.Update(ctx, "default", testCM, nil)
if err != nil {
t.Fatalf("failed to update test configmap: %v", err)
}