Documentation
¶
Overview ¶
Package envtemplate renders Peen's commented .env file.
One template is the source of both .env.example and the .env that `peen config init` writes, so the example a reader copies and the file an installer writes cannot drift apart.
Index ¶
Constants ¶
const ( // FileMode keeps the env file private to its owner: it holds the API // token and provider keys once an operator fills them in. FileMode fs.FileMode = 0o600 )
Variables ¶
This section is empty.
Functions ¶
func WriteNew ¶
WriteNew renders values and writes them to path, which must be absolute and must not exist yet.
The file is written in full to a temporary file beside path and then hard linked into place. A link never replaces an existing name, so an operator's .env is never overwritten, and a reader never sees a partly written file. An existing path returns commerr.ErrAlreadyExists and is left unchanged. Invalid values return commerr.ErrValidationFailed and write nothing.
Types ¶
type ControlSpace ¶
type ControlSpace = string
ControlSpace is where Peen itself runs. The peen command reads it, and the controller ignores it.
const ( // ControlSpaceHost runs the Peen binary on the host. ControlSpaceHost ControlSpace = "host" // ControlSpaceDocker runs Peen in a container. ControlSpaceDocker ControlSpace = "docker" )
type Values ¶
type Values struct {
ConfigDirectory string
StateDirectory string
WorkspaceRoot string
DefaultAgentSpace string
WorkerImage string
HTTPListenAddress string
HostUsername string
HostHome string
ControlSpace ControlSpace
Image string
ContainerName string
}
Values are the settings an installer knows before Peen first starts. An empty field renders the template's commented placeholder or default, so the zero Values renders .env.example.
func (Values) Validate ¶
Validate refuses values that would render a file Peen or the peen command cannot use: a line break in any value, a relative path, an agent space that is neither control nor docker:<profile>, a control space other than host or docker, and a container name Docker would reject. Every refusal wraps commerr.ErrValidationFailed.