config

package
v0.0.0-...-ea7380c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Name        string `mapstructure:"name" json:"name" yaml:"name"`
	ClusterSpec `mapstructure:"cluster" json:"cluster" yaml:"cluster"`
}

Cluster is a cluster definition with a name

type ClusterSpec

type ClusterSpec struct {
	CertAuth              string `mapstructure:"certificate-authority" json:"certificate-authority" yaml:"certificate-authority"`
	CertAuthData          string `` /* 139-byte string literal not displayed */
	InsecureSkipTLSVerify bool   `` /* 133-byte string literal not displayed */
	Server                string `mapstructure:"server" json:"server" yaml:"server"`
}

type Config

type Config struct {
	APIVersion     string     `mapstructure:"apiVersion" json:"apiVersion" yaml:"apiVersion"`
	Kind           string     `mapstructure:"kind" json:"kind" yaml:"kind"`
	Contexts       []*Context `mapstructure:"contexts" json:"contexts" yaml:"contexts"`
	Clusters       []*Cluster `mapstructure:"clusters" json:"clusters" yaml:"clusters"`
	CurrentContext string     `mapstructure:"current-context" json:"current-context" yaml:"current-context"`
	Users          []*User    `mapstructure:"users" json:"users" yaml:"users"`
}

Config defines config options

func (*Config) DeleteCluster

func (c *Config) DeleteCluster(name string) error

DeleteCluster will delete the named cluster

func (*Config) DeleteContext

func (c *Config) DeleteContext(name string) error

DeleteContext will delete the named cluster

func (*Config) DeleteUser

func (c *Config) DeleteUser(name string) error

DeleteUser will delete the named cluster

func (*Config) GetClientFromContext

func (cfg *Config) GetClientFromContext(secretsvc secretservice.SecretService, configfile, contextName, namespace string) (*api.Client, error)

GetClientFromContext gets user/cluster/namespace info from context

func (*Config) GetClusterByName

func (c *Config) GetClusterByName(name string) *Cluster

GetClusterByName returns a named cluster

func (*Config) GetContextByName

func (c *Config) GetContextByName(name string) *Context

GetContextByName returns a named cluster

func (*Config) GetDefaultClient

func (cfg *Config) GetDefaultClient(namespace, url, token, cert, key, cacert string) (*api.Client, error)

GetDefaultClient attempt to login ot vault

func (*Config) GetServiceFromContext

func (cfg *Config) GetServiceFromContext(ctx *Context, configfile, namespace string) (secretservice.SecretService, error)

GetServiceFromContext gets user/cluster/namespace info from context

func (*Config) GetSession

func (cfg *Config) GetSession(secretsvc secretservice.SecretService, configfile, contextName string, forceNewSession bool) (*Session, error)

GetSession will return an existing session or create a new one and save the config

func (*Config) GetUserByName

func (c *Config) GetUserByName(name string) *User

GetUserByName returns a named cluster

func (*Config) SaveConfig

func (c *Config) SaveConfig(filename string) error

SaveConfig writes yaml to a file

func (*Config) SetAppRoleUser

func (c *Config) SetAppRoleUser(name string,
	roleID string,
	secretID string,
) (*User, error)

SetAppRoleUser will create a new user or update an existing user

func (*Config) SetCertUser

func (c *Config) SetCertUser(name string,
	clientCert string,
	clientCertData string,
	clientKey string,
	clientKeyData string,
) (*User, error)

SetCertUser will create a new user or update an existing user

func (*Config) SetCluster

func (c *Config) SetCluster(name string,
	certAuth string,
	certAuthData string,
	insecureSkipTLSVerify bool,
	server string,
) (*Cluster, error)

SetCluster returns a new Cluster

func (*Config) SetContext

func (c *Config) SetContext(name string,
	cluster string,
	namespace string,
	session *Session,
	user string) (*Context, error)

SetContext will create a new context or update an existing context

func (*Config) SetSession

func (c *Config) SetSession(token string, duration *int64, renewable *bool, expireSkewFactor int64) *Session

SetSession Builds a session object expireSkewFactor in seconds

func (*Config) SetUserPassUser

func (c *Config) SetUserPassUser(name string,
	username string,
	password string,
) (*User, error)

SetUserPassUser will create a new user or update an existing user

func (*Config) StopSession

func (cfg *Config) StopSession(configfile, contextName string) error

StopSession will return an existing session or create a new one and save the config

func (*Config) String

func (c *Config) String() string

type Context

type Context struct {
	Name        string `mapstructure:"name" json:"name" yaml:"name"`
	ContextSpec `mapstructure:"context" json:"context" yaml:"context"`
}

Context a context with a name +k8s:deepcopy-gen=true

type ContextSpec

type ContextSpec struct {
	Cluster       string `mapstructure:"cluster" json:"cluster" yaml:"cluster"`
	InventoryPath string `mapstructure:"inventoryPath" json:"inventoryPath" yaml:"inventoryPath"`
	Namespace     string `mapstructure:"namespace" json:"namespace" yaml:"namespace"`
	Session       `mapstructure:"session,omitempty" json:"session,omitempty" yaml:"session,omitempty"`
	User          string `mapstructure:"user" json:"user" yaml:"user"`
}

ContextSpec consist of a user paired with a cluster, namespace

type Session

type Session struct {
	Token         string `mapstructure:"token,omitempty" json:"token,omitempty" yaml:"token,omitempty"`
	LeaseDuration *int64 `mapstructure:"lease-duration,omitempty" json:"lease-duration,omitempty" yaml:"lease-duration,omitempty"`
	Expires       *int64 `mapstructure:"expires,omitempty" json:"expires,omitempty" yaml:"expires,omitempty"`
	Renewable     *bool  `mapstructure:"renewable,omitempty" json:"renewable,omitempty" yaml:"renewable,omitempty"`
}

Session is a Token and its metadata

type User

type User struct {
	Name     string `mapstructure:"name" json:"name" yaml:"name"`
	UserSpec `mapstructure:"user" json:"user" yaml:"user"`
}

User is a user with a name

type UserSpec

type UserSpec struct {
	ClientCert            string `mapstructure:"client-certificate" json:"client-certificate" yaml:"client-certificate"`
	ClientCertData        string `` /* 130-byte string literal not displayed */
	ClientKey             string `mapstructure:"client-key" json:"client-key" yaml:"client-key"`
	ClientKeyData         string `mapstructure:"client-key-data,omitempty" json:"client-key-data,omitempty" yaml:"client-key-data,omitempty"`
	Password              string `mapstructure:"password" json:"password" yaml:"password"`
	Username              string `mapstructure:"username" json:"username" yaml:"username"`
	RoleID                string `mapstructure:"roleID" json:"roleID" yaml:"roleID"`
	SecretID              string `mapstructure:"secretID" json:"secretID" yaml:"secretID"`
	IgnoreNamespaceOnAuth bool   `mapstructure:"ignore-namespace-on-auth" json:"ignore-namespace-on-auth" yaml:"ignore-namespace-on-auth"`
}

UserSpec a user with credentials

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL