Documentation
¶
Overview ¶
Package core is the construct model of the yawn kit. An App holds Stacks, a Stack holds Resources, and Synth writes everything to an output folder (.yawn/ by default) as plain OpenTofu configuration plus manifest.json.
Synth never touches the network or reads credentials, and its output is a pure function of the program: the same program always writes the same bytes.
Index ¶
- Constants
- Variables
- func Ref(r *Resource, attr string) string
- func VarRef(name string) string
- type App
- type Backend
- type Encryption
- type Manifest
- type ManifestProvider
- type ManifestStack
- type Provider
- type ProviderRelease
- type Resource
- type Stack
- func (s *Stack) AddResource(r *Resource) *Resource
- func (s *Stack) Encrypt(e Encryption)
- func (s *Stack) Import(to *Resource, id string)
- func (s *Stack) Note(key string, value any)
- func (s *Stack) RequireProvider(p Provider)
- func (s *Stack) Resources() []*Resource
- func (s *Stack) SetBackend(b Backend)
- func (s *Stack) Variable(name string, v Variable)
- type Variable
- type ZipPin
Constants ¶
const DefaultOutDir = ".yawn"
DefaultOutDir is the synth output folder. It is built in CI and never committed.
const ManifestVersion = 1
ManifestVersion is the manifest.json schema version. Consumers must refuse versions they do not understand.
Variables ¶
var KitVersion = "code.yawn.dev/john/cdk@v0.2.0-dev.1"
KitVersion identifies this library in manifests. Set by releases.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the root of a construct tree. Create one per program.
type Backend ¶
type Backend interface {
// Block returns the backend type and its static configuration for a stack.
// It must not contain credentials.
Block(stackID string) (kind string, config map[string]any)
}
Backend is a stack's state backend.
type Encryption ¶
type Encryption struct {
// PassphraseVariable names the sensitive variable holding the passphrase.
PassphraseVariable string
}
Encryption enables OpenTofu client-side encryption of state and plans with a PBKDF2 passphrase taken from a sensitive variable. Encryption is enforced: OpenTofu refuses to write state or plans unencrypted.
type Manifest ¶
type Manifest struct {
Version int `json:"manifest_version"`
Kit string `json:"kit"`
Stacks []ManifestStack `json:"stacks"`
}
Manifest is the typed summary written to <out>/manifest.json. It is data only: consumers read it without running any repository code.
type ManifestProvider ¶
type ManifestProvider struct {
Source string `json:"source"`
Version string `json:"version"`
Release ProviderRelease `json:"release"`
}
ManifestProvider pins a provider so CD can install exactly these zips.
type ManifestStack ¶
type ManifestStack struct {
ID string `json:"id"`
Dir string `json:"dir"`
Providers []ManifestProvider `json:"providers"`
Resources []string `json:"resources"`
Imports map[string]string `json:"imports,omitempty"`
Variables []string `json:"variables"`
Encrypted bool `json:"encrypted"`
Notes map[string]any `json:"notes,omitempty"`
}
ManifestStack describes one synthesized stack.
type Provider ¶
type Provider struct {
// Name is the local name, e.g. "gitea".
Name string
// Source is the full address, e.g. "registry.yawn.dev/john/gitea".
Source string
// Version is exact; ranges are refused.
Version string
// Release pins zips published as release assets. Required: synth writes the
// lock file from it, so plans never trust an unpinned download.
Release ProviderRelease
// Config is the provider block. Credentials must come from the environment.
Config map[string]any
}
Provider is a pinned OpenTofu provider.
type ProviderRelease ¶
type ProviderRelease struct {
// BaseURL is the HTTPS download directory, ending in "/".
BaseURL string `json:"base_url"`
// Zips maps a platform ("linux_amd64") to its pinned zip.
Zips map[string]ZipPin `json:"zips"`
}
ProviderRelease pins a provider's per-platform zips.
type Resource ¶
type Resource struct {
Type string
Name string
Attrs map[string]any
// PreventDestroy makes OpenTofu refuse any plan that destroys this resource.
PreventDestroy bool
// IgnoreChanges lists attributes OpenTofu must not reconcile.
IgnoreChanges []string
}
Resource is one OpenTofu resource.
type Stack ¶
type Stack struct {
ID string
// contains filtered or unexported fields
}
Stack is one OpenTofu root module: one state, one plan, one apply.
func (*Stack) AddResource ¶
AddResource adds a resource. Addresses are unique within a stack.
func (*Stack) Encrypt ¶
func (s *Stack) Encrypt(e Encryption)
Encrypt enables enforced client-side encryption of state and plans.
func (*Stack) RequireProvider ¶
RequireProvider declares a provider. Repeating a name must agree exactly.
func (*Stack) SetBackend ¶
SetBackend sets the state backend. Synth refuses a stack without one.