devconfig

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package devconfig reads the developer's own settings for aicoded dev: ports, the apps' environment, personas, the local MySQL server and local values of settings and secrets. The file holds secrets, so only its owner may read it.

Index

Constants

View Source
const DefaultPort = 8080

DefaultPort is the dev gateway's port when the workspace sets none.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the location of dev.yaml in the user's configuration directory.

func MySQL

func MySQL(path, dir string) (string, error)

MySQL returns the MySQL admin DSN for the folder dir, an absolute path: that of the workspace of the nearest folder at or above dir that names one in the dev.yaml at path, or "".

Types

type AppValues

type AppValues struct {
	Settings map[string]string `yaml:"settings"`
	Secrets  map[string]string `yaml:"secrets"`
}

AppValues are local values for the settings and secrets an app declares.

type Env

type Env string

Env is an environment a workspace's apps can run in.

const (
	// EnvDev is aicoded dev's own environment, the default.
	EnvDev Env = "dev"
	// EnvPreview runs the apps as a preview, so that the framework behaves as it does outside
	// aicoded dev.
	EnvPreview Env = "preview"
)

func (*Env) UnmarshalYAML

func (e *Env) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML accepts only a valid Env.

func (Env) Valid

func (e Env) Valid() bool

Valid reports whether e is EnvDev or EnvPreview.

type Persona

type Persona struct {
	Name   string   `yaml:"name"`
	Groups []string `yaml:"groups"`
	Roles  []string `yaml:"roles"`
}

Persona is a test viewer the dev gateway can sign in as. Its name is the viewer's Subject, so it is 1 to viewer.MaxSubject bytes.

type Workspace

type Workspace struct {
	Port int `yaml:"port"`
	// Env is the environment the runner tells the apps they run in.
	Env Env `yaml:"env"`
	// MySQL is the DSN of an admin user of a MySQL 8 server on this machine; it creates the
	// apps' databases.
	MySQL    string               `yaml:"mysql"`
	Personas []Persona            `yaml:"personas"`
	Apps     map[string]AppValues `yaml:"apps"`
}

Workspace holds the settings for one directory tree of apps.

func Find added in v0.12.0

func Find(path, root string) (ws Workspace, found bool, above string, err error)

Find returns what Load does, whether the dev.yaml at path names the workspace root, and, when it does not, the nearest folder above root, an absolute path, that it names, or "".

func Load

func Load(path, root string) (Workspace, error)

Load returns the settings for the workspace rooted at root. A missing file gives defaults. Personas stay empty when the workspace names none; the caller picks the defaults.

Jump to

Keyboard shortcuts

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