Documentation
¶
Overview ¶
Package config resolves the CLI connection context from flags, env and ~/.miabi/config.yaml, in that order.
Index ¶
- func Path() string
- func Save(f *File) error
- type AppRef
- type Context
- type Effective
- type File
- func (f *File) ContextNames() []string
- func (f *File) CurrentContext() *Context
- func (f *File) EnsureContext(name string) *Context
- func (f *File) EnsureCurrent() *Context
- func (f *File) EnsureSelected(flag string) *Context
- func (f *File) Selected(flag string) *Context
- func (f *File) SelectedName(flag string) string
- type Flags
- type Identity
- type Server
- type WorkspaceRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppRef ¶ added in v0.10.0
type AppRef struct {
ID uint `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
DisplayName string `yaml:"display_name,omitempty" json:"display_name,omitempty"`
}
AppRef is the app bound by `miabi use`; it is cleared whenever the workspace changes.
type Context ¶ added in v0.10.0
type Context struct {
Server Server `yaml:"server,omitempty"`
Token string `yaml:"token,omitempty"`
User *Identity `yaml:"user,omitempty"`
Workspace *WorkspaceRef `yaml:"workspace,omitempty"`
App *AppRef `yaml:"app,omitempty"`
}
Context is one named connection profile (server, token, bound workspace/app).
func (Context) MarshalYAML ¶ added in v0.10.0
MarshalYAML base64-encodes the token: obfuscation only, not encryption.
type Effective ¶
type Effective struct {
Context string // "" when no context applies
URL string
Token string
CA string
InsecureSkip bool
Workspace *WorkspaceRef
App *AppRef
}
Effective is the resolved context a command runs against.
type File ¶
type File struct {
Current string `yaml:"current,omitempty"`
Contexts map[string]*Context `yaml:"contexts,omitempty"`
// Legacy single-context fields, migrated on Load and cleared so Save never re-emits them.
LegacyServer *Server `yaml:"server,omitempty"`
LegacyToken string `yaml:"token,omitempty"`
LegacyUser *Identity `yaml:"user,omitempty"`
LegacyWorkspace *WorkspaceRef `yaml:"workspace,omitempty"`
LegacyApp *AppRef `yaml:"app,omitempty"`
LegacyURL string `yaml:"url,omitempty"`
}
File mirrors ~/.miabi/config.yaml: a set of named contexts and the active one.
func (*File) ContextNames ¶ added in v0.10.0
ContextNames returns the context names sorted, for listing.
func (*File) CurrentContext ¶ added in v0.10.0
CurrentContext returns the active context, or nil when none is set.
func (*File) EnsureContext ¶ added in v0.10.0
EnsureContext returns the named context, creating it if absent, and makes it current.
func (*File) EnsureCurrent ¶ added in v0.10.0
EnsureCurrent creates a "default" context when none is set, so binding works before login.
func (*File) EnsureSelected ¶ added in v0.21.0
EnsureSelected is EnsureCurrent for the selected context; it never changes `current`.
func (*File) Selected ¶ added in v0.21.0
Selected returns the selected context, or nil when none is set or it is unknown.
func (*File) SelectedName ¶ added in v0.21.0
SelectedName picks --context, else MIABI_CONTEXT, else the file's current context.
type Flags ¶ added in v0.10.0
type Flags struct {
Context string
Server string // --server or the deprecated --url
Token string
CA string
InsecureSkip bool
}
Flags carries the parsed connection flags, which take precedence over env and context.
type Identity ¶ added in v0.10.0
type Identity struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Username string `yaml:"username,omitempty" json:"username,omitempty"`
Email string `yaml:"email,omitempty" json:"email,omitempty"`
}
Identity is captured at login for offline display only; the token remains the source of truth.
type Server ¶ added in v0.10.0
type Server struct {
URL string `yaml:"url,omitempty"`
// CA is a PEM bundle trusted in addition to the system roots.
CA string `yaml:"ca,omitempty"`
// InsecureSkip disables TLS verification entirely; never use it against a public server.
InsecureSkip bool `yaml:"insecure_skip,omitempty"`
}
Server describes how to reach and trust one Miabi control plane.
type WorkspaceRef ¶
type WorkspaceRef struct {
ID uint `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
DisplayName string `yaml:"display_name,omitempty" json:"display_name,omitempty"`
}
WorkspaceRef is the active workspace persisted by `miabi workspace switch`; ID is the durable key.