ansh0014 commented on issue #6612:
URL: https://github.com/apache/camel-k/issues/6612#issuecomment-7253846688
hey@squakez I compared `camel-monitor-operator/pkg/internal/fake.go` with
Camel K's `pkg/internal/client.go` to map out the scope:
- `NewFakeClient` currently has ~304 usages across `pkg/`, and still backs
`CamelV1()` (~46 usages), `AddReactor`/`PrependReactor` (~19 usages), and
`Discovery()`/`AuthorizationV1()` via `fakecamelclientset` and `fakeclientset`.
- Around ~83 test object declarations manually specify `TypeMeta`.
To keep this manageable and reviewable without breaking existing `CamelV1()`
/ `Reactor` tests right away, I propose a phased approach:
1. **Refactor `pkg/internal/client.go` (non-breaking):**
- Switch from the global `clientscheme.Scheme` to an isolated
`runtime.NewScheme()` per fake client.
- Ensure `TypeMeta` / GVK is resolved automatically from the scheme for
objects passed to `NewFakeClient` (and use `WithObjects` where applicable), so
tests no longer need to declare `TypeMeta`.
- Register `WithStatusSubresource` for all Camel CRDs consistently.
2. **Clean up `TypeMeta` in unit tests:**
- Remove manual `TypeMeta` declarations across `pkg/**/*_test.go` (either
in this PR or split by package if too large).
3. **Post-v3 follow-up:**
- Gradually replace remaining `CamelV1()` / `Reactor` usages with
`ctrl.Client` + `interceptor.Funcs` so `fakecamelclientset` can be dropped
completely.
WDYT about starting with Step 1 in a draft PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]