Installation
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install cue-kind-definition@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin cue-kind-definition v1.0.0 follows the Agent Plugins spec.
gh skills-hub install cue-kind-definition Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/cue-kind-definition/ Extract the ZIP to .github/skills/ in your repo. The folder name must match cue-kind-definition for Copilot to auto-discover it.
Skill Files (6)
SKILL.md 5.3 KB
---
name: cue-kind-definition
license: Apache-2.0
description: Author CUE kind definitions for grafana-app-sdk apps - schemas, versioning, field constraints, named type definitions, custom routes, and codegen configuration. Scaffolds kinds via `grafana-app-sdk project kind add`, writes spec/status schemas with type constraints (regex, enum, range), defines `#`-prefixed named types for reusable structs, registers versions in the app manifest, and runs `grafana-app-sdk generate` with explicit error recovery. Use when working with CUE kinds, adding a new resource type, adding a version to an existing kind, writing schema field constraints, defining `#Definition` types, adding custom routes, editing files under `kinds/`, or when the user asks to "model a resource", "add a CUE schema", or "write a kind" — even without saying "CUE" explicitly.
---
# CUE Kind Definition
## Common Workflows
### Adding a new kind
```bash
# 1. Scaffold the kind files
grafana-app-sdk project kind add MyKind --overwrite
# Produces kinds/mykind.cue + kinds/mykind_v1alpha1.cue + updates kinds/manifest.cue.
# 2. Edit the generated .cue files — fill in schema.spec / schema.status fields
# 3. Generate types and clients
grafana-app-sdk generate
# 4. Verify the generated artifacts exist
ls pkg/generated/ # should contain new types for MyKind
```
If `generate` fails with CUE errors:
- Read the error — CUE prints the offending file + line + which constraint failed
- Common causes: missing required field, type mismatch (e.g. `string` field assigned an `int`), unresolved reference between version files
- Fix the `.cue` source, re-run `grafana-app-sdk generate`. Never edit files under `pkg/generated/` — they're overwritten on every run.
### Adding a new version to an existing kind
```bash
# 1. Copy the existing version file
cp kinds/mykind_v1alpha1.cue kinds/mykind_v1.cue
# 2. Edit kinds/mykind_v1.cue — rename the top-level object (e.g. myKindv1) and adjust the schema
# 3. Register the new version in kinds/manifest.cue
# Add a versions["v1"]: { schema: myKindv1 } entry
# 4. Re-generate
grafana-app-sdk generate
# 5. Verify both versions were generated — per-version Go types live under pkg/generated/<group>/<version>/
ls pkg/generated/ # should list both version directories (e.g. v1alpha1/ v1/)
# Optionally inspect the CRD spec under definitions/ to confirm both versions appear in `spec.versions[]`
```
**Breaking changes** (removing fields, changing types, adding required fields) must go into a new version — never modify a stable version (`v1`, `v2`) in place.
## Kind file structure
The CLI produces a flat layout under `kinds/`:
```
kinds/
├── manifest.cue # App manifest + version list declarations
├── mykind.cue # Common (cross-version) kind metadata
└── mykind_v1alpha1.cue # v1alpha1 schema + codegen config
```
For multi-version kinds, additional version files sit alongside (`mykind_v1.cue`, etc.). For very large kind sets (10+ kinds), consider the per-kind subdirectory layout — full kind anatomy reference in [references/kind-layout.md](references/kind-layout.md).
## CUE Kind Anatomy
Three layers per kind:
### 1. Common kind metadata
```cue
// kinds/mykind.cue
package kinds
myKind: {
kind: "MyKind" // Required: PascalCase kind name
// other cross-version fields (scope, pluralName, validation, mutation, conversion, …)
// Full field reference in references/kind-layout.md.
}
```
### 2. Per-version schema
```cue
// kinds/mykind_v1alpha1.cue
package kinds
myKindv1alpha1: myKind & {
schema: {
spec: { // desired state — user-set
title: string
description: string | *""
count: int & >=0
enabled: bool | *true
}
status: { // observed state — operator-set
lastObservedGeneration: int | *0
state: string | *""
message: string | *""
}
}
codegen: {
ts: { enabled: true }
go: { enabled: true }
}
}
```
### 3. App manifest
```cue
// kinds/manifest.cue
package kinds
App: {
appName: "my-app"
versions: {
"v1alpha1": { schema: myKindv1alpha1 }
}
}
```
## Codegen configuration
Control what gets generated per kind per version:
```cue
codegen: {
ts: { enabled: true | false } // TypeScript types
go: { enabled: true | false } // Go types + client
}
```
Disabling `go` for frontend-only apps avoids unused Go code. Disabling `ts` for backend-only resources reduces bundle size. Both default to `true` when omitted.
## References
- [`references/kind-layout.md`](references/kind-layout.md) — full common-metadata field reference + app manifest fields + per-kind subdirectory layout
- [`references/schema-types.md`](references/schema-types.md) — CUE schema field types (basic types, constraints, regex, enums, maps, lists) + `#`-prefixed named type definitions
- [`references/custom-routes.md`](references/custom-routes.md) — kind-level + version-level custom routes + handler registration in `app.go`
## External resources
- [grafana-app-sdk GitHub](https://github.com/grafana/grafana-app-sdk)
- [CUE Language Reference](https://cuelang.org/docs/)
- [Example kinds layout](https://github.com/grafana/grafana/tree/main/apps/example/kinds)
cue-constraints.md 6.3 KB
# CUE Constraints Reference
CUE (Configure, Unify, Execute) is a constraint-based language. Values are not assigned — they are constrained. Every field is the intersection (`&`) of all constraints applied to it.
## Basic Types
```cue
myString: string
myInt: int
myFloat: float
myBool: bool
myBytes: bytes
myNull: null
```
## Disjunctions (OR / enums)
```cue
// String enum
status: "pending" | "active" | "archived"
// Type or null (optional)
description: string | null
// Multiple types
value: int | string
```
## Default Values
```cue
// Optional string with default
description: string | *""
// Optional bool with default
enabled: bool | *true
// Optional int with default
replicas: int | *1
// Optional enum with default
priority: "low" | "medium" | "high" | *"medium"
```
## Constraints
Constraints use the `&` (unify/intersect) operator:
```cue
// Numeric bounds
port: int & >=1 & <=65535
count: int & >=0
percent: float & >=0 & <=100
// String length
name: string & strings.MinRunes(1) & strings.MaxRunes(63)
// Regex patterns
slug: string & =~"^[a-z][a-z0-9-]*$"
email: string & =~"^[^@]+@[^@]+\\.[^@]+$"
semver: string & =~"^v?[0-9]+\\.[0-9]+\\.[0-9]+"
// Non-empty string
title: string & != ""
```
## Lists
```cue
// List of any type
items: [...]
// List of strings (scalars — inline fine)
tags: [...string]
// List of objects — always use a #Definition, never inline the struct
// ❌ Avoid:
// rules: [...{ path: string, method: string }]
// ✅ Preferred:
#Rule: {
path: string
method: "GET" | "POST" | "PUT" | "DELETE"
}
rules: [...#Rule]
// Fixed-size list
pair: [string, int] // exactly 2 elements: a string and an int
```
## Maps / Structs
```cue
// Map from string to string
labels: {[string]: string}
// Map from string to any
annotations: {[string]: _}
// Nested struct
metadata: {
name: string
namespace: string | *"default"
labels: {[string]: string} | *{}
}
```
## Optional Fields
In CUE, all struct fields are required unless marked with `?`:
```cue
// Required
title: string
// Optional (may be absent)
description?: string
// Optional with a specific type
config?: {
timeout: int | *30
}
```
Note: In grafana-app-sdk kind schemas, the common pattern is to use `string | *""` rather than `?` for optional string fields, as it provides a sensible default that the generated Go struct can hold.
## Additional Types
In CUE, non-primitive types can be imported from the standard library. For exmaple, to create a field of go type `time.Time`:
```cue
import "time"
{
timeField: string & time.Time
}
```
## CUE Imports for Constraints
```cue
import "strings"
name: string & strings.MinRunes(1) & strings.MaxRunes(253)
```
Available standard packages: `strings`, `math`, `list`, `regexp`, `encoding/json`, `encoding/yaml`
## Named Type Definitions (`#` prefix)
CUE supports named struct definitions using `#TypeName`. Inside a `schema` block, these define sub-types that the code generator emits as named Go structs and TypeScript interfaces.
```cue
schema: {
#Config: {
timeout: int & >=1 & <=3600 | *30
retries: int & >=0 & <=10 | *3
}
#Rule: {
path: string
weight: int & >=0 & <=100
}
#ResourceRef: {
name: string & != ""
namespace: string | *"default"
}
spec: {
config: #Config
rules: [...#Rule] | *[]
targetRef: #ResourceRef
}
}
```
**Scope:** `#` definitions are scoped to the `schema` block they are declared in and cannot be referenced outside it.
**Generated output:** Each `#TypeName` produces a named type in Go and TypeScript:
- Go: `type Config struct { Timeout int \`json:"timeout"\`; Retries int \`json:"retries"\` }`
- TypeScript: `interface Config { timeout: number; retries: number; }`
**Prefer `#` definitions when:**
- The struct is used in more than one field
- The struct is large or complex (many fields, nested constraints)
- The struct appears in a list (`[...#Rule]`) — keeping the list declaration readable
**Inline structs are fine when:**
- The struct is small and simple (2–3 fields)
- It is used in exactly one place and unlikely to be reused
Maps (`{[string]: string}`) and lists of scalars (`[...string]`) are always fine inline.
## Pattern in grafana-app-sdk Kinds
A complete `schema` block with preferred patterns:
```cue
schema: {
// #Definitions for structs that are large, reused, or appear in lists
#Config: {
timeout: int & >=1 & <=3600 | *30
retries: int & >=0 & <=10 | *3
}
#Rule: {
path: string
weight: int & >=0 & <=100
}
spec: {
// Required scalar fields
title: string & != ""
category: "issue" | "feature" | "bug"
// Optional scalars with defaults
description: string | *""
priority: "low" | "medium" | "high" | *"medium"
enabled: bool | *true
count: int & >=0 | *0
// Named definition for a larger/reused struct
config: #Config
// Small, simple, single-use struct — inline is fine
contact: {
name: string
email: string
}
// List of scalars (inline fine)
tags: [...string] | *[]
// List of objects — prefer a named definition
rules: [...#Rule] | *[]
// Map (always inline)
labels: {[string]: string} | *{}
}
// status is written only by the operator/reconciler, never by users.
status: {
lastObservedGeneration: int | *0
state: string | *"" // e.g. "Ready", "Provisioning", "Error"
message: string | *""
// e.g. name of a resource provisioned by the reconciler:
// provisionedConfigMap: string | *""
}
}
## Common Mistakes
**Don't use `?` on spec fields that need defaults in Go:**
```cue
// Bad — Go will get zero value, hard to distinguish "not set" from empty
description?: string
// Better — explicit default
description: string | *""
```
**Don't put server state in spec:**
```cue
// Bad — this should be in status
spec: {
lastUpdated: string // server writes this
}
// Good
status: {
lastUpdated: string
}
```
**Do use `!= ""` for required strings:**
```cue
// Bad — accepts empty string
name: string
// Good — rejects empty string at API level
name: string & != ""
```
custom-routes.md 1.5 KB
# Custom routes in CUE
Routes can be defined at two levels. Both require corresponding Go handlers registered in `app.go`.
## Kind-level routes
```cue
MyKind: {
kind: "MyKind"
schema: { ... }
routes: {
"/actions/process": {
"POST": {
name: "processMyKind" // unique within version; must start with a k8s verb
request: {
body: {
reason: string
}
}
response: {
jobId: string
status: string
}
}
}
}
}
```
## Version-level routes
```cue
versions: {
"v1alpha1": {
routes: {
namespaced: {
"/summary": {
"GET": {
name: "getNamespacedSummary"
response: { count: int }
}
}
}
cluster: {
"/health": {
"GET": {
name: "getHealth"
response: { status: string }
}
}
}
}
}
}
```
## After adding routes
Run `grafana-app-sdk generate` — routes are included in the AppManifest and `ValidateManifest` will fail if a Go handler is missing in `app.go`.
If the generate step fails with `route handler missing`, register the handler in `app.go`:
```go
app.RegisterCustomRouteHandler("processMyKind", processHandler)
```
…and re-run `generate`.
kind-layout.md 7.6 KB
# Kind Layout Reference
## Overview
The default layout produced by `grafana-app-sdk project kind add` places all CUE files directly in `kinds/`, sharing `package kinds`. A kind is split into two objects:
- **`myKind`** (`myKind.cue`) — common metadata shared across all versions (`kind`, `group`, `scope`, admission config, etc.)
- **`myKindv1alpha1`** (`myKind_v1alpha1.cue`) — per-version schema joined to the metadata via CUE's `&` operator
The app manifest (`myapp.cue`) references version objects directly — no imports needed in the flat layout.
See SKILL.md for the full three-layer anatomy and file structure details.
## Full Example Kind
An example kind with all possible fields populated:
```cue
package kinds
myKind: {
kind: "MyKind" // [required] The name of the kind
pluralName: "MyKinds" // [optional] The plural form of `kind`. Defaults to `kind`+`s`
scope: "Namespaced" // [optional] "Cluster" or "Namespaced", defaults to "Namespaced"
validation: { // [optional] Validating admission control configuration for the kind
operations: ["POST","PUT","PATCH"] // values limited to "GET","POST","PUT","DELETE","PATCH"
}
mutation: { // [optional] Mutating admission control configuration for the kind
operations: ["POST","PUT","PATCH"] // values limited to "GET","POST","PUT","DELETE","PATCH"
}
conversion: true // [optional] Explicit conversion supported, defaults to false. When true, the App must register a Converter in app.go and ValidateManifest will fail at startup if it is missing.
conversionWebhookProps: { // [optional] Only required if conversion=true and the app is running as a standalone binary
url: "https://myapp.svc.cluster.local:443/convert" // The URL of the conversion webhook which should be called to conver the kind between versions
}
codegen: {
ts: { // [optional] TypeScript codegen settings
enabled: true // [optional] If true TypeScript types are generated for this kind. Defaults to true
config: { // [optional] Configuration to pass into github.com/grafana/cog when running TypeScript generation
// [optional] importsMap associates package names to their import path.
importsMap: {
"common": "github.com/example/common"
}
// [optional] enumsAsUnionTypes controls how CUE enums (disjunctions) are emitted in TypeScript.
// false (default): generates a TypeScript enum declaration, e.g.:
// enum Direction { Up = "up", Down = "down" }
// true: generates a union type, e.g.:
// type Direction = "up" | "down"
// Use true when consumers prefer plain string unions over enum objects (e.g. for JSON serialization compatibility).
enumsAsUnionTypes: false
}
}
go: { // [optional] go codegen settings
enabled: true // [optional] If true go types are generated for this kind. Defaults to true
}
}
}
```
And an example version `v1` of that kind with all possible fields populated:
```cue
package kinds
myKindv1: myKind & {
// schema is the schema for the kind version, defined as a CUE definition. It must contain at least `spec`.
// Any top-level fields aside from `spec` are considered subresources of the object, the most common of which is `status`
schema: {
spec: {
foo: string
}
status: {
observedGeneration?: int
}
}
// [optional] selectableFields is a list of JSON paths to fields in the schema which can be used as field selectors in the resulting kubernetes API. CRDs limit the number of selectableFields to 8, so it is good practice to have 8 or fewer
selectableFields: [".spec.foo"]
// [optional] additionalPrinterColumns is a list of additional columns to display in a `kubectl get` output for the kind
additionalPrinterColumns: [{
// name is a human readable name for the column.
name: "Foo"
// type is an OpenAPI type definition for this column.
// See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.
type: "string"
// [optional] format is an optional OpenAPI type definition for this column.
// See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.
// Use format: "name" on the column that displays the resource name (.metadata.name) — this signals
// to clients (e.g. kubectl) that the column is the primary identifier.
format: ""
// [optional] description is a human readable description of this column.
description: "Lorem ipsum"
// priority is an integer defining the relative importance of this column compared to others. Lower
// numbers are considered higher priority. Columns that may be omitted in limited space scenarios
// should be given a priority greater than 0.
priority: 1
// jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against
// each custom resource to produce the value for this column.
jsonPath: ".spec.foo"
}]
// [optional] routes is any custom subresource routes for the kind.
// Subresource routes differ from subresources defined in `schema` in that they call a handler, rather than
// store/retrieve a payload to the underlying storage. Route paths must not conflict with subresources defined in `schema` (like `spec` and `status`)
routes: {
// This defines a subresource /message on the kind. Keys in the subsequent map must be all-caps HTTP verbs which correlate to handlers for this subresource
"message": {
// This defines a GET handler for the /message subresource
"GET": {
name: "getMessage" // name is the OpenAPI name of the route, must begin with a kubernetes verb and match the regex `^(get|log|read|replace|patch|delete|deletecollection|watch|connect|proxy|list|create|patch)([A-Za-z0-9]+)$`
// [optional] request information
request: {
// query parameters
query: {
echo: int
}
}
// successful response schema
response: {
message: string
}
// [optional] kubernetes metadata to include in the response payload (impacts codegen and OpenAPI)
responseMetadata: {
typeMeta: true // [optional] include meta/v1.TypeMeta (`kind` and `apiVersion`), defaults to true
objectMeta: false // [optional] include a `metadata` field that contains meta/v1.ObjectMeta (defaults to false). Mutually exclusive with `listMeta`
listMeta: false // [optional] include a `metadata` field that contains meta/v1.ListMeta (defaults to false). Mutually exclusive with `objectMeta`
}
// OpenAPI extensions to add to the generated OpenAPI for the route
extensions: {
"x-myapp-some-extension": "foo"
}
}
// This defines a POST handler for the /message subresource
"POST": {
name: "replaceMessage"
request: {
// [optional] request body schema
body: {
message: string
}
}
response: {
message: string
}
}
}
}
}
``` schema-types.md 2.0 KB
# Schema field types + named definitions
## Contents
- [Schema field types and constraints](#schema-field-types-and-constraints)
- [Type definitions with `#`](#type-definitions-with-)
## Schema field types and constraints
CUE is a superset of JSON. Commonly used types and constraints:
```cue
// Basic types
myString: string
myInt: int
myFloat: float
myBool: bool
myBytes: bytes
// Optional with default (using disjunction + *)
name: string | *"default-value"
// Constraints (using & to intersect)
port: int & >=1 & <=65535
label: string & =~"^[a-z][a-z0-9-]*$" // regex
// Enums (disjunctions)
status: "pending" | "active" | "archived"
// Maps (always fine inline)
labels: {[string]: string}
attrs: {[string]: _}
// Lists of scalars (fine inline)
tags: [...string]
// Optional field (no value required)
description?: string
```
## Type definitions with `#`
CUE supports named type definitions using the `#` prefix inside a `schema` block. Each `#Definition` generates a named Go struct and TypeScript interface alongside the kind's `Spec` type.
```cue
schema: {
#Threshold: {
value: float & >=0
severity: "info" | "warning" | "critical"
message: string | *""
}
#ResourceRef: {
name: string & != ""
namespace: string | *"default"
}
spec: {
title: string & != ""
alertThreshold: #Threshold
thresholds: [...#Threshold] // list of a defined type
targetRef?: #ResourceRef // optional
}
}
```
`#` definitions are scoped to the `schema` block they are declared in.
**Prefer `#` definitions when:**
- A struct is used in more than one field
- A struct is large or complex enough that inlining hurts readability
- A struct appears in a list (`[...#MyType]`)
**Inline structs are fine when:**
- The struct is small and simple (2-3 fields) or shallow
- It is used in only one place and unlikely to be reused
Maps and lists of scalars are always fine inline.
versioning-guide.md 6.2 KB
# Kind Versioning Guide
## Overview
grafana-app-sdk kind versioning mirrors Kubernetes API versioning. Each version represents a distinct schema that is independently accessible via the API at `/apis/<group>/<version>/`. Multiple versions of the same kind can be served simultaneously, which enables non-disruptive schema evolution.
## Version Naming Conventions
Follow Kubernetes conventions:
| Stage | Format | Example | Meaning |
|-------|--------|---------|---------|
| Alpha | `v1alpha1`, `v1alpha2` | First experiment | May change without notice |
| Beta | `v1beta1`, `v1beta2` | Maturing | Likely to become stable |
| Stable | `v1`, `v2` | Shipped | Breaking changes require new version |
Start with `v1alpha1` for new kinds. Graduate to `v1beta1` and `v1` as the schema stabilizes.
## Default Layout (flat)
`grafana-app-sdk project kind add` generates files directly in `kinds/`, all sharing `package kinds`:
```
kinds/
├── manifest.cue # App manifest
├── myKind.cue # Common metadata (cross-version)
└── myKind_v1alpha1.cue # v1alpha1 schema + codegen
```
## Multi-Version Layout
When a kind needs a second version, add a new file alongside the existing ones:
```
kinds/
├── manifest.cue
├── myKind.cue
├── myKind_v1alpha1.cue
└── myKind_v1.cue
```
> Users working with complex kinds may choose to organise into per-kind and per-version subdirectories (each with its own CUE package). That layout requires importing version packages in the app manifest. The flat default requires no imports — version objects are referenced directly since all files share `package kinds`.
## What Must Match Across Versions
Fields declared in the common kind metadata object (`myKind.cue`) must be identical in all versions:
```cue
// kinds/myKind.cue — these must match across ALL versions
myKind: {
kind: "MyKind" // identical in all versions
group: "my-app.grafana.app"
// scope, pluralName, etc.
}
```
Per-version `schema.spec` fields can differ freely.
## Backward-Compatible Changes (safe)
These changes can be made to an existing version's schema:
- **Adding an optional field** — existing resources remain valid; new field defaults to its CUE default
- **Widening a constraint** — e.g. changing `int & >=1` to `int & >=0` (more permissive)
- **Adding a new enum value** — e.g. adding `"archived"` to `"pending" | "active"`
- **Loosening a regex** — making a pattern less restrictive
## Breaking Changes (require a new version)
These changes break existing clients and must be introduced via a new version:
- **Removing a field** — existing resources stored with that field become invalid
- **Renaming a field** — clients using the old name stop working
- **Adding a required field** (no default) — existing resources missing the field fail validation
- **Narrowing a constraint** — e.g. making an `int` field require `>= 0` when `< 0` was previously allowed
- **Changing a field's type** — e.g. changing `string` to `int`
- **Removing an enum value** — resources with that value become invalid
## Adding a New Version
### Step 1: Create the new version schema
1. Create the new version CUE file, and copy the previous version as a starting point, ensuring that the type name has changed (e.g. `mykindv1alpha1: mykind & {...}` to `mykindv1beta1: mykind & {...}`).
2. Add the kind to `manifest.versions[<version>]` in the manifest CUE file. If the new version does not exist in `manifest.versions`, create a new object in `manifest.cue` for the version, e.g.
```
v1beta1: {
kinds: [mykindv1beta1]
}
```
And add it to `manifest.versions` using the version as the map key.
```bash
# Scaffold the new version
grafana-app-sdk project kind add MyKind --overwrite
# Then manually copy the v1alpha1 schema to v1/ as a starting point
```
### Step 2: Define the new schema
Create `kinds/myKind_v1.cue` (flat default layout), starting from the previous version's schema:
```cue
package kinds
myKindv1: myKind & {
schema: {
spec: {
// All fields from v1alpha1
title: string & != ""
description: string | *""
// New in v1 — must have a default to not break existing resources
category: "general" | "advanced" | *"general"
// Breaking change from v1alpha1 — that's why we created v1
// In v1alpha1, `config` was a free-form string; in v1 it's a struct
config?: {
timeout: int & >=1 | *30
retries: int & >=0 | *3
}
}
}
codegen: {
ts: { enabled: true }
go: { enabled: true }
}
}
```
### Step 3: Register the new version in the app manifest
In the flat layout all objects share `package kinds` — reference them directly, no imports needed:
```cue
// kinds/myapp.cue
package kinds
App: {
versions: {
"v1alpha1": { schema: myKindv1alpha1 }
"v1": { schema: myKindv1 }
}
}
```
### Step 4: Run generate
```bash
grafana-app-sdk generate
```
Both versions now have generated Go types and clients.
## Deprecation Strategy
When deprecating an old version:
1. Add the new version to the manifest (both versions served simultaneously)
2. Announce deprecation in docs/changelog
3. Migrate existing resources using a conversion webhook or migration job
4. After all resources are migrated, remove the old version from the manifest
5. Run `generate` to remove the old version's generated code
## Storage Version
Only one version is the "storage version" — the canonical form stored in etcd. The Kubernetes API server converts between versions on read/write. The storage version should be the most recent stable version.
In grafana-app-sdk, the storage version is typically configured in the kind's CUE definition or the app manifest. Check the SDK documentation for the current mechanism.
## Conversion
When multiple versions are served, resources stored in the storage version need to be converted to other versions on read. Conversion can be:
- **Automatic** — for purely additive changes where the new fields have defaults; the SDK may handle this automatically
- **Manual** — for structural changes; implement a conversion function in Go
Conversion logic lives outside the generated code and is registered when building the app.
License (Apache-2.0)
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/grafana/skills/blob/main/LICENSE