Skip to content

crd-from-oas: union discriminator values derived from variant names produce awkward identifiers (e.g. oIDC) #5803

Description

@tao12345666333

Problem Statement

The crd-from-oas generator derives CRD union discriminator values (the type enum) from Go variant type names: extractVariantNames strips common prefixes/suffixes, then a lower-first camelCase conversion produces the final value. For OIDCIdentityProviderConfig this yields oIDC — an awkward, error-prone, user-facing value in the PortalIdentityProviderRequest CRD (spec.config.type: oIDC, also the JSON field name oIDC).

The upstream OpenAPI spec already defines a clean enum for this purpose (IdentityProviderType: oidc / saml), but the generator does not use it for the discriminator.

Proposed Solution

Candidate approaches (not mutually exclusive):

  1. Use the spec's own type enum values as union discriminator values when available.
  2. Add a per-union discriminator/variant-name override in crd-from-oas/config.yaml.
  3. Improve initialism handling in the lower-first camelCase conversion (lowercase the whole leading initialism run: OIDC → oidc).

Note: oIDC has shipped in v2.3.0 (and exists on release/2.2.x), so changing the enum value is a CRD breaking change. Any fix likely needs to wait for a CRD version bump (e.g. v1alpha1 → v1alpha2) or a major release window.

Additional Information

  • Derivation chain: extractVariantNames / uniqueUnionDiscriminatorValues in crd-from-oas/pkg/generator/generator.go (~L3945) → lower-first camelCase (jsonName).
  • Impact scan: oIDC is currently the only awkward discriminator value across all generated API types (portalSAML, tls_server, etc. are all fine).
  • Surfaced during review of feat: generate GetForUID for Konnect PortalIdentityProviderRequest #3956.

Acceptance Criteria

  • Documentation is updated with this new feature / enhancement (no user-facing docs change expected; the CRD schema itself is the documentation)
  • Tests are added for this feature / enhancement
  • Helm chart is updated to work with this feature / enhancement (no chart changes needed)
  • As a user, I can use clean, idiomatic discriminator values (e.g. oidc / saml) in PortalIdentityProviderRequest manifests

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions