feat(tenant_gateway): register TenantGateway kind as raw-spec passthrough - #23
Conversation
…ough Cozystack 1.6 adds a new gateway.cozystack.io/v1alpha1 group with a namespaced TenantGateway kind, declaring a tenant's per-namespace Gateway API / Cilium Gateway. It is a controller-facing CRD rather than a packages/apps application, so it follows the same raw-spec passthrough pattern already used for other platform kinds (spec = jsonencode(...)) instead of a fully typed model. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
IvanHunters
left a comment
There was a problem hiding this comment.
Verdict
LGTM
Summary
Registers TenantGateway (gateway.cozystack.io) as a namespaced raw-spec passthrough: a new cozystack_tenant_gateway resource and matching data source, plus generated docs, examples, and a README entry. Purely additive — no change to any existing kind.
What I verified
- GVR is exact.
TenantGatewayResource()returns{Group: gateway.cozystack.io, Resource: tenantgateways, Kind: TenantGateway}with noClusterScoped, andResource.Versiondefaults tov1alpha1. Cross-checked against upstream cozystackmain:api/gateway/v1alpha1/groupversion_info.go(Group: gateway.cozystack.io, Version: v1alpha1) and the CRDpackages/system/cozystack-controller/definitions/gateway.cozystack.io_tenantgateways.yaml(plural: tenantgateways,kind: TenantGateway,scope: Namespaced,v1alpha1served+storage). Group, version, plural, kind and scope all match. - Correct wiring. Registered via
newAppResource/newAppDataSource(namespaced) with the sharedrawSpecNsResourceModel/rawSpecNsModeland the sharedrawSpecNsSchema/rawSpecNsDataSourceSchema— identical to the existingbackupandbackup_jobnamespaced passthroughs.expand/flattenare the shared, unit-tested code paths. - Docs accuracy. Every spec field named in the docs/README (
apex,certMode,issuerName,dns01,wildcardSecretRef,attachedNamespaces,tlsPassthroughServices,gatewayClassName) exists in the CRD schema;apexis the only required field. README table separator formatting is correct. - Builds clean.
go build ./...andgo vet ./internal/provider/pass; the rawspec unit tests pass. - No dangling refs / no secret in state. The DNS-01 credential is referenced by
secretRefname only inside the user-authored JSON; no secret value is read into Terraform state.
Caveats (non-blocking)
[MINOR] Raw-spec drift on server-defaulted fields. The TenantGateway CRD server-defaults several top-level fields (certMode: http01, gatewayClassName: cilium, issuerName: letsencrypt-prod, plus nested dns01 defaults). Because spec is Optional+Computed normalized JSON and flatten reads back the full server spec, a config that sets only apex is likely to show a perpetual plan diff as the server populates those defaults. This is inherent to the raw-spec passthrough design (the other passthrough kinds behave the same) and is the deliberate "don't chase the spec evolution" tradeoff, so it is not a regression. A one-line docs note advising users to include the defaulted fields they care about (or to expect the passthrough not to reconcile server-added defaults) would help. Not blocking.
[NIT] No dedicated unit/acceptance test for tenant_gateway. This matches the nearest precedents (backup, backup_job, marketplace_panel — namespaced/dashboard raw-spec passthroughs that also ship without a per-kind test), and CONTRIBUTING only requires the reflection spec-coverage guard "where a typed model is used", which does not apply to a raw-spec kind. SchedulingClass does carry a TestAcc*, so if the team wants parity a small acceptance test could be added later. Not blocking.
Note
Base branch is feat/cozystack-1.6, not main — this is a stacked PR in the 1.6 series; respect the merge order relative to the rest of the 1.6 stack.
IvanHunters
left a comment
There was a problem hiding this comment.
Verdict
LGTM
Registration is a faithful reuse of the existing namespaced raw-spec passthrough machinery: same rawSpecNs{Model,ResourceModel} and rawSpecNs{,DataSource}Schema helpers already exercised by backup / backup_job, wired symmetrically into both Resources() and DataSources(), with a correctly namespaced TenantGatewayResource() (no ClusterScoped, unlike the cluster-scoped MarketplacePanel).
Caveats
- GVK
gateway.cozystack.io/tenantgateways(KindTenantGateway, namespaced) could not be verified against a live Cozystack 1.6 aggregated API in this static review. If the plural/group does not match the 1.6ApplicationDefinition,apply/readwill fail with NotFound at runtime. This is additive (no effect on existing resources, no silent state loss) and self-evident on first use, so it is not blocking — but an acceptance test against a 1.6 cluster (orcozystack-pr-test) is the authoritative confirmation. - No dedicated acceptance test for
tenant_gateway; verified this matches the established convention (thebackup,backup_job, andmarketplace_panelpassthrough kinds carry no per-kind*_test.goeither — the genericrawSpecNspath is the tested surface).go build ./...andgo vet ./internal/provider/are clean.
VerdictLGTM with non-blocking notes SummarySmall, purely-additive PR (+150/-0, 8 files, 0 deletions) that registers the new Checked and correct
Findings[MINOR] Namespaced raw-spec model ( Caveats
What would change my mindIf a future Kind (or this one, on live-cluster testing via Recommended follow-ups
|
Pull Request
Summary
Adds
cozystack_tenant_gatewayresource and data source for the newgateway.cozystack.io/v1alpha1TenantGateway kind (namespaced), introduced with Cozystack 1.6 Gateway API support. Spec is raw-JSON passthrough, matching the existing pattern for non-app platform kinds, so upstream spec changes need no provider changes.Changes
gateway.cozystack.ionamespaced client resource descriptorcozystack_tenant_gatewayresource and data source through the existing raw-spec machineryTesting
make test): the branch inherits 7 spec-coverage failures from the integration base (v1.6.1 pin bump). The sibling field-modeling PRs fix them. This diff adds zero new failures.make lint)make docsproduces no diff)make testacc), if applicable: not run in this passDocumentation
examples/make docs)Checklist
type(scope): description)Additional Notes
Targets the
feat/cozystack-1.6integration branch, notmaster.