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

config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config is the schema of pogi.yaml: server settings, seed resources, CloudFormation stacks, chaos rules and IAM identities. It imports nothing from pogi so every package can use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRelay

func CheckRelay(relay string) error

CheckRelay checks an email relay URL, smtp://[user:pass@]host[:port]; empty is none.

func Find

func Find(explicit string) string

Find returns the config file to use: explicit, else $POGI_CONFIG, else ./pogi.yaml or ./pogi.yml; "" when there is none.

Types

type AI

type AI struct {
	Endpoint string            `yaml:"endpoint"`
	APIKey   string            `yaml:"apiKey"`
	Models   map[string]string `yaml:"models"`  // service model id glob → local model
	Timeout  time.Duration     `yaml:"timeout"` // longest one model call; 0 means 5m
}

AI is an optional OpenAI-compatible endpoint (Ollama, LM Studio) that Bedrock and the language services answer with.

type AWSIdentities

type AWSIdentities struct {
	Users []User `yaml:"users"`
	Roles []Role `yaml:"roles"`
}

AWSIdentities are IAM users (with fixed access keys) and roles.

type CORS

type CORS struct {
	Origins []string `yaml:"origins"`
	Headers []string `yaml:"headers"`
}

CORS lists browser origins and headers allowed on every API.

type Chaos

type Chaos struct {
	Name    string        `yaml:"name"`
	Cloud   string        `yaml:"cloud"`
	Service string        `yaml:"service"`
	Op      string        `yaml:"op"`
	Region  string        `yaml:"region"`
	Rate    float64       `yaml:"rate"` // 0..1; 0 means always
	Latency time.Duration `yaml:"latency"`
	Status  int           `yaml:"status"`
	Code    string        `yaml:"code"`
	Message string        `yaml:"message"`
}

Chaos is a fault-injection rule (see core.Rule).

type Docker

type Docker struct {
	Host    string            `yaml:"host"`    // empty: auto-detect Docker, Podman, Colima, OrbStack
	Network string            `yaml:"network"` // default "pogi"
	Images  map[string]string `yaml:"images"`  // e.g. rds.postgres: postgres:16-alpine
}

Docker is the container engine pogi drives when one is running.

type Email

type Email struct {
	SMTPPort int    `yaml:"smtpPort"` // 2525 by default; -1 turns it off
	Relay    string `yaml:"relay"`    // smtp://[user:pass@]host:port
}

Email is SES's SMTP side: the port mail can be sent to, and an SMTP server (Mailpit, MailHog) every message sent through SES also goes to.

type File

type File struct {
	Path       string     `yaml:"-"` // where it was loaded from, for error messages
	Version    int        `yaml:"version"`
	Server     Server     `yaml:"server"`
	Services   Services   `yaml:"services"`
	Storage    Storage    `yaml:"storage"`
	IAM        IAM        `yaml:"iam"`
	Lambda     Lambda     `yaml:"lambda"`
	Docker     Docker     `yaml:"docker"`
	AI         AI         `yaml:"ai"`
	Email      Email      `yaml:"email"`
	Chaos      []Chaos    `yaml:"chaos"`
	Identities Identities `yaml:"identities"`
	Resources  Resources  `yaml:"resources"`
	Stacks     []Stack    `yaml:"stacks"`
}

File is a parsed pogi.yaml. Zero values mean "not set": defaults, environment variables and flags fill them in (flags > env > file > defaults).

func Load

func Load(path string) (*File, error)

Load reads a pogi.yaml: it expands ${VAR} and ${VAR:-default}, rejects unknown keys and checks values. Errors read "path:line: message", one per line.

func (*File) Check added in v0.2.0

func (f *File) Check() error

Check runs the file's checks on settings that flags and environment variables may have changed, naming each bad value by its pogi.yaml key, since it has no line.

type IAM

type IAM struct {
	Mode               string `yaml:"mode"`
	ValidateSignatures bool   `yaml:"validateSignatures"`
}

IAM is policy enforcement (off | soft | strict) and signature checking.

type Identities

type Identities struct {
	AWS AWSIdentities `yaml:"aws"`
}

Identities are IAM users and roles created at startup (and after a reset).

type Item

type Item struct {
	Name  string
	Props map[string]any // everything except name
	Line  int
}

Item is one friendly resource: a bare name, or a map with a name and properties.

type Items

type Items []Item

Items accepts three spellings:

buckets: [uploads, {name: logs, versioning: true}]   # names or maps
secrets: {db-password: hunter2}                       # name → value
queues:  {jobs: {delaySeconds: 5}}                    # name → properties

func (Items) MarshalYAML

func (l Items) MarshalYAML() (any, error)

MarshalYAML writes items in list form, for `pogi config print`.

func (*Items) UnmarshalYAML

func (l *Items) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements the spellings above.

type Lambda

type Lambda struct {
	Executor    string        `yaml:"executor"`
	WarmPool    int           `yaml:"warmPool"`
	InitTimeout time.Duration `yaml:"initTimeout"` // longest a new environment may take to start; 0 means 10s, as on AWS
}

Lambda is the function executor (auto | native | docker).

type Resources

type Resources struct {
	AWS   map[string]map[string]Items `yaml:"aws"`
	GCP   map[string]map[string]Items `yaml:"gcp"`
	Azure map[string]map[string]Items `yaml:"azure"`
	Typed []Typed                     `yaml:"typed"`
}

Resources are seeded at startup and after every reset; existing ones are skipped. Friendly entries are keyed cloud → service → kind, e.g. aws.s3.buckets.

type Role

type Role struct {
	Name     string         `yaml:"name"`
	Account  string         `yaml:"account"`
	Trust    string         `yaml:"trust"`
	Policies []string       `yaml:"policies"`
	Inline   map[string]any `yaml:"inline"`
}

Role is an IAM role; Trust is a service principal (lambda.amazonaws.com), an account id or ARN, or "*".

type Server

type Server struct {
	Port          int    `yaml:"port"`
	Host          string `yaml:"host"`          // anything but loopback needs AllowExternal
	Region        string `yaml:"region"`        // the partition follows the region (cn-*, us-gov-*)
	Hostname      string `yaml:"hostname"`      // localhost; aws.localhost enables virtual-host style
	TLS           TLS    `yaml:"tls"`           // empty: pogi's local CA
	CORS          CORS   `yaml:"cors"`          // extra origins allowed to call the APIs from a browser
	AllowExternal bool   `yaml:"allowExternal"` // allow a non-loopback Host
	MaxUploadMB   int    `yaml:"maxUploadMB"`   // largest upload in MiB; 0 means 10
}

Server is where and how pogi listens.

type Services

type Services struct {
	Enable  []string `yaml:"enable"`
	Disable []string `yaml:"disable"`
}

Services enables clouds or services ("all", "aws", "s3", …).

type Stack

type Stack struct {
	Name       string            `yaml:"name"`
	Template   string            `yaml:"template"` // path, relative to the config file
	Parameters map[string]string `yaml:"parameters"`
	Account    string            `yaml:"account"`
	Region     string            `yaml:"region"`
	Line       int               `yaml:"-"`
}

Stack is a CloudFormation stack deployed at startup.

func (*Stack) UnmarshalYAML

func (s *Stack) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML records the line, for deployment errors.

type Storage

type Storage struct {
	Mode          string            `yaml:"mode"`
	Dir           string            `yaml:"dir"`
	FlushInterval time.Duration     `yaml:"flushInterval"` // hybrid
	Services      map[string]string `yaml:"services"`      // per-service mode
}

Storage is how state is kept: memory | hybrid | persistent | wal.

type TLS

type TLS struct {
	Cert string `yaml:"cert"`
	Key  string `yaml:"key"`
}

TLS is a custom certificate for the HTTPS side of the main port.

type Typed

type Typed struct {
	Type       string         `yaml:"type"`
	Name       string         `yaml:"name"` // optional logical id
	Account    string         `yaml:"account"`
	Region     string         `yaml:"region"`
	Properties map[string]any `yaml:"properties"`
	Line       int            `yaml:"-"`
}

Typed is a resource in CloudFormation form ("AWS::SNS::Topic"); GCP and Azure types follow once the generic engine exists.

func (*Typed) UnmarshalYAML

func (t *Typed) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML records the line, for seeding errors.

type User

type User struct {
	Name      string         `yaml:"name"`
	Account   string         `yaml:"account"`
	AccessKey string         `yaml:"accessKey"`
	SecretKey string         `yaml:"secretKey"`
	Policies  []string       `yaml:"policies"` // managed policy ARNs
	Inline    map[string]any `yaml:"inline"`   // policy name → policy document
	Groups    []string       `yaml:"groups"`
}

User is an IAM user; AccessKey and SecretKey make its credentials fixed.

Jump to

Keyboard shortcuts

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