Skip to content

codegen: generate go clients for custom resource routes#1283

Merged
amalavet merged 21 commits intomainfrom
ale/clients
Mar 13, 2026
Merged

codegen: generate go clients for custom resource routes#1283
amalavet merged 21 commits intomainfrom
ale/clients

Conversation

@amalavet
Copy link
Copy Markdown
Contributor

@amalavet amalavet commented Mar 11, 2026

What Changed? Why?

Previously, the SDK only generated Go clients for individual resource kinds
(CRUD operations + kind-level custom routes). However, manifest versions can
also define custom routes at the routes.namespaced and routes.cluster level —
scoped to a Group/Version rather than a specific kind — and no client was
generated for those.

This PR adds codegen support for Group/Version-level custom route clients.
When a manifest version defines routes in routes.namespaced or routes.cluster,
a CustomRouteClient is now generated in the version package (e.g.
pkg/generated/v1alpha1/client_gen.go) with typed methods for each route.

Key Changes

  • codegen/jennies/goclients.go: Split Generate into generateResourceClients
    (existing per-kind clients) and generateCustomRouteClients (new GV-level
    clients). The new generator iterates over manifest versions and emits a client
    file if any namespaced or clustered routes are present.
  • codegen/templates/client.tmpl: New template for the CustomRouteClient
    struct, with typed *Request/*Response wrapper methods for namespaced and
    clustered routes. Uses NewCustomRouteClientFromGenerator to construct the
    client from a resource.ClientGenerator.
  • resource/client.go: Added CustomRouteClient interface (NamespacedRequest /
    ClusteredRequest) and extended ClientGenerator with
    GetCustomRouteClient(schema.GroupVersion, string).
  • k8s/custom_route_client.go: Concrete CustomRouteClient implementation backed
    by the existing groupVersionClient.
  • k8s/client_registry.go: Wired GetCustomRouteClient into the registry so
    callers can obtain a CustomRouteClient for any registered GV.

Addresses Issue #1277

How was it tested?

  • Codegen golden file tests
  • Local generation against example apiserver kinds
  • Manual client setup and live requests to the example apiserver

remove unused

add testing client and fix bug

save progress on testing

cleanup

cleanup testing

basic

cleanups

remove
@amalavet amalavet marked this pull request as ready for review March 12, 2026 17:51
@amalavet amalavet requested a review from a team as a code owner March 12, 2026 17:51
@amalavet amalavet requested a review from charandas March 12, 2026 17:51
@amalavet amalavet enabled auto-merge (squash) March 13, 2026 15:59
@amalavet amalavet removed the request for review from charandas March 13, 2026 16:01
@amalavet amalavet merged commit b0513a6 into main Mar 13, 2026
17 checks passed
@amalavet amalavet deleted the ale/clients branch March 13, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants