refactor(ops): depend on kubernetesjs and reuse its APIClient - #40
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review complete. 🟡 2 medium 💬 Inline comments (1)
📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Dashboard passes removed The These become excess-property type errors and the values are silently discarded at runtime. Because the dashboard is excluded from This PR consolidates the duplicated
Reviewed commit: 8f0fcad |
There was a problem hiding this comment.
Refactors @kubernetesjs/ops to reuse the kubernetesjs APIClient, deleting the local APIClient and switching imports to the kubernetesjs/client package, but leaves kubeconfig/context options silently ignored and in-repo dashboard consumers passing removed constructor fields.
Key findings
- 🟡 Dashboard passes removed
kubeconfig/contexttoKubernetesClient— kubernetes-client.ts - 🟡
kubeconfig/contextsilently ignored byClient— client.ts:46
| this.kubeClient = new KubernetesClient({ | ||
| kubeconfig: ctx.kubeconfig, | ||
| namespace: ctx.namespace, | ||
| context: ctx.context, | ||
| restEndpoint: ctx.restEndpoint || 'http://127.0.0.1:8001' | ||
| }); |
There was a problem hiding this comment.
🟡 bug · medium
kubeconfig/context silently ignored by Client
The Client constructor now forwards only restEndpoint to KubernetesClient, so the kubeconfig and context fields on the public KubernetesContext interface are silently discarded and every request targets restEndpoint (default http://127.0.0.1:8001) (packages/client/src/client.ts:46-48).
The --kubeconfig and --context CLI flags in packages/ops-cli/src/index.ts at lines 28-29 still pass these values through, so a user selecting a non-default cluster gets a client silently wired to the proxy instead. The PR removed the forwarding without reconciling the interface, leaving a misleading contract.
📋 Prompt for AI Agents
In packages/client/src/client.ts, the Client constructor (lines 44-48) no longer forwards kubeconfig/context to KubernetesClient, yet KubernetesContext (lines 28-35) still declares kubeconfig and context, and packages/ops-cli commands (setup.ts:180-186, deploy.ts:111-117, delete.ts, status.ts, teardown.ts) pass --kubeconfig/--context expecting cluster selection. Either (a) remove kubeconfig and context from KubernetesContext and stop passing them from the ops-cli commands and index.ts flags, or (b) implement real kubeconfig/context loading in the KubernetesClient. Do not leave public options that are silently ignored.
Summary
Makes
kubernetesjsa real (published) dependency of@kubernetesjs/opsand drops ops's duplicated HTTP transport in favor of the core one — no schema-sdk changes needed, sincenpmApiClientalready accepts an arbitrary import specifier:packages/ops/src/client.tsdeleted; the regeneratedsrc/index.tsnow importsAPIClient/APIClientOptions/APIClientRequestOptsfromkubernetesjs/client(only the import line changed in the generated output).packages/ops/package.jsongains"kubernetesjs": "workspace:^", so on publishkubernetesjsbecomes a subdep of@kubernetesjs/ops.token/headers/timeoutoptions,getInClusterConfig()), instead of the older stale copy.@kubernetesjs/client'sClientstopped passingkubeconfig/namespace/contexttonew KubernetesClient(...)— those fields existed only in ops's oldAPIClientOptionsand were never read by the transport (dead options); the coreAPIClientOptionsdoesn't declare them.Not done here (would require a schema-sdk feature): importing the core k8s types (
ObjectMeta,Pod, …) fromkubernetesjsinstead of re-emitting them into ops's generatedindex.ts— schema-sdk currently has no "external types" option, so the generated type surface is unchanged.Verified with
pnpm buildandpnpm lintacross the workspace (what CI runs).Link to Devin session: https://app.devin.ai/sessions/95f4ed628067485ebab80535c50d6e88
Requested by: @pyramation