Skip to content

Allow using a CUE attribute to note reference types in schemas #1282

@IfSentient

Description

@IfSentient

It would be useful to allow users to use an attribute on a CUE field to specify that it is a reference to another app platform kind (and how that reference is structured), so that we could then use an extension on the generated OpenAPI (for CRD or API Server OpenAPI) to allow a service to "discover" app platform references in kind schemas, and be able to construct a graph of relationships, or work based on specific kinds of references.

Something like

schema: {
    spec: {
        relatedDashboard: string @grafanaappsdk(type="ref" kind="Dashboard" group="dashboard.grafana.app" name=".") // use '.' to designate the value of the field
        relatedObject: {
            kind: string
            group: string
            namespace: string
            name: string
        } @grafanappsdk(type="ref" kind=".kind" group=".group" namespace=".namespace" name=".name") // we could probably have the same-name fields be defaulted to those values?
    }
}

Which would manifest on an extension for each of these fields like:

{
    "relatedDashboard": {
        "type": "string"
        "x-grafana-object-ref": {
            "kind": "Dashboard",
            "group": "dashboard.grafana.app",
            "name": "."
        }
    },
    "relatedObject": {
        "$ref": "#/components/schemas/relatedObject",
        "x-grafana-object-ref": {
            "kind": ".kind",
            "group": ".group",
            "namespace": ".namespace",
            "name": ".name"
        }
    }
}

But this should be modified to best fit the use-case. Discuss with @bcotton to work out the best layout for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions