discover

package
v1.13.1 Latest Latest
Warning

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

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

Documentation

Overview

Package discover reads application metadata and proposes deployment settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigValue

func ConfigValue(app App, dotted string) (string, bool)

ConfigValue reads the highest precedence scalar without exposing an entire secret-bearing config.

func NamedInstance

func NamedInstance(app App, key, list, name string) (bool, bool)

NamedInstance reports list presence separately from an item named default.

Types

type App

type App struct {
	Name        string   `json:"name"`
	Dir         string   `json:"dir"`
	MainPath    string   `json:"main_path"`
	Module      string   `json:"module"`
	Type        string   `json:"type"`         // from cmd/<app>/.forge.yaml app.type, "" if absent
	Port        int      `json:"port"`         // from dev.port, 0 if absent
	ConfigPaths []string `json:"config_paths"` // existing config files for this app
	Imports     []string `json:"imports"`      // module paths from go list -deps, deduplicated
}

type Confidence

type Confidence string
const (
	High   Confidence = "high"   // from config
	Medium Confidence = "medium" // from per-app .forge.yaml
	Low    Confidence = "low"    // from imports only
)

type Options

type Options struct {
	// GoList runs `go list` with args in dir. nil uses execx.System().
	Modules []catalog.Module `json:"modules"`
	Runner  execx.Runner
}

type Result

type Result struct {
	Runtime     []RuntimeReport    `json:"runtime,omitempty"`
	Apps        []App              `json:"apps"`
	Suggestions []Suggestion       `json:"suggestions"`
	Modules     []catalog.Module   `json:"modules"`
	Diagnostics output.Diagnostics `json:"diagnostics"`
}

func Run

func Run(ctx context.Context, cfg *config.ForgeConfig, cat *catalog.Catalog, opts Options) (*Result, error)

Run discovers apps and suggests services, resources, bindings and decisions. It never executes application code.

type RuntimeReport

type RuntimeReport struct {
	Service      string               `json:"service,omitempty"`
	Schema       string               `json:"schema"`
	App          string               `json:"app"`
	Requirements []RuntimeRequirement `json:"requirements"`
}

func ExecuteRuntime

func ExecuteRuntime(ctx context.Context, root string, apps []App, selected string, runner execx.Runner) ([]RuntimeReport, error)

ExecuteRuntime executes only explicitly selected, trusted project apps. Ordinary discovery, planning and the workbench never call this method.

type RuntimeRequirement

type RuntimeRequirement struct {
	Extension string `json:"extension"`
	Kind      string `json:"kind"`
	Instance  string `json:"instance,omitempty"`
	ConfigKey string `json:"config_key"`
	Optional  bool   `json:"optional,omitempty"`
}

type Suggestion

type Suggestion struct {
	Kind       SuggestionKind `json:"kind"`
	Path       string         `json:"path"` // the spec path it would set, e.g. "deploy.services.api.kind"
	Value      any            `json:"value"`
	Source     string         `json:"source"` // "config/api.yaml:14" or "go.mod: github.com/xraph/grove/drivers/pgdriver"
	Confidence Confidence     `json:"confidence"`
	Question   string         `json:"question"` // set for decisions
	Options    []string       `json:"options"`  // for decisions
}

func Block

func Block(suggestions []Suggestion, defaults spec.Defaults) (map[string]any, []Suggestion)

Block renders suggestions as a complete deploy: v2 map. Decisions that are unanswered are left out and returned.

type SuggestionKind

type SuggestionKind string
const (
	SuggestService  SuggestionKind = "service"
	SuggestResource SuggestionKind = "resource"
	SuggestBinding  SuggestionKind = "binding"
	SuggestDecision SuggestionKind = "decision"
)

Jump to

Keyboard shortcuts

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