Documentation ¶
Index ¶
Constants ¶
const ( // RecommendedHomeDir is the default name for the osprey home directory. RecommendedHomeDir = ".osprey" // RecommendedFileName is the default name for the osprey config file. RecommendedFileName = "config" )
Variables ¶
var ( // HomeDir is the user's home directory. HomeDir = homeDir() // RecommendedOspreyHomeDir is the default full path for the osprey home. RecommendedOspreyHomeDir = path.Join(HomeDir, RecommendedHomeDir) // RecommendedOspreyConfigFile is the default full path for the osprey config file. RecommendedOspreyConfigFile = path.Join(RecommendedOspreyHomeDir, RecommendedFileName) )
Functions ¶
func SaveConfig ¶
SaveConfig serializes the osprey config to the specified path.
Types ¶
type Client ¶
type Client interface { // GetAccessToken returns an access token that is required to authenticate user access against a kubernetes cluster GetAccessToken(*LoginCredentials) (*kubeconfig.TokenInfo, error) }
Client is used to authenticate and generate the configuration
type Config ¶
type Config struct { // CertificateAuthority is the path to a cert file for the certificate authority. // +optional CertificateAuthority string `yaml:"certificate-authority,omitempty"` // CertificateAuthorityData is base64-encoded CA cert data. // This will override any cert file specified in CertificateAuthority. // +optional CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"` // Kubeconfig specifies the path to read/write the kubeconfig file. // +optional Kubeconfig string `yaml:"kubeconfig,omitempty"` // DefaultGroup specifies the group to log in to if none provided. // +optional DefaultGroup string `yaml:"default-group,omitempty"` // Targets is a map of referenceable names to osprey configs Targets map[string]*Osprey `yaml:"targets"` }
Config holds the information needed to connect to remote osprey servers as a given user
func LoadConfig ¶
LoadConfig reads an osprey Config from the specified path.
func NewConfig ¶
func NewConfig() *Config
NewConfig is a convenience function that returns a new Config object with non-nil maps
func (*Config) GroupOrDefault ¶ added in v1.2.0
GroupOrDefault returns the group if it is not empty, or the Config.DefaultGroup if it is.
func (*Config) TargetsByGroup ¶ added in v1.2.0
TargetsByGroup returns the Config targets organized by groups. One target may appear in multiple groups.
type ConfigSnapshot ¶ added in v1.2.0
type ConfigSnapshot struct {
// contains filtered or unexported fields
}
ConfigSnapshot is a snapshot view of the configuration to organize the targets per group. It does not reflect changes to the configuration after it has been taken.
func GetSnapshot ¶ added in v1.2.0
func GetSnapshot(config *Config) ConfigSnapshot
GetSnapshot creates a snapshot view of the provided Config
func (*ConfigSnapshot) DefaultGroup ¶ added in v1.2.0
func (t *ConfigSnapshot) DefaultGroup() Group
DefaultGroup returns the default group in the configuration. If no specific group is set as default, it will return the special ungrouped ("") group
func (*ConfigSnapshot) GetGroup ¶ added in v1.2.0
func (t *ConfigSnapshot) GetGroup(name string) (Group, bool)
GetGroup returns a valid group and true if it exists, an empty group and false if it doesn't.
func (*ConfigSnapshot) Groups ¶ added in v1.2.0
func (t *ConfigSnapshot) Groups() []Group
Groups returns all defined groups sorted alphabetically by name.
func (*ConfigSnapshot) HaveGroups ¶ added in v1.2.0
func (t *ConfigSnapshot) HaveGroups() bool
HaveGroups returns true if there is at least one defined group.
func (*ConfigSnapshot) Targets ¶ added in v1.2.0
func (t *ConfigSnapshot) Targets() []Target
Targets returns all the targets in the configuration in alphabetical order.
type Group ¶ added in v1.2.0
type Group struct {
// contains filtered or unexported fields
}
Group organizes the osprey targets
func (*Group) IsDefault ¶ added in v1.2.0
IsDefault returns true if this is the default group in the configuration
type LoginCredentials ¶
type LoginCredentials struct { // Username username of user intending to login Username string // Password the password for user Password string }
LoginCredentials represents user credentials
func GetCredentials ¶
func GetCredentials() (*LoginCredentials, error)
GetCredentials loads the credentials from the terminal or stdin.
type Osprey ¶
type Osprey struct { // Server is the address of the osprey server (hostname:port). Server string `yaml:"server"` // CertificateAuthority is the path to a cert file for the certificate authority. // +optional CertificateAuthority string `yaml:"certificate-authority,omitempty"` // CertificateAuthorityData is base64-encoded CA cert data. // This will override any cert file specified in CertificateAuthority. // +optional CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"` // Aliases is a list of names that the osprey server can be called. // +optional Aliases []string `yaml:"aliases,omitempty"` // Groups is a list of names that can be used to group different osprey servers. // +optional Groups []string `yaml:"groups,omitempty"` }
Osprey contains information about how to communicate with an osprey server
type Target ¶ added in v1.2.0
type Target struct {
// contains filtered or unexported fields
}
Target has the information of an Osprey target server
func (*Target) Aliases ¶ added in v1.2.0
Aliases returns the list of aliases of the Target alphabetically sorted
func (*Target) CertificateAuthorityData ¶ added in v1.2.0
CertificateAuthorityData returns the CertificateAuthorityData of the Target
func (*Target) HasAliases ¶ added in v1.2.0
HasAliases returns true if the Target has at least one alias