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 ¶
const ( GoVersion = "1.27.4" GoImage = "1.27.4-alpine3.24" AlpineVersion = "3.24.4" )
Toolchain versions written into every Go starter.
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 ¶
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.
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.
type File ¶
File is one rendered file, relative to the starter's directory.
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.
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 ¶
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 (Starter) DefaultLab ¶
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.