starters

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package starters lists starters and renders their templates. Applying a starter to a project (writing files, editing experiment.yaml) is a core operation; this package only knows what each starter contains.

Index

Constants

View Source
const (
	GoVersion     = "1.27.4"
	GoImage       = "1.27.4-alpine3.24"
	AlpineVersion = "3.24.4"
)

Toolchain versions written into every Go starter.

View Source
const AppTemplate = "go/app"

AppTemplate is the embedded template directory of bb add app's program: one Go module with main.go at its root, built into one binary named after the app.

Variables

This section is empty.

Functions

func EnvBase

func EnvBase(service, name string) string

EnvBase is the contract name of a variable an app receives from service: name itself, or name without the service prefix bb up adds when another used service has the same variable.

func EnvHelp

func EnvHelp(base string) (string, bool)

EnvHelp says what a contract variable holds. Proxy variables are named after their service, so they match by suffix.

func SDKImport

func SDKImport(typ string) (string, bool)

SDKImport returns the client package of a catalog type, and whether the type is known; the package is empty for HTTP proxies.

Types

type App

type App struct {
	Name string
	// Command runs the app: the binary the Dockerfile's dev stage built
	// from cmd/<name> into /usr/local/bin.
	Command []string
	// Uses lists catalog types, each resolved to the experiment's service of
	// that type, or the names of this starter's Services.
	Uses []string
	// Register, when set, registers the app in the registry it uses through a sidecar.
	Register *spec.Register
	// Replicas is the number of instances; zero means one.
	Replicas int
	// Sidecars run in the app's pod. A reference to an infra service
	// (pgbouncer service, fluent-bit to, an outbound service that is not an
	// app of this starter) names its catalog type, which resolves like Uses.
	Sidecars []spec.Sidecar
}

App is an app service the starter adds.

type AppScaffold

type AppScaffold struct {
	Name       string // app name: the binary and the command; the module is example.com/<Name>
	Experiment string
	Uses       []AppUse
	// Taken are the names experiment.yaml already uses (services and
	// apps), so the README's add-a-service example names a new one.
	Taken []string
}

AppScaffold is what bb add app renders: the app and, for each service in its uses, the variables bb up gives it.

type AppUse

type AppUse struct {
	Service   string
	Type      string // catalog type
	Title     string // catalog title
	Summary   string // catalog summary
	Plaintext bool   // the edge has TLS off
	Vars      []AppVar
}

AppUse is one service in the app's uses, with its env contract exactly as the app receives it.

type AppVar

type AppVar struct {
	Name   string // as injected, prefixed when another used service has the same name
	Base   string // the catalog contract's name, before any prefix
	Value  string // empty for secrets
	Secret bool
}

AppVar is one variable the app receives from a used service.

type Data

type Data struct {
	Experiment string
	// Domain is the install's service domain (default bb.internal): every
	// service and app instance is <name>.<Domain>, which native proxy
	// configs need for their backends.
	Domain        string
	GoVersion     string
	GoImage       string
	AlpineVersion string
	// contains filtered or unexported fields
}

Data is what templates can use.

func (Data) Config

func (d Data) Config(typ, key string) (string, error)

Config is one config option, defaults applied, of the experiment's service of a required catalog type: {{.Config "postgres" "database"}}.

func (Data) Service

func (d Data) Service(typ string) (string, error)

Service is the name of the experiment's service of a catalog type the starter requires: {{.Service "postgres"}}.

type File

type File struct {
	Path string
	Data []byte
}

File is one rendered file, relative to the starter's directory.

func Render

func Render(s Starter, lab Lab) ([]File, error)

Render renders every template file of s for a lab.

func RenderApp

func RenderApp(a AppScaffold) ([]File, error)

RenderApp renders bb add app's program for a: main.go with the lab map, requireEnv, auto-wired SDK clients for every used service, and wiring helpers below main.

func RenderFS

func RenderFS(fsys fs.FS, s Starter, lab Lab) ([]File, error)

RenderFS renders s from templates in fsys, rooted like the embedded templates. Tests use it to apply starters that do not ship.

type Infra

type Infra struct {
	Name string
	// Config is every config option of the service, defaults applied.
	Config map[string]string
}

Infra is the experiment's service for one catalog type a starter requires.

func DefaultInfra

func DefaultInfra(typ string) Infra

DefaultInfra is a service named after a catalog type, with the type's default config.

type Lab

type Lab struct {
	Experiment string
	// Domain is the install's service domain (default bb.internal).
	Domain string
	// Infra maps each catalog type in the starter's Requires to the
	// experiment's service of that type.
	Infra map[string]Infra
}

Lab is the experiment a starter is rendered for.

type Service

type Service struct {
	// Name is unique across every starter, like app names.
	Name string
	// Type is a proxy type from the catalog (haproxy, envoy, traefik,
	// nginx, pgbouncer).
	Type string
	// Upstreams are the proxy's backends. Each Service names an app of
	// this starter or a catalog type in Requires, which resolves to the
	// experiment's service of that type, like Uses. Port, Name and TLS
	// (mode and reason) are written as given.
	Upstreams []spec.Upstream
	// File is the path of a rendered template file (without .tmpl),
	// relative to the starter's directory. bb starter writes it with the
	// code and sets the service's file to it, relative to experiment.yaml.
	// Empty keeps the generated config.
	File string
	// StaticFile is like File for the service's static_file: a rendered
	// template file merged into the proxy's generated static
	// configuration (Traefik only).
	StaticFile string
	// Config is the service's config, written as given and validated
	// against the catalog entry's options like any config.
	Config map[string]string
}

Service is a proxy service the starter adds: an infra service of a proxy type, with upstreams and, usually, a native config the learner owns.

type Starter

type Starter struct {
	ID       string
	Title    string
	Summary  string
	Language string
	// Template is the directory in the embedded templates.
	Template string
	// Dir is the default directory the code is written to, relative to the project.
	Dir string
	// Requires lists catalog types the starter needs; missing ones are added.
	Requires []string
	// RequiresConfig holds config options to apply to required catalog types
	// (keyed by catalog type id). For otel, signals are merged when the
	// service already exists.
	RequiresConfig map[string]map[string]string
	// RequiresHost lists required catalog types that get host: true so they
	// are reachable in the browser through bb-host.
	RequiresHost []string
	Apps         []App
	// Services are proxies the starter adds in front of its apps.
	Services []Service
}

Starter is one starter's definition.

func All

func All() []Starter

All returns every starter.

func Lookup

func Lookup(id string) (Starter, bool)

Lookup finds a starter by id.

func (Starter) DefaultLab

func (s Starter) DefaultLab(experiment, domain string) Lab

DefaultLab is the lab s renders for in an experiment that has none of its required services yet: each type gets a service named after it with the catalog's default config, as applying the starter would add.

Jump to

Keyboard shortcuts

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