1
0
Fork 0
mirror of https://github.com/imjasonh/client-go2 synced 2026-07-07 00:33:49 +00:00
Commit graph

61 commits

Author SHA1 Message Date
Jason Hall
245a7bff43
Merge pull request #14 from imjasonh/dependabot/github_actions/actions/checkout-6
chore(deps): bump actions/checkout from 5 to 6
2025-12-08 23:53:34 -05:00
Jason Hall
c5bf84f538
Merge pull request #13 from imjasonh/dependabot/github_actions/golangci/golangci-lint-action-9
chore(deps): bump golangci/golangci-lint-action from 8 to 9
2025-12-08 23:52:30 -05:00
Jason Hall
526cfdb072
Merge branch 'main' into dependabot/github_actions/actions/checkout-6 2025-12-08 23:51:30 -05:00
Jason Hall
61457684ba
Merge pull request #11 from imjasonh/dependabot/github_actions/actions/setup-go-6
chore(deps): bump actions/setup-go from 5 to 6
2025-12-08 23:50:35 -05:00
Jason Hall
4744363404
Merge branch 'main' into dependabot/github_actions/golangci/golangci-lint-action-9 2025-12-08 23:50:28 -05:00
Jason Hall
cb171be2dd
Merge branch 'main' into dependabot/github_actions/actions/checkout-6 2025-12-08 23:50:23 -05:00
Jason Hall
194b7edc08
Merge pull request #17 from imjasonh/copilot/remove-buildtag-line
[WIP] Remove unnecessary +build lines from test files
2025-12-08 23:50:09 -05:00
copilot-swe-agent[bot]
98685bb419 Remove obsolete +build directives from e2e test files
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
2025-12-09 04:46:20 +00:00
copilot-swe-agent[bot]
b20e4f8c62 Initial plan 2025-12-09 04:40:48 +00:00
Jason Hall
9d18ec1520
Merge pull request #12 from imjasonh/dependabot/go_modules/k8s-dependencies-496cdf6fe6
chore(deps): bump the k8s-dependencies group with 3 updates
2025-12-08 23:39:37 -05:00
dependabot[bot]
53acbea0c3
chore(deps): bump the k8s-dependencies group with 3 updates
Bumps the k8s-dependencies group with 3 updates: [k8s.io/api](https://github.com/kubernetes/api), [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go).


Updates `k8s.io/api` from 0.34.0 to 0.34.1
- [Commits](https://github.com/kubernetes/api/compare/v0.34.0...v0.34.1)

Updates `k8s.io/apimachinery` from 0.34.0 to 0.34.1
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.34.0...v0.34.1)

Updates `k8s.io/client-go` from 0.34.0 to 0.34.1
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.34.0...v0.34.1)

---
updated-dependencies:
- dependency-name: k8s.io/api
  dependency-version: 0.34.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-dependencies
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.34.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-dependencies
- dependency-name: k8s.io/client-go
  dependency-version: 0.34.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 10:46:10 +00:00
Jason Hall
30376e8172
Merge pull request #15 from imjasonh/crds
Add CRD support to generic client
2025-12-07 02:06:00 -05:00
Jason Hall
70fae081b2 Add CRD support to generic client
- Fix parameter encoding for CRDs by using core v1 GroupVersion
- Add AbsPath-based request construction for CRD operations (Get, Inform, UpdateStatus)
- Make WatchOwned generic over owned resource type O
- Rename ReconcileKind -> Reconcile in controller interface

For CRDs, NewClientGVR now sets APIPath to full path (/apis/group/version) and GroupVersion to core v1, ensuring metav1 types like ListOptions encode correctly while still accessing the correct CRD endpoint.

Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-12-07 02:00:56 -05:00
dependabot[bot]
37e359e291
chore(deps): bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 11:07:27 +00:00
dependabot[bot]
a683cdf791
chore(deps): bump golangci/golangci-lint-action from 8 to 9
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 8 to 9.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v8...v9)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-version: '9'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-10 13:24:36 +00:00
Jason Hall
02a0d2efc8
Merge pull request #10 from imjasonh/dependabot/go_modules/k8s-dependencies-9b98bb80d7 2025-10-21 07:39:06 -04:00
dependabot[bot]
cb52e5ea7c
chore(deps): bump actions/setup-go from 5 to 6
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 11:02:46 +00:00
dependabot[bot]
ac9af29fa2
chore(deps): bump the k8s-dependencies group with 2 updates
Bumps the k8s-dependencies group with 2 updates: [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go).


Updates `k8s.io/apimachinery` from 0.33.4 to 0.34.0
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.33.4...v0.34.0)

Updates `k8s.io/client-go` from 0.33.4 to 0.34.0
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.33.4...v0.34.0)

---
updated-dependencies:
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: k8s-dependencies
- dependency-name: k8s.io/client-go
  dependency-version: 0.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: k8s-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 11:00:12 +00:00
Jason Hall
cb2c71d445
Merge pull request #9 from imjasonh/dependabot/github_actions/actions/checkout-5
chore(deps): bump actions/checkout from 4 to 5
2025-08-19 12:31:25 -04:00
Jason Hall
b0e4703e84
Merge pull request #8 from imjasonh/dependabot/go_modules/k8s-dependencies-53e96f5bee
chore(deps): bump the k8s-dependencies group with 3 updates
2025-08-19 12:31:05 -04:00
dependabot[bot]
c6d9d13109
chore(deps): bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-18 17:53:15 +00:00
dependabot[bot]
11134b8e03
chore(deps): bump the k8s-dependencies group with 3 updates
Bumps the k8s-dependencies group with 3 updates: [k8s.io/api](https://github.com/kubernetes/api), [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go).


Updates `k8s.io/api` from 0.33.3 to 0.33.4
- [Commits](https://github.com/kubernetes/api/compare/v0.33.3...v0.33.4)

Updates `k8s.io/apimachinery` from 0.33.3 to 0.33.4
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.33.3...v0.33.4)

Updates `k8s.io/client-go` from 0.33.3 to 0.33.4
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.33.3...v0.33.4)

---
updated-dependencies:
- dependency-name: k8s.io/api
  dependency-version: 0.33.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-dependencies
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.33.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-dependencies
- dependency-name: k8s.io/client-go
  dependency-version: 0.33.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-18 16:01:13 +00:00
Jason Hall
3264d2dfa4
Merge pull request #7 from imjasonh/imjasonh-patch-1
Update README.md
2025-07-28 17:00:09 -04:00
Jason Hall
7ec3c06f9a
Update README.md 2025-07-28 16:57:56 -04:00
Jason Hall
6c7409049e
Fix controller example to implement correct interface method (#6)
* Fix controller example to implement correct interface method

- Change ReconcileKind to Reconcile to match the Reconciler interface
- Add nil check for secretLister to handle initialization timing
- Fix OnError handler in e2e test to not fail immediately on expected errors

This allows the controller-owned-lister example to compile and run correctly.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Update examples/controller-owned-lister/main.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-28 19:57:12 +00:00
Jason Hall
da1a422278
Merge pull request #5 from imjasonh/add-controller-framework
Add generic controller framework inspired by Knative
2025-07-28 15:17:43 -04:00
Jason Hall
2f443ee72b
Add lister functionality and improve controller framework
- Add Lister and NamespaceLister as concrete structs (not interfaces)
- Implement cache-backed List/Get operations with type safety
- Add lister support to Inform method, returning (*Lister[T], error)
- Update controller to store owned resource listers
- Add example showing how to use listers with controllers
- Fix error logging in examples to use log.Fatal instead of log.Printf
- Fix flaky e2e test by changing OnError handler to not fail immediately
- Update WatchOwned to automatically get owner GVK from client

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 15:13:22 -04:00
Jason Hall
e5b7ad1a0d
Add generic controller framework inspired by Knative
This PR introduces a new controller package that provides a simple, type-safe
framework for building Kubernetes controllers. The implementation is inspired
by Knative's controller patterns but optimized for simplicity.

Key features:
- Simple reconciler interface with just one method (ReconcileKind)
- Automatic detection and persistence of object changes
- Built-in conflict resolution with retry logic
- Owner reference support for watching owned resources
- Error handling patterns (RequeueAfter, RequeueImmediately, PermanentError)
- Context-aware logging with clog integration
- Full test coverage including e2e tests

The framework handles the complexity of update detection, conflict resolution,
and status updates automatically, allowing users to focus on their business logic.

Also includes:
- Comprehensive documentation in controller/README.md
- Example controller implementation in examples/controller/
- Updates to use errors.Is pattern for error checking
- Minor refactoring to use "if err := ..." idiom where appropriate

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 13:01:24 -04:00
Jason Hall
f39381e7db
Fix ProxyGet to use net.JoinSchemeNamePort for proper URL construction (#4)
This change updates the ProxyGet implementations for both PodClient and
ServiceClient to use k8s.io/apimachinery/pkg/util/net.JoinSchemeNamePort,
matching the behavior of the official client-go library.

The function properly handles empty ports and scheme values:
- Empty scheme and port: returns just the name
- Empty scheme with port: returns "name:port"
- With scheme and port: returns "scheme:name:port"

This ensures compatibility with Kubernetes proxy endpoints and allows
users to omit the port when not needed.

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-28 14:59:53 +00:00
Jason Hall
87b4da941a
Add expansion methods and missing client-go operations (#3)
This PR adds support for resource-specific expansion methods and implements
missing standard client-go operations to achieve feature parity.

## New Features

### Expansion Methods
- Added PodClient with methods: GetLogs, Bind, Evict, ProxyGet
- Added ServiceClient with method: ProxyGet
- Both clients implement the official k8s.io/client-go expansion interfaces
- Runtime type assertions ensure type safety (panic if wrong type)

### Missing Standard Methods
- Watch: Watch resources with optional label/field selectors
- DeleteCollection: Delete multiple resources matching criteria
- UpdateStatus: Update only the status subresource

### Other Improvements
- Refactored all tests to use inline configuration pattern
- Added comprehensive e2e tests for new functionality
- Updated documentation with examples
- Fixed linting error in stream.Close() handling

## Design Decisions

The expansion methods follow a namespace-scoped pattern where calling
`client.PodClient("namespace")` returns a client that implements the
standard client-go PodExpansion interface. This maintains full API
compatibility while providing type safety through runtime assertions.

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-28 14:35:31 +00:00
Jason Hall
63505cf9fd
update readme
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-07-27 17:28:29 -04:00
Jason Hall
4675498f7c
Merge pull request #2 from imjasonh/dependabot/go_modules/k8s-dependencies-e15c065dcb
chore(deps): bump the k8s-dependencies group with 2 updates
2025-07-27 17:25:40 -04:00
Jason Hall
b8a421fa95
Merge branch 'main' into dependabot/go_modules/k8s-dependencies-e15c065dcb 2025-07-27 17:22:00 -04:00
Jason Hall
46ff633b0e
fix CI again
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-07-27 17:21:03 -04:00
dependabot[bot]
1d30b996c9
chore(deps): bump the k8s-dependencies group with 2 updates
Bumps the k8s-dependencies group with 2 updates: [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go).


Updates `k8s.io/apimachinery` from 0.31.11 to 0.33.3
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.31.11...v0.33.3)

Updates `k8s.io/client-go` from 0.31.11 to 0.33.3
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.31.11...v0.33.3)

---
updated-dependencies:
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.33.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: k8s-dependencies
- dependency-name: k8s.io/client-go
  dependency-version: 0.33.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: k8s-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-27 21:17:52 +00:00
Jason Hall
bf141053f3
chore: Add Dependabot configuration for Go and GitHub Actions
- Configure weekly updates for Go modules
- Configure weekly updates for GitHub Actions
- Group Kubernetes dependencies (k8s.io/*) together
- Set update schedule for Mondays at 10:00 UTC
- Add appropriate labels for dependency PRs

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-27 17:16:28 -04:00
Jason Hall
9eaff0dc42
simplify patch
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-07-27 17:14:13 -04:00
Jason Hall
e5071fc0cf
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>
2025-07-27 17:13:22 -04:00
Jason Hall
d2b0d467e5
fix CI
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-07-27 16:35:38 -04:00
Jason Hall
fb8305a316
Refactor to use rest.Client directly instead of dynamic client
This major refactoring eliminates the dependency on the dynamic client
and unstructured types, using rest.RESTClient directly for all operations.

Key changes:
- Replace dynamic.Interface with rest.RESTClient in client struct
- Remove all unstructured.Unstructured conversions
- Use direct JSON marshaling/unmarshaling for type conversions
- Update all CRUD methods (List, Get, Create, Update, Delete, Patch)
- Reimplement Inform to use cache.ListWatch with rest client
- Export Client type and update method signatures
- Add proper GroupVersion and APIPath configuration in NewClientGVR
- Update all tests to use mock HTTP transport instead of fake dynamic client
- Fix informer event handler to use new InformerHandler type
- Update example code to demonstrate new API

Benefits:
- More efficient: eliminates unnecessary type conversions
- Cleaner code: direct use of REST client
- Better performance: reduced JSON marshaling overhead
- Type safety maintained through generics

All unit tests and e2e tests pass against a real Kubernetes cluster.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-27 16:33:45 -04:00
Jason Hall
cf4e05003b
README
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-07-23 16:33:24 -04:00
Jason Hall
4b9bb6db4d
Add CLAUDE.md for repository guidance
Provides comprehensive guidance for Claude Code when working with this
repository, including build/test commands, architecture overview, and
important coding rules.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 16:00:41 -04:00
Jason Hall
9eaaec04da
Update build.yaml 2025-07-23 11:45:58 -04:00
Jason Hall
74aace1a2d
Update to use stable Go and add comprehensive CI/CD
- Replace gotip with stable Go in GitHub Actions
- Add automatic GVR inference for Kubernetes types
- Rename API: NewClient (inferred GVR) and NewClientGVR (explicit)
- Add comprehensive test coverage including e2e tests
- Update CI to include linting, unit tests, and e2e tests with kind
- Add .gitignore for common Go development files
- Update README with usage examples and features

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 11:41:20 -04:00
Jason Hall
d6bb3cc61c
Update client-go2 with enhanced functionality and modern dependencies
- Fix syntax error in Inform method (< to ,)
- Add missing CRUD operations: Update, Delete, and Patch methods
- Add comprehensive test coverage for all client operations
- Update Kubernetes dependencies from v0.21.1 to v0.31.11
- Update Go version requirement to 1.22.0
- Update README to remove outdated Go 1.18 beta references
- Improve error handling and logging

The client now provides full CRUD functionality with type-safe generic
operations for any Kubernetes resource type, significantly reducing
boilerplate compared to traditional client-go usage.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 09:39:08 -04:00
Jason Hall
dca6437adb
Create LICENSE 2022-09-21 15:00:38 -04:00
Jason Hall
384f6ed83f add fancy badge 2021-12-15 12:18:41 -05:00
Jason Hall
fbf85d4793 make event handler configuration the caller's responsibility, maybe they want to enqueue the event 2021-12-15 12:17:04 -05:00
Jason Hall
8736289eac update README 2021-12-15 12:09:18 -05:00
Jason Hall
da349520ce Merge branch 'main' of github.com:imjasonh/client-go2 2021-12-15 12:05:55 -05:00