Documentation ¶
Overview ¶
package config provides structs for holding, parsing, writing, and working with local configuration data for the command line tool.
Index ¶
- Variables
- func FolderPath() (string, error)
- func Path() (string, error)
- type Cluster
- type Config
- func (c *Config) AddCluster(label models.Label, url *models.URL, authToken string) (*Cluster, error)
- func (c *Config) Cluster() (*Cluster, error)
- func (c *Config) GetCluster(clusterStr string) (*Cluster, error)
- func (c *Config) HasCluster(clusterLabel models.Label) bool
- func (c *Config) Print(w io.Writer) error
- func (c *Config) RemoveCluster(label models.Label) error
- func (c *Config) Use(label models.Label) error
- func (c *Config) Validate() error
- func (c *Config) Write() error
- type Context
- type Session
- type UI
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCluster = errors.New(MissingConfigCause, "Missing cluster configuration; please set via 'cape config clusters use'") ErrMissingHome = errors.New(InvalidEnvCause, "The $HOME environment variable could not be found") ErrUserInfo = errors.New(InvalidEnvCause, "Unable to retrieve info about current user") )
var ( InvalidVersionCause = errors.NewCause(errors.BadRequestCategory, "invalid_version") MissingConfigCause = errors.NewCause(errors.BadRequestCategory, "missing_config") InvalidConfigCause = errors.NewCause(errors.BadRequestCategory, "invalid_config") InvalidEnvCause = errors.NewCause(errors.BadRequestCategory, "invalid_environment") InvalidPermissionsCause = errors.NewCause(errors.BadRequestCategory, "invalid_file_permissions") ExistingClusterCause = errors.NewCause(errors.BadRequestCategory, "cluster_exists") ClusterNotFoundCause = errors.NewCause(errors.NotFoundCategory, "cluster_not_found") )
Functions ¶
func FolderPath ¶
FolderPath returns the path to the local folder that holds user-space wide cape configuration
TODO: Add support for XDG_CONFIG standard which can be found at https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Types ¶
type Cluster ¶
type Cluster struct { AuthToken string `json:"auth_token,omitempty"` URL *models.URL `json:"url"` Label models.Label `json:"label"` CertFile string `json:"tls_cert,omitempty"` Insecure bool `json:"insecure,omitempty"` }
Cluster represents configuration for a Cape cluster
func (*Cluster) SetToken ¶
func (c *Cluster) SetToken(token *base64.Value)
SetToken sets the token on the cluster
func (*Cluster) Transport ¶
func (c *Cluster) Transport() (coordinator.ClientTransport, error)
Transport returns a configured coordinator transport for this cluster. This can be used with a client
type Config ¶
type Config struct { Version int `json:"version"` Context *Context `json:"context,omitempty"` Clusters []*Cluster `json:"clusters,omitempty"` UI *UI `json:"ui"` }
Config represents the configuration settings for the command line
func Parse ¶
Parse reads the given file path and returns a Config object or returns an error as to why the config could not have been read
func (*Config) AddCluster ¶
func (c *Config) AddCluster(label models.Label, url *models.URL, authToken string) (*Cluster, error)
AddCluster attempts to add the cluster to the configuration
func (*Config) Cluster ¶
Cluster returns the current cluster, if no cluster is set, cluster will be n
func (*Config) GetCluster ¶
GetCluster returns the cluster by its label
func (*Config) HasCluster ¶
HasCluster returns true if the provided label exists, false otherwise
func (*Config) RemoveCluster ¶
RemoveCluster attempts to remove the cluster from configuration
func (*Config) Use ¶
Use sets the given label as the current cluster or to unset the current cluster by passing an empty label
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session stores CLI "session" data that overrides data in the config. For example, when a command has the flag --cluster it overrides the value in the config.
func NewSession ¶
NewSession returns a new session