Help us shape the future of Go! Take the 2026 Go Developer Survey

scaffold

package
v0.31.0 Latest Latest
Warning

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

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

Documentation

Overview

Package scaffold writes a first rig.yaml from what a directory already has: compose files, Kubernetes manifests, and services in Go, Python, Node, Java or Rust, plus infrastructure presets.

Index

Constants

This section is empty.

Variables

View Source
var Langs = []string{"go", "python", "ts", "bash", "yaml"}

Langs are the plugin templates: a server in Go, Python or TypeScript, scripts, or YAML alone.

Functions

func ImportCompose

func ImportCompose(path, dir string) (map[string]*spec.Service, error)

ImportCompose reads a compose file's services as rig services under their compose names, so a docker runtime with compose: finds their containers. ${VARS} fill from the environment, then the compose file's .env.

func ImportManifests

func ImportManifests(path, _ string) (map[string]*spec.Service, error)

ImportManifests makes a service of every Deployment, StatefulSet and DaemonSet under path, named after the workload, so the manifests stay the only definition: a Kubernetes runtime without manifests: deploys from these folders.

func NewPlugin

func NewPlugin(dir, name, lang string) ([]string, error)

NewPlugin writes a plugin named name in lang into dir, which must be empty or missing, and returns the files it wrote.

func Presets

func Presets() []string

Presets are the names --with takes.

Types

type Candidate

type Candidate struct {
	Kind      string // go, python, node, rust, java, dotnet, ruby, dockerfile, compose, manifest, helm, goland, container, tests
	Name      string
	Where     string
	Service   *Service
	Suite     *Suite
	Manifests string
	// Import is the imports: entry ({kind, path}) that brings Service from its own file instead of a copy.
	Import [2]string
}

Candidate is something rig init --deep found that could go into rig.yaml: a service to run, a test suite, or a folder of manifests.

func Deep

func Deep(ctx context.Context, root string) ([]Candidate, error)

Deep walks every folder under root and lists what could run there, without building anything: Go main packages and test packages, Python/Node/Rust/Java/.NET/Ruby entry points, Dockerfiles, compose services, Kubernetes workloads, Helm charts, GoLand run configurations, and the containers running on this machine. Names are unique; the first find of a name wins.

type Component

type Component struct {
	Name   string
	Fields [][2]string
}

Component is a components: entry, its fields in order.

type Options

type Options struct {
	// With are presets to add: postgres, mysql, mssql, redis, kafka, rabbitmq, consul, prometheus,
	// jaeger, loki, otel.
	With []string
	// Scan turns the source scan off when false (compose and manifests still count).
	NoScan bool
}

type Plan

type Plan struct {
	Project    string
	Services   []*Service
	Components []Component
	Suites     []Suite
	Manifests  []string
	// Imports are imports: entries ({kind: path}), the files that stay the services' definition.
	Imports [][2]string
	Godev   bool
	// OTel is where services send traces, when a tracing backend that takes OTLP is there.
	OTel string
	// Notes say what was found where, for the summary.
	Notes []string
}

func Detect

func Detect(ctx context.Context, dir string, o Options) (*Plan, error)

Detect builds the plan for dir.

func PlanOf

func PlanOf(root string, picked []Candidate) *Plan

PlanOf turns picked candidates into a plan: their services, suites and manifest folders.

func (*Plan) YAML

func (p *Plan) YAML() ([]byte, error)

YAML is the rig.yaml of the plan.

type Port

type Port struct {
	Name string
	Port int
}

type Service

type Service struct {
	Name, Role, Image string
	// Go is a main package to build; Dockerfile and Context a docker build.
	Go, Dockerfile, Context string
	Run                     []string
	RunDir                  string
	Ports                   []Port
	Env                     [][2]string
	DependsOn               []string
	// Docker is the docker runtime's section: compose's entrypoint, command and volumes.
	DockerCommand, DockerArgs, Volumes []string
	Shared                             bool
	From                               string
	// Adopt is a running container rig takes over (docker: {container: ...}) instead of making one.
	Adopt string
	// Section groups it on the Services screen (sections:), by what rig init --deep found it as.
	Section string
	// Imported comes from a compose file or manifests rig.yaml imports: only what they lack is written.
	Imported bool
}

type Suite

type Suite struct {
	Name, Dir, Command string
	Packages           []string
}

Jump to

Keyboard shortcuts

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