Documentation
¶
Index ¶
- Constants
- Variables
- func AuthenticateWithKey(ctx context.Context, hostname string, keyPair *cloudauth.KeyPair) (string, error)
- func GetActiveConfigPath() string
- func GetConfigDirPath() string
- type BeginAuthRequest
- type BeginAuthResponse
- type ClusterConfig
- func (c *ClusterConfig) RPCOptions(ctx context.Context, config *Config) ([]rpc.StateOption, error)
- func (c *ClusterConfig) RPCOptionsWithName(ctx context.Context, config *Config, clusterName string) ([]rpc.StateOption, error)
- func (c *ClusterConfig) State(ctx context.Context, config *Config, opts ...rpc.StateOption) (*rpc.State, error)
- type CompleteAuthRequest
- type CompleteAuthResponse
- type Config
- func (c *Config) ActiveCluster() string
- func (c *Config) GetActiveCluster() (*ClusterConfig, error)
- func (c *Config) GetCluster(name string) (*ClusterConfig, error)
- func (c *Config) GetClusterCount() int
- func (c *Config) GetClusterNames() []string
- func (c *Config) GetIdentity(name string) (*IdentityConfig, error)
- func (c *Config) GetIdentityCount() int
- func (c *Config) GetIdentityNames() []string
- func (c *Config) GetKey(name string) (*KeyConfig, error)
- func (c *Config) GetKeyNames() []string
- func (c *Config) GetLeafConfigNames() []string
- func (c *Config) GetPrivateKeyPEM(identity *IdentityConfig) (string, error)
- func (c *Config) HasAnyClusters() bool
- func (c *Config) HasCluster(name string) bool
- func (c *Config) HasIdentities() bool
- func (c *Config) HasIdentity(name string) bool
- func (c *Config) HasKey(name string) bool
- func (c *Config) IsEmpty() bool
- func (c *Config) IterateClusters(fn func(name string, cluster *ClusterConfig) error) error
- func (c *Config) MarshalYAML() (interface{}, error)
- func (c *Config) RPCOptions(ctx context.Context) ([]rpc.StateOption, error)
- func (c *Config) RemoveCluster(name string) error
- func (c *Config) Save() error
- func (c *Config) SaveTo(path string) error
- func (c *Config) SaveToHome() error
- func (c *Config) SetActiveCluster(name string) error
- func (c *Config) SetCluster(name string, cluster *ClusterConfig)
- func (c *Config) SetIdentity(name string, identity *IdentityConfig)
- func (c *Config) SetKey(name string, key *KeyConfig)
- func (c *Config) SetLeafConfig(name string, configData *ConfigData)
- func (c *Config) SourcePath() string
- func (c *Config) State(ctx context.Context, opts ...rpc.StateOption) (*rpc.State, error)
- func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (c *Config) Validate() error
- type ConfigData
- type IdentityConfig
- type KeyConfig
Constants ¶
const ( // DefaultConfigPath is the default path for the config file in user's home directory DefaultConfigPath = ".config/miren/clientconfig.yaml" // EnvConfigPath is the environment variable name for custom config path EnvConfigPath = "MIREN_CONFIG" )
Variables ¶
var ErrNoConfig = fmt.Errorf("no config file found")
Functions ¶
func AuthenticateWithKey ¶
func AuthenticateWithKey(ctx context.Context, hostname string, keyPair *cloudauth.KeyPair) (string, error)
AuthenticateWithKey performs the challenge-response authentication flow
func GetActiveConfigPath ¶
func GetActiveConfigPath() string
GetActiveConfigPath returns the path to the active configuration file
func GetConfigDirPath ¶
func GetConfigDirPath() string
GetConfigDirPath returns the path to the configuration directory
Types ¶
type BeginAuthRequest ¶
type BeginAuthRequest struct {
Fingerprint string `json:"fingerprint"`
}
BeginAuthRequest is the request to begin authentication
type BeginAuthResponse ¶
type BeginAuthResponse struct {
Envelope string `json:"envelope"`
Challenge string `json:"challenge"`
}
BeginAuthResponse is the response from begin authentication
type ClusterConfig ¶
type ClusterConfig struct {
Hostname string `yaml:"hostname"`
AllAddresses []string `yaml:"all_addresses,omitempty"` // All available addresses for this cluster
Identity string `yaml:"identity,omitempty"` // Reference to an identity in the Identities section
CACert string `yaml:"ca_cert,omitempty"` // PEM encoded CA certificate
ClientCert string `yaml:"client_cert,omitempty"` // PEM encoded client certificate (deprecated, use identity)
ClientKey string `yaml:"client_key,omitempty"` // PEM encoded client key (deprecated, use identity)
Insecure bool `yaml:"insecure,omitempty"` // Skip TLS verification
CloudAuth bool `yaml:"cloud_auth,omitempty"` // Use cloud authentication (deprecated, use identity)
}
ClusterConfig holds the configuration for a single cluster
func (*ClusterConfig) RPCOptions ¶
func (c *ClusterConfig) RPCOptions(ctx context.Context, config *Config) ([]rpc.StateOption, error)
RPCOptions returns RPC options without a cluster name (deprecated, use RPCOptionsWithName)
func (*ClusterConfig) RPCOptionsWithName ¶
func (c *ClusterConfig) RPCOptionsWithName(ctx context.Context, config *Config, clusterName string) ([]rpc.StateOption, error)
RPCOptionsWithName returns RPC options with cluster name for caching
type CompleteAuthRequest ¶
type CompleteAuthRequest struct {
Envelope string `json:"envelope"`
Signature string `json:"signature"`
}
CompleteAuthRequest is the request to complete authentication
type CompleteAuthResponse ¶
type CompleteAuthResponse struct {
User interface{} `json:"user"`
Token string `json:"token"`
}
CompleteAuthResponse is the response from complete authentication
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the complete client configuration
func DecodeConfig ¶
LoadConfig loads the configuration from disk
func LoadConfigFrom ¶
LoadConfig loads the configuration from disk
func (*Config) ActiveCluster ¶
ActiveCluster returns the name of the active cluster
func (*Config) GetActiveCluster ¶
func (c *Config) GetActiveCluster() (*ClusterConfig, error)
GetActiveCluster returns the active cluster configuration
func (*Config) GetCluster ¶
func (c *Config) GetCluster(name string) (*ClusterConfig, error)
GetCluster returns the configuration for a specific cluster
func (*Config) GetClusterCount ¶
GetClusterCount returns the number of clusters in the configuration
func (*Config) GetClusterNames ¶
GetClusterNames returns a sorted list of all cluster names
func (*Config) GetIdentity ¶
func (c *Config) GetIdentity(name string) (*IdentityConfig, error)
GetIdentity returns an identity configuration by name
func (*Config) GetIdentityCount ¶
GetIdentityCount returns the number of configured identities
func (*Config) GetIdentityNames ¶
GetIdentityNames returns a sorted list of all identity names
func (*Config) GetKeyNames ¶
GetKeyNames returns a sorted list of all key names
func (*Config) GetLeafConfigNames ¶
GetLeafConfigNames returns the names of all leaf configs
func (*Config) GetPrivateKeyPEM ¶
func (c *Config) GetPrivateKeyPEM(identity *IdentityConfig) (string, error)
GetPrivateKeyPEM resolves and returns the private key PEM for an identity. It handles both direct PrivateKey fields and KeyRef references.
func (*Config) HasAnyClusters ¶
HasAnyClusters checks if any clusters are configured
func (*Config) HasCluster ¶
HasCluster checks if a cluster exists in the configuration
func (*Config) HasIdentities ¶
HasIdentities returns true if there are any identities configured
func (*Config) HasIdentity ¶
HasIdentity checks if an identity exists in the configuration
func (*Config) IterateClusters ¶
func (c *Config) IterateClusters(fn func(name string, cluster *ClusterConfig) error) error
IterateClusters calls the provided function for each cluster in sorted order If the function returns an error, iteration stops and the error is returned
func (*Config) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface
func (*Config) RPCOptions ¶
func (*Config) RemoveCluster ¶
RemoveCluster removes a cluster from the configuration
func (*Config) SaveToHome ¶
func (*Config) SetActiveCluster ¶
SetActiveCluster sets the active cluster
func (*Config) SetCluster ¶
func (c *Config) SetCluster(name string, cluster *ClusterConfig)
SetCluster adds or updates a cluster in the configuration
func (*Config) SetIdentity ¶
func (c *Config) SetIdentity(name string, identity *IdentityConfig)
SetIdentity adds or updates an identity configuration
func (*Config) SetLeafConfig ¶
func (c *Config) SetLeafConfig(name string, configData *ConfigData)
SetLeafConfig adds or updates a leaf config that will be saved to clientconfig.d/name.yaml
func (*Config) SourcePath ¶
SourcePath returns the path to the config file that was loaded, if any.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface
type ConfigData ¶
type ConfigData struct {
Active string `yaml:"active_cluster,omitempty"`
Clusters map[string]*ClusterConfig `yaml:"clusters,omitempty"`
Identities map[string]*IdentityConfig `yaml:"identities,omitempty"`
Keys map[string]*KeyConfig `yaml:"keys,omitempty"`
}
ConfigData is used for YAML unmarshaling to handle private fields
type IdentityConfig ¶
type IdentityConfig struct {
Type string `yaml:"type"` // Type of identity: "keypair", "certificate", etc.
Issuer string `yaml:"issuer,omitempty"` // The auth server that issued this identity (e.g., "https://miren.cloud")
KeyRef string `yaml:"key_ref,omitempty"` // Reference to a key in the Keys section (for keypair auth)
PrivateKey string `yaml:"private_key,omitempty"` // PEM encoded private key (for keypair auth, deprecated - use KeyRef)
ClientCert string `yaml:"client_cert,omitempty"` // PEM encoded client certificate (for cert auth)
ClientKey string `yaml:"client_key,omitempty"` // PEM encoded client key (for cert auth)
}
IdentityConfig holds authentication credentials that can be used across clusters
type KeyConfig ¶
type KeyConfig struct {
Name string `yaml:"name"` // Name of the key (e.g., "miren-cli@hostname")
Type string `yaml:"type"` // Type of key: "ed25519", etc.
PrivateKey string `yaml:"private_key"` // PEM encoded private key
Fingerprint string `yaml:"fingerprint,omitempty"` // Fingerprint of the public key
Metadata map[string]string `yaml:"metadata,omitempty"` // Arbitrary metadata about the key
}
KeyConfig holds a reusable cryptographic key