Documentation
¶
Index ¶
- Constants
- Variables
- func ActionLogPath(root, name string) string
- func ConfigHome(override string) (string, error)
- func ConfigPath(root string) string
- func ConsoleAPIKeyPath(root, ctxName string) string
- func ContextDir(root, name string) string
- func ContextWorkflowsDir(root, name string) string
- func EnsureContextDirs(root, name string) error
- func KeyringDir(root string, kr Keyring) string
- func NetworkTemplates() map[string]Network
- func NewViper(root string) (*viper.Viper, error)
- func ResolveConsoleAPIKey(root, ctxName string) string
- func ResolveProviderAuthType(value string) (string, error)
- func SaveConfig(root string, cfg *Config) error
- func SetConsoleAPIKey(root, ctxName, key string) error
- func StoreDBPath(root, name string) string
- func StoreDir(root, name string) string
- func StoredConsoleAPIKey(root, ctxName string) (string, error)
- func ValidateConsoleOrganization(value string) error
- func ValidateConsoleProject(value string) error
- func WorkflowsDir(root string) string
- type Config
- type Context
- type Defaults
- type Endpoints
- type Keyring
- type Manager
- func (m *Manager) ActiveContext(override string) string
- func (m *Manager) Config() Config
- func (m *Manager) CreateContext(ctx Context) error
- func (m *Manager) CreateKeyring(kr Keyring) error
- func (m *Manager) CreateNetwork(net Network) error
- func (m *Manager) CreateNetworkFromTemplate(name, template string) error
- func (m *Manager) CurrentContext() string
- func (m *Manager) DeleteContext(name string, keepData bool) error
- func (m *Manager) DeleteNetwork(name string) error
- func (m *Manager) ForkNetwork(srcName, newName string) error
- func (m *Manager) GetContext(name string) *Context
- func (m *Manager) GetKeyring(name string) *Keyring
- func (m *Manager) GetNetwork(name string) *Network
- func (m *Manager) KeyringUsers(name string) []string
- func (m *Manager) ListContexts() []Context
- func (m *Manager) ListKeyrings() []Keyring
- func (m *Manager) ListNetworks() []Network
- func (m *Manager) NetworkUsers(name string) []string
- func (m *Manager) Reload() error
- func (m *Manager) RenameContext(oldName, newName string) error
- func (m *Manager) Resolve(name string) (*Context, error)
- func (m *Manager) Root() string
- func (m *Manager) UpdateContext(name string, apply func(*Context) error) error
- func (m *Manager) UpdateContextAndNetwork(name string, forkName string, applyContext func(*Context) error, ...) error
- func (m *Manager) UpdateKeyring(name string, apply func(*Keyring) error) error
- func (m *Manager) UpdateNetwork(name string, apply func(*Network) error) error
- func (m *Manager) UseContext(name string) error
- type Network
- type PluginSettings
- type ProviderDefaults
- type TUISettings
- type Watcher
Constants ¶
const ( // KeyringServiceName is the service name akt registers with the OS // keyring backend (Keychain on macOS, libsecret on Linux). The service // name is the lookup key, which is why akt cannot see entries written // by the legacy CLI and vice versa (SPEC §1.12). KeyringServiceName = "akt" // LegacyKeyringServiceName is the service name used by the legacy // akash / provider-services CLIs. It exists so the first-run wizard can // explain the mismatch; akt never opens a keyring under this name. LegacyKeyringServiceName = "akash" )
const ( EnvConsoleOrganization = "AKT_CONSOLE_ORGANIZATION" EnvConsoleProject = "AKT_CONSOLE_PROJECT" )
Environment variables that select the Console organization and project for one invocation, overriding the context's stored selection (SPEC §7.1.1).
const ( AuthMethodKeyring = "keyring" AuthMethodConsoleAPI = "console-api" )
Authentication methods a context can use (SPEC §1.4, §7).
const ( ProviderAuthJWT = "jwt" ProviderAuthMTLS = "mtls" )
const ConfigVersion = 1
ConfigVersion is the current schema version.
const DefaultConsoleAPIURL = "https://console-api.akash.network"
DefaultConsoleAPIURL is the default Console API base URL (SPEC §7.2).
const EnvConsoleAPIKey = "AKT_CONSOLE_API_KEY"
EnvConsoleAPIKey is the environment variable holding the Console API key. It overrides the per-context stored credential (SPEC §7.1).
Variables ¶
var DefaultHome = filepath.Join(os.Getenv("HOME"), ".config", "akt")
DefaultHome is the fallback home directory used when no override or env var is set. It matches the last-resort path in ConfigHome.
Functions ¶
func ActionLogPath ¶
ActionLogPath returns the action log file path for a named context.
func ConfigHome ¶
ConfigHome resolves the akt home directory.
Resolution order:
- override parameter (from --home flag)
- AKT_HOME env var
- $XDG_CONFIG_HOME/akt
- ~/.config/akt
func ConfigPath ¶
ConfigPath returns the path to config.yaml within the given config root.
func ConsoleAPIKeyPath ¶
ConsoleAPIKeyPath returns the path of a context's stored Console API key. The credential lives inside the context's data directory so renames move it and deletes remove it (SPEC §7.1).
func ContextDir ¶
ContextDir returns the data directory for a named context.
func ContextWorkflowsDir ¶
ContextWorkflowsDir returns the per-context workflows directory.
func EnsureContextDirs ¶
EnsureContextDirs creates the store and action log directories for a context. The context directory is 0700: it holds per-context secrets (the Console API credential) alongside the store and action log.
func KeyringDir ¶
KeyringDir returns the directory for a named keyring.
func NetworkTemplates ¶
NetworkTemplates returns pre-configured network definitions for known Akash networks. Returns a fresh map on each call to prevent mutation of shared state.
func NewViper ¶
NewViper creates a Viper instance configured for the given root directory. It reads config.yaml, binds environment variables with the AKT_ prefix, and sets defaults from DefaultConfig.
func ResolveConsoleAPIKey ¶
ResolveConsoleAPIKey resolves the effective Console API key for a context per SPEC §7.1: environment variable first, then the stored per-context credential. The --console-api-key flag override is applied by the CLI layer on top of this.
func ResolveProviderAuthType ¶ added in v0.0.3
ResolveProviderAuthType applies the context default and validates the provider gateway authentication enum at the configuration boundary.
func SaveConfig ¶
SaveConfig writes the config to config.yaml in the given root. It creates the root directory and parent directories as needed. Uses YAML encoder with 2-space indentation.
func SetConsoleAPIKey ¶
SetConsoleAPIKey stores (or, with an empty key, removes) a context's Console API key. The file is written with 0600 permissions and is never part of config.yaml.
func StoreDBPath ¶ added in v0.0.4
StoreDBPath returns the deployment store database path for a named context. It is the single source of truth for where a context's store lives; every opener must go through it so `akt store status` and a workflow's own persistence (SPEC §6.6) can never disagree about which file they mean.
func StoredConsoleAPIKey ¶
StoredConsoleAPIKey reads a context's stored Console API key. A missing credential file returns an empty key with no error.
func ValidateConsoleOrganization ¶ added in v1.1.0
ValidateConsoleOrganization checks a stored organization selector, which is the organization's id or slug as the Console API accepts them in x-organization-id. Empty clears the selection.
func ValidateConsoleProject ¶ added in v1.1.0
ValidateConsoleProject checks a stored project selector. A context stores the project's id, which survives renames; names are resolved to ids by `akt console project use`. Empty clears the selection.
func WorkflowsDir ¶
WorkflowsDir returns the global workflows directory within the home.
Types ¶
type Config ¶
type Config struct {
Version int `yaml:"version" json:"version"`
CurrentContext string `yaml:"current-context" json:"current_context"`
Networks []Network `yaml:"networks" json:"networks"`
Keyrings []Keyring `yaml:"keyrings" json:"keyrings"`
Contexts []Context `yaml:"contexts" json:"contexts"`
TUI TUISettings `yaml:"tui,omitempty" json:"tui,omitempty"`
Plugins PluginSettings `yaml:"plugins,omitempty" json:"plugins,omitempty"`
Defaults Defaults `yaml:"defaults,omitempty" json:"defaults,omitempty"`
}
Config is the top-level configuration structure persisted in config.yaml.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a new empty config with version set.
func LoadConfig ¶
LoadConfig reads and parses the config.yaml file from the given root using Viper. If the file does not exist, a default config is returned.
type Context ¶
type Context struct {
Name string `yaml:"-" json:"name"`
Network Network `yaml:"-" json:"network"`
Keyring Keyring `yaml:"-" json:"keyring"`
AuthMethod string `yaml:"auth-method,omitempty" json:"auth_method,omitempty"`
ConsoleAPIURL string `yaml:"console-api-url,omitempty" json:"console_api_url,omitempty"`
ConsoleOrganization string `yaml:"console-organization,omitempty" json:"console_organization,omitempty"`
ConsoleProject string `yaml:"console-project,omitempty" json:"console_project,omitempty"`
DefaultAccount string `yaml:"default-account,omitempty" json:"default_account,omitempty"`
TrackedAccounts []string `yaml:"tracked-accounts,omitempty" json:"tracked_accounts,omitempty"`
Gas string `yaml:"gas,omitempty" json:"gas,omitempty"`
Fees string `yaml:"fees,omitempty" json:"fees,omitempty"`
ProviderDefaults ProviderDefaults `yaml:"provider-defaults,omitempty" json:"provider_defaults,omitempty"`
// Resolved fields -- populated by Manager.Resolve(), not serialized.
// These are convenience accessors that flatten nested values.
GasPrices string `yaml:"-" json:"-"`
GasAdjustment string `yaml:"-" json:"-"`
AuthType string `yaml:"-" json:"-"`
Root string `yaml:"-" json:"-"` // config root directory
// ConsoleAPIKey is the resolved Console API key (env var overrides the
// per-context credential file, SPEC §7.1). Never serialized.
ConsoleAPIKey string `yaml:"-" json:"-"`
}
Context defines a named environment that composes a network, keyring, and context-specific settings (store + action log are implicitly per-context).
In config (YAML), Network and Keyring are serialized as name strings that reference top-level network and keyring definitions. After resolution via Manager.Resolve(), the full Network and Keyring objects are populated with all their fields.
TrackedAccounts names the accounts store reconciliation covers (SPEC §6.7): empty means the default account alone, ["*"] every account in the context's keyring.
ConsoleOrganization and ConsoleProject select the Console organization (team) and project that Console calls act in (SPEC §7.1.1). Empty means the API key's own scope, which is how every context behaved before teams. Manager.Resolve applies their environment overrides.
func (Context) MarshalYAML ¶
MarshalYAML serializes a Context to YAML, writing Network and Keyring as name strings.
type Defaults ¶
type Defaults struct {
Output string `yaml:"output,omitempty" json:"output,omitempty"`
BroadcastMode string `yaml:"broadcast-mode,omitempty" json:"broadcast_mode,omitempty"`
// CommandGating selects how commands the context configuration cannot
// execute are presented: dim (default), hide, or off. Both dim and
// hide are supported while UX feedback is collected.
CommandGating string `yaml:"command-gating,omitempty" json:"command_gating,omitempty"`
}
Defaults holds global default values.
type Endpoints ¶
type Endpoints struct {
RPC []string `yaml:"rpc" json:"rpc"`
API []string `yaml:"api,omitempty" json:"api,omitempty"`
GRPC []string `yaml:"grpc,omitempty" json:"grpc,omitempty"`
}
Endpoints defines the network transport endpoints.
type Keyring ¶
type Keyring struct {
Name string `yaml:"name" json:"name"`
Backend string `yaml:"backend,omitempty" json:"backend,omitempty"`
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`
}
Keyring defines wallet storage configuration. Keyrings are shared -- adding a key makes it available to all contexts using the keyring.
func DefaultKeyring ¶
func DefaultKeyring() Keyring
DefaultKeyring returns the default keyring configuration.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides CRUD operations for networks, contexts, and keyrings. It holds the config in memory and persists changes to disk. Manager is safe for concurrent use.
func NewManager ¶
NewManager creates a manager by loading (or initialising) config from root.
func (*Manager) ActiveContext ¶
ActiveContext resolves which context a run targets: the explicit override (the global --context flag), else current-context, else the sole configured context. Returns "" when no single context can be determined.
func (*Manager) CreateContext ¶
CreateContext adds a new context. The referenced network and keyring must exist.
func (*Manager) CreateKeyring ¶
CreateKeyring adds a new keyring definition.
func (*Manager) CreateNetwork ¶
CreateNetwork adds a new network definition. If template is non-empty, the network fields are populated from NetworkTemplates.
func (*Manager) CreateNetworkFromTemplate ¶
CreateNetworkFromTemplate creates a network from a built-in template. The name parameter overrides the template's default name.
func (*Manager) CurrentContext ¶
CurrentContext returns the name of the active context.
func (*Manager) DeleteContext ¶
DeleteContext removes a context. Cannot delete the current context. If keepData is false, the context data directory is also removed.
func (*Manager) DeleteNetwork ¶
DeleteNetwork removes a network. It fails if any context references it.
func (*Manager) ForkNetwork ¶
ForkNetwork creates a copy of an existing network with a new name.
func (*Manager) GetContext ¶
GetContext returns a context by name, or nil if not found.
func (*Manager) GetKeyring ¶
GetKeyring returns a keyring by name, or nil if not found.
func (*Manager) GetNetwork ¶
GetNetwork returns a network by name, or nil if not found.
func (*Manager) KeyringUsers ¶ added in v0.0.4
KeyringUsers returns the names of contexts referencing the named keyring.
func (*Manager) ListContexts ¶
ListContexts returns all configured contexts.
func (*Manager) ListKeyrings ¶
ListKeyrings returns all configured keyrings.
func (*Manager) ListNetworks ¶
ListNetworks returns all configured networks.
func (*Manager) NetworkUsers ¶
NetworkUsers returns the names of contexts referencing a network.
func (*Manager) RenameContext ¶
RenameContext renames a context and its data directory.
func (*Manager) Resolve ¶
Resolve resolves the current (or named) context into a fully populated Context. This dereferences the network and keyring names into their full definitions and populates the convenience fields (GasPrices, GasAdjustment, AuthType, Root).
func (*Manager) UpdateContext ¶
UpdateContext modifies an existing context in-place.
func (*Manager) UpdateContextAndNetwork ¶ added in v0.0.3
func (m *Manager) UpdateContextAndNetwork( name string, forkName string, applyContext func(*Context) error, applyNetwork func(*Network) error, ) error
UpdateContextAndNetwork applies context and optional network changes in one config write. When forkName is non-empty, the selected network is copied, updated, and assigned only to the named context. A failed validation or save leaves both the in-memory manager and config file at their prior state.
func (*Manager) UpdateKeyring ¶ added in v0.0.4
UpdateKeyring mutates an existing keyring definition in place. Without it the only way to change where a context stores its keys after first run was to hand-edit config.yaml (SPEC §2.2.2).
func (*Manager) UpdateNetwork ¶
UpdateNetwork replaces a network definition in-place. All contexts referencing this network see the change.
func (*Manager) UseContext ¶
UseContext switches the active context.
type Network ¶
type Network struct {
Name string `yaml:"name" json:"name"`
ChainID string `yaml:"chain-id" json:"chain_id"`
Endpoints Endpoints `yaml:"endpoints" json:"endpoints"`
GasPrices string `yaml:"gas-prices,omitempty" json:"gas_prices,omitempty"`
GasAdjustment string `yaml:"gas-adjustment,omitempty" json:"gas_adjustment,omitempty"`
Faucet string `yaml:"faucet,omitempty" json:"faucet,omitempty"`
}
Network defines chain connectivity settings. Networks are shared resources -- multiple contexts can reference the same network.
type PluginSettings ¶
type PluginSettings struct {
Paths []string `yaml:"paths,omitempty" json:"paths,omitempty"`
Disabled []string `yaml:"disabled,omitempty" json:"disabled,omitempty"`
}
PluginSettings holds plugin-specific configuration.
type ProviderDefaults ¶
type ProviderDefaults struct {
AuthType string `yaml:"auth-type,omitempty" json:"auth_type,omitempty"`
}
ProviderDefaults holds provider-specific defaults for a context.
type TUISettings ¶
type TUISettings struct {
Theme string `yaml:"theme,omitempty" json:"theme,omitempty"`
Keybindings string `yaml:"keybindings,omitempty" json:"keybindings,omitempty"`
CustomKeybindings map[string]string `yaml:"custom-keybindings,omitempty" json:"custom_keybindings,omitempty"`
RefreshInterval string `yaml:"refresh-interval,omitempty" json:"refresh_interval,omitempty"`
}
TUISettings holds TUI-specific configuration.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors config.yaml for changes and reloads the Manager. Subscribers are notified via callback after each successful reload.
func NewWatcher ¶
NewWatcher creates a filesystem watcher on the config file. It does NOT start watching; call Start() to begin.
func (*Watcher) Start ¶
Start begins watching the config file for writes. It blocks internally in a goroutine; call Stop() to tear down.