config

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultGatewayURL = "https://gateway.agyn.dev"
	ConfigDir         = ".agyn"
	ConfigFile        = "config.yaml"
	CredentialsFile   = "credentials"
	GatewayURLEnv     = "AGYN_GATEWAY_URL"
	GatewayAddressEnv = "GATEWAY_ADDRESS"
	// TokenEnv supplies a token without writing one to disk, for CI.
	TokenEnv = "AGYN_TOKEN"
	// OrganizationEnv scopes commands for a shell session without changing the
	// profile's recorded selection.
	OrganizationEnv = "AGYN_ORGANIZATION"

	// DefaultInstanceName is the VM used when none is named — the ordinary
	// case, where the user has exactly one and never thinks about it.
	DefaultInstanceName = "agyn"

	DefaultLocalPort    = 2496
	DefaultLocalAPIPort = 6445
	DefaultLocalVersion = "latest"
	DefaultLocalCPUs    = 4
	DefaultLocalMemory  = "8GiB"
)
View Source
const (
	// ProfileEnv selects a profile for one invocation.
	ProfileEnv = "AGYN_PROFILE"
	// DefaultProfileName is used when nothing has ever selected one.
	DefaultProfileName = "default"
	// LocalProfileName is the profile `agyn local start` provisions for the
	// default VM.
	LocalProfileName = "local"
)

Variables

This section is empty.

Functions

func ExpandPath added in v0.2.13

func ExpandPath(path string) (string, error)

ExpandPath resolves a leading ~ so configuration files can be written with portable paths.

func LocalProfileFor added in v0.2.13

func LocalProfileFor(instance string) string

LocalProfileFor names the profile that talks to one local VM. The default VM keeps the bare "local" name, so a machine with one VM sees exactly what it saw before instances existed.

func RemoveInstance added in v0.2.13

func RemoveInstance(name string) error

RemoveInstance drops a VM's settings from the config.

func RemoveProfile added in v0.2.13

func RemoveProfile(name string) error

RemoveProfile deletes a profile from the config file, clearing the current selection when it named the removed profile. Leaving currentProfile pointing at something that no longer exists would make every later command resolve against a profile the user can no longer inspect.

func SaveCurrentInstance added in v0.2.13

func SaveCurrentInstance(name string) error

SaveCurrentInstance records the VM `agyn local` acts on by default.

func SaveInstance added in v0.2.13

func SaveInstance(name string, settings LocalInstance) error

SaveInstance persists one VM's settings without disturbing other config keys (including ones this CLI version does not know about), and without rewriting the other instances.

func SaveProfiles added in v0.2.13

func SaveProfiles(currentProfile string, profiles map[string]Profile) error

SaveProfiles persists the profile section and current selection without disturbing other config keys, including ones this CLI version does not know about — the same reason SaveLocal merges rather than rewrites.

Types

type Config

type Config struct {
	// CurrentProfile is the profile commands run under when nothing overrides
	// it. Empty means the default profile.
	CurrentProfile string             `yaml:"currentProfile,omitempty"`
	Profiles       map[string]Profile `yaml:"profiles,omitempty"`
	// Local configures the VM itself — image version, host ports, resources.
	// It is not a profile: the `local` profile under Profiles configures how
	// the CLI talks to that VM, and the two are independent.
	Local LocalConfig `yaml:"local"`
}

func Load

func Load() (*Config, error)

func (*Config) InstanceNames added in v0.2.13

func (c *Config) InstanceNames() []string

InstanceNames lists the configured VMs, default first and the rest sorted, so output is stable between runs.

func (*Config) InstanceSettings added in v0.2.13

func (c *Config) InstanceSettings(name string) LocalInstance

InstanceSettings returns the stored settings for one VM with the version/resource defaults applied.

Ports are left as stored: zero means "not chosen yet", and only the caller knows whether that should become the well-known default or a free port found for a second VM.

func (*Config) Profile added in v0.2.13

func (c *Config) Profile(name string) Profile

Profile returns the named profile. A name that has never been configured yields an empty profile rather than an error: the gateway URL still falls back to its default, so a fresh machine can talk to a local cluster before anything has been written.

func (*Config) ProfileNames added in v0.2.13

func (c *Config) ProfileNames() []string

ProfileNames lists configured profiles in a stable order.

func (*Config) ResolveCAFile added in v0.2.13

func (c *Config) ResolveCAFile(profileName string) (string, error)

ResolveCAFile returns the profile's extra CA bundle with ~ expanded.

func (*Config) ResolveGatewayTargetFor added in v0.2.13

func (c *Config) ResolveGatewayTargetFor(profileName, flagURL string) GatewayTarget

ResolveGatewayTargetFor resolves the endpoint for a profile.

func (*Config) ResolveGatewayURLFor added in v0.2.13

func (c *Config) ResolveGatewayURLFor(profileName, flag string) string

ResolveGatewayURLFor resolves the endpoint for a profile: a flag wins, then the environment, then the profile, then the default.

func (*Config) ResolveInstanceName added in v0.2.13

func (c *Config) ResolveInstanceName(flag string) string

ResolveInstanceName picks the VM a command acts on: an explicit --instance first, then the one `agyn local select` stored, then the default. A machine with one VM therefore never has to name it.

func (*Config) ResolveOrganization added in v0.2.13

func (c *Config) ResolveOrganization(profileName, flag string) string

ResolveOrganization returns the organization a command should act in: an explicit flag, then the environment, otherwise whatever the profile has selected. An empty result means nothing has chosen one and the caller should fall back to their sole accessible organization.

func (*Config) ResolveProfileName added in v0.2.13

func (c *Config) ResolveProfileName(flag string) string

ResolveProfileName picks the profile for this invocation: an explicit flag beats the environment, which beats the recorded choice.

func (*Config) SetProfile added in v0.2.13

func (c *Config) SetProfile(name string, update Profile)

SetProfile creates or updates a profile, leaving fields the caller did not supply untouched so `profile set --organization` does not clear a gateway URL set earlier.

type GatewayTarget

type GatewayTarget struct {
	URL      string
	UsesZiti bool
}

type LocalConfig added in v0.2.13

type LocalConfig struct {
	// The flat fields are the shape from when only one VM existed. Load moves
	// them into Instances under the default name and clears them, so a config
	// written before this change keeps working and is never written back in
	// the old shape.
	Port    int    `yaml:"port,omitempty"`
	APIPort int    `yaml:"apiPort,omitempty"`
	Version string `yaml:"version,omitempty"`
	CPUs    int    `yaml:"cpus,omitempty"`
	Memory  string `yaml:"memory,omitempty"`

	// Current is the VM `agyn local` acts on when --instance is not given, set
	// by `agyn local select`. Empty means the default instance, so a machine
	// with one VM never sees this key.
	Current   string                   `yaml:"current,omitempty"`
	Instances map[string]LocalInstance `yaml:"instances,omitempty"`
}

LocalConfig configures the local platform VMs managed by `agyn local`.

One VM is the ordinary case and stays unnamed in everyday use. The map exists for the cases a single VM cannot serve: moving data between versions an upgrade cannot bridge, or running separate clusters side by side.

type LocalInstance added in v0.2.13

type LocalInstance struct {
	Port    int    `yaml:"port,omitempty"`
	APIPort int    `yaml:"apiPort,omitempty"`
	Version string `yaml:"version,omitempty"`
	CPUs    int    `yaml:"cpus,omitempty"`
	Memory  string `yaml:"memory,omitempty"`
}

LocalInstance configures one VM.

type Profile added in v0.2.13

type Profile struct {
	GatewayURL   string `yaml:"gatewayUrl,omitempty"`
	Organization string `yaml:"organization,omitempty"`
	CAFile       string `yaml:"caFile,omitempty"`
}

Profile is a named set of connection settings: which Gateway to talk to, which organization to act in, and which CA to trust. Keeping them together under a name is what lets one machine address a local VM and a remote cluster without rewriting configuration between commands.

Jump to

Keyboard shortcuts

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