Skip to content
/ spec Public

Defines the input types for the Kure API code generator

License

Notifications You must be signed in to change notification settings

kure-sh/spec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kure spec

The spec library package defines the types that the API package generator expects to be fed.

Example

Below is an example of a simple API with one custom resource: Calculator. Normally, this spec would be generated directly from the operator's codebase, via (e.g.) ingest-go.

import type { APIGroupVersion } from "jsr:@kure/spec";

export const v1alpha1: APIGroupVersion = {
  apiVersion: "spec.kure.sh/v1alpha1",
  kind: "APIGroupVersion",

  api: "example",
  group: { name: "example.kure.sh", module: null /* root module of API */},
  version: 'v1alpha1',

  dependencies: [
    { package: "kubernetes", version: "1.30" },
  ],

  definitions: [
    {
      name: "Calculator",
      description: "Evaluate a math expression",
      value: {
        type: "resource",
        metadata: { name: "calculators", scope: "namespace", /* ... */},
        properties: [ 
          {
            name: "metadata",
            value: {
              type: "reference",
              target: {
                scope: {
                  package: "kubernetes",
                  group: { name: "meta", module: "meta" },
                  version: "v1",
                },
                name: "ObjectMeta"
              },
            }
          },
          {
            name: "spec",
            value: {
              type: "reference",
              target: { name: "CalculatorSpec" },
            }
          },
          {
            name: "status",
            value: {
              type: "reference",
              target: { name: "CalculatorStatus" },
            }
          },
        ]
      }
    },

    {
      name: "CalculatorSpec",
      description: "Defines the input to Calculator",
      value: {
        type: "object",
        properties: [
          {
            name: "expression",
            value: { type: "string" },
            required: true,
          }
        ]
      }
    },

    {
      name: "CalculatorStatus",
      description: "Provides the output from Calculator",
      value: {
        type: "object",
        properties: [
          {
            name: "result",
            value: {
              type: "optional", // may be `null`
              value: { type: "integer", size: 32 },
            },
            required: true,
          },
          {
            name: "error",
            description: "If the input expression was invalid, explains the error",
            value: { type: "string" },
          }
        ]
      }
    }
  ]
};

About

Defines the input types for the Kure API code generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published