catalog

package
v1.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package catalog holds the descriptors that say how a Forge extension declares its backends, and the recipes that can host those backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	Descriptors map[string]Descriptor // by extension name
	Recipes     map[string]Recipe     // by id
}

func Embedded

func Embedded() *Catalog

Embedded returns the catalog shipped in the CLI.

func Load

func Load(ctx context.Context, projectRoot string, modules []Module) (*Catalog, output.Diagnostics, error)

Load returns the embedded catalog with module-shipped and project-local descriptors applied on top, in that order. A descriptor with a schema newer than this CLI reads is reported and skipped.

func (*Catalog) DescriptorFor

func (c *Catalog) DescriptorFor(extension string) (Descriptor, bool)

DescriptorFor returns the descriptor for an extension name.

func (*Catalog) RecipeFor

func (c *Catalog) RecipeFor(t model.ResourceType, version string, features []string) (Recipe, bool)

RecipeFor picks the recipe for a type that provides every feature asked for. version "" accepts any. Ties resolve to the recipe with the fewest extra features, then by id.

type Condition

type Condition struct {
	Field  string `yaml:"field"`
	Equals string `yaml:"equals"`
}

type Descriptor

type Descriptor struct {
	Schema     int                           `yaml:"schema"`
	Extension  string                        `yaml:"extension"`
	ConfigKey  string                        `yaml:"config_key"`
	Instances  *Instances                    `yaml:"instances,omitempty"`
	Kinds      map[string]model.ResourceType `yaml:"kinds,omitempty"`
	Bind       map[string]string             `yaml:"bind,omitempty"`
	Requires   []Requirement                 `yaml:"requires,omitempty"`
	Optional   []OptionalRequirement         `yaml:"optional,omitempty"`
	Migrations *Migrations                   `yaml:"migrations,omitempty"`
	Source     string                        `yaml:"-"` // "embedded", module path, or project file
}

func (Descriptor) KindOf

func (d Descriptor) KindOf(value string) (model.ResourceType, bool)

KindOf maps a driver value or DSN to a resource type through the descriptor's kinds table. For a DSN the scheme before ':' is used. ok is false when the value is unknown; an empty type with ok true means embedded.

type Instances

type Instances struct {
	Path        string   `yaml:"path"`
	Name        string   `yaml:"name"`
	DefaultFrom []string `yaml:"default_from,omitempty"`
}

type Migrations

type Migrations struct {
	Owner bool `yaml:"owner"`
}

type Module

type Module struct {
	Path string // module path
	Dir  string // on-disk directory from go list -m -json
}

type OptionalRequirement

type OptionalRequirement struct {
	Kind model.ResourceType `yaml:"kind"`
	When *Condition         `yaml:"when,omitempty"`
	Bind map[string]string  `yaml:"bind,omitempty"`
}

type Recipe

type Recipe = model.RuntimeRecipe

type Requirement

type Requirement struct {
	Extension string `yaml:"extension"`
	Via       string `yaml:"via"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL