Skip to content

Support referencing custom types from other custom types in schema.types #906

@kahirokunn

Description

@kahirokunn

Feature Description

Problem Statement:

Currently, custom types defined in ResourceGraphDefinition.spec.schema.types cannot reference each other, preventing the division and reuse of types. For example, if BaseCluster attempts to reference KubeconfigRef as shown below, the build of the RGD fails with an error unknown type: KubeconfigRef.

schema:
  spec:
    baseCluster: BaseCluster
  types:
    BaseCluster:
      kubeconfigRef: KubeconfigRef | required=true
    KubeconfigRef:
      name: string | required=true
      namespace: string | required=true

The current workarounds are to either inline and copy-paste KubeconfigRef or to fall back to the object notation. However, the object notation tends to weaken structured schema/validation. This goes against the intention of defining structures with types and then enhancing safety by applying CEL validation or constraints via markers.

Proposed Solution:

Allowing references to other schema.types within schema.types would be beneficial.

Expected Benefits:

  • types can be modularized and reused, leading to a more concise schema.
  • Structuring using types makes validation/CEL targets clearer compared to the object notation, making it easier to enhance safety.

Alternatives Considered:

Additional Context:

Current error example (from kubectl describe rgd ...):

conditions:
  - lastTransitionTime: "2025-12-17T04:15:40Z"
    message: 'failed to build resourcegraphdefinition ''k0smotrondockercluster.cluster.example.com'':
      failed to build OpenAPI schema for instance: failed to build OpenAPI schema
      for instance: failed to build pre-defined types schema: unknown type: KubeconfigRef'
    observedGeneration: 2
    reason: InvalidResourceGraph
    status: "False"
    type: ResourceGraphAccepted
  - lastTransitionTime: "2025-12-17T04:15:40Z"
    message: 'failed to build resourcegraphdefinition ''k0smotrondockercluster.cluster.example.com'':
      failed to build OpenAPI schema for instance: failed to build OpenAPI schema
      for instance: failed to build pre-defined types schema: unknown type: KubeconfigRef'
    observedGeneration: 2
    reason: InvalidResourceGraph
    status: "False"
    type: Ready
  • Please vote on this issue by adding a 👍 reaction to the original issue
  • If you are interested in working on this feature, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions