Documentation ¶
Index ¶
- Constants
- Variables
- type AuthInformation
- type ClientConfigManager
- func (l *ClientConfigManager) GetConfig() *Config
- func (l *ClientConfigManager) GetConfigLocation() string
- func (l *ClientConfigManager) InitConfig(config *Config, force bool) error
- func (l *ClientConfigManager) LoadConfig() error
- func (*ClientConfigManager) LoadFromBytes(data []byte) (*Config, error)
- func (l *ClientConfigManager) LoadFromFile(filename string) (*Config, error)
- func (l *ClientConfigManager) SaveConfig() error
- func (l *ClientConfigManager) SaveToFile(config *Config, filename string, permission os.FileMode) error
- type Config
- func (c *Config) GetClusterAuthInformation(clusterId, username, role string) *AuthInformation
- func (c *Config) HasAuthInformation() bool
- func (c *Config) LoadToken()
- func (c *Config) SetClusterAuthInformation(clusterId, username, role, token string, expiry time.Time)
- func (c *Config) StoreToken() error
- func (c *Config) String() (string, error)
- func (c *Config) Validate() error
Constants ¶
const ( RecommendedConfigPathEnvVar = "MONOSKOPECONFIG" RecommendedHomeDir = ".monoskope" RecommendedFileName = "config" FileMode = 0644 )
Variables ¶
var ( ErrEmptyServer = errors.New("has no server defined") ErrNoConfigExists = errors.New("no valid monoconfig found") ErrAlreadyInitialized = errors.New("a configuration already exists") )
var ( RecommendedConfigDir = path.Join(util.HomeDir(), RecommendedHomeDir) RecommendedHomeFile = path.Join(RecommendedConfigDir, RecommendedFileName) )
Functions ¶
This section is empty.
Types ¶
type AuthInformation ¶
type AuthInformation struct { Username string `yaml:"username,omitempty"` Token string `yaml:"-"` Expiry time.Time `yaml:"expiry,omitempty"` }
func (*AuthInformation) HasToken ¶
func (a *AuthInformation) HasToken() bool
HasToken checks that Token is not empty
func (*AuthInformation) IsTokenExpired ¶
func (a *AuthInformation) IsTokenExpired() bool
IsTokenExpired checks if the auth token is expired with an offset
func (*AuthInformation) IsTokenExpiredExact ¶
func (a *AuthInformation) IsTokenExpiredExact() bool
IsTokenExpiredExact checks if the auth token is expired
func (*AuthInformation) IsValid ¶
func (a *AuthInformation) IsValid() bool
IsValid checks that Token is not empty and is not expired with an offset
func (*AuthInformation) IsValidExact ¶
func (a *AuthInformation) IsValidExact() bool
IsValidExact checks that Token is not empty and is not expired
type ClientConfigManager ¶
type ClientConfigManager struct {
// contains filtered or unexported fields
}
func NewLoader ¶
func NewLoader() *ClientConfigManager
NewLoader is a convenience function that returns a new ClientConfigManager object with defaults
func NewLoaderFromConfig ¶
func NewLoaderFromConfig(conf *Config) *ClientConfigManager
NewLoaderFromConfig is mainly intended to be used for tests. It allows setting the config without the need of an external file.
func NewLoaderFromExplicitFile ¶
func NewLoaderFromExplicitFile(explicitFile string) *ClientConfigManager
NewLoaderFromExplicitFile is a convenience function that returns a new ClientConfigManager object with explicitFile set
func (*ClientConfigManager) GetConfig ¶
func (l *ClientConfigManager) GetConfig() *Config
GetConfig returns the previously loaded config
func (*ClientConfigManager) GetConfigLocation ¶
func (l *ClientConfigManager) GetConfigLocation() string
GetConfigLocation returns the location of the previously loaded config
func (*ClientConfigManager) InitConfig ¶
func (l *ClientConfigManager) InitConfig(config *Config, force bool) error
func (*ClientConfigManager) LoadConfig ¶
func (l *ClientConfigManager) LoadConfig() error
LoadConfig loads the config either from env or home file.
func (*ClientConfigManager) LoadFromBytes ¶
func (*ClientConfigManager) LoadFromBytes(data []byte) (*Config, error)
LoadFromBytes takes a byte slice and deserializes the contents into Config object. Encapsulates deserialization without assuming the source is a file.
func (*ClientConfigManager) LoadFromFile ¶
func (l *ClientConfigManager) LoadFromFile(filename string) (*Config, error)
LoadFromFile takes a filename and deserializes the contents into Config object
func (*ClientConfigManager) SaveConfig ¶
func (l *ClientConfigManager) SaveConfig() error
func (*ClientConfigManager) SaveToFile ¶
func (l *ClientConfigManager) SaveToFile(config *Config, filename string, permission os.FileMode) error
SaveToFile takes a config, serializes the contents and stores them into a file.
type Config ¶
type Config struct { // Server is the address of the Monoskope Gateway (https://hostname:port). Server string `yaml:"server"` // KubeConfigPath is the filepath, where m8 will write its kubeConfig KubeConfigPath string `yaml:"KubeConfigPath"` // AuthInformation contains information to authenticate against Monoskope AuthInformation *AuthInformation `yaml:"authInformation,omitempty"` // ClusterAuthInformation contains information to authenticate against K8s clusters ClusterAuthInformation map[string]*AuthInformation `yaml:"clusterAuthInformation,omitempty"` }
Config holds the information needed to build connect to remote monoskope instance as a given user
func NewConfig ¶
func NewConfig() *Config
NewConfig is a convenience function that returns a new Config object with defaults
func (*Config) GetClusterAuthInformation ¶
func (c *Config) GetClusterAuthInformation(clusterId, username, role string) *AuthInformation
func (*Config) HasAuthInformation ¶
HasAuthInformation checks if the the config contains AuthInformation