config

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCurrentContext = "default"
	DefaultServer         = "https://localhost"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Auth        string
	Name        string `json:"cluster_name"`
	Context     string
	CountryCode int    `json:"country_code,int" validate:"required"`
	Number      int    `json:"number,int" validate:"required"`
	Server      string `json:"server" validate:"required"`
	Username    string `json:"username" validate:"required"`
	Insecure    bool
}

Cluster holds the basic information of the connected cluster Auth is authentication generated after login Server is the base url of the account Name (optional) is the name of the cluster CountryCode is the officially assigned code Number is the phone number of the cluster VerifySSL will define if ssl needs to be verified during the api call, defaults to true

type Configuration

type Configuration struct {
	Clusters       []Cluster `mapstructure:"clusters" json:"clusters"`
	CurrentContext string    `mapstructure:"current_context" json:"current_context"`
	CurrentCluster Cluster   `mapstructure:"current_cluster" json:"current_cluster"`
	Version        string    `mapstructure:"version" json:"version"`
}

Configuration defines the basic structure of config file Config can be provided in json, yaml or from environment

func GetConfig

func GetConfig() (c *Configuration, err error)

TODO add auth expiry time to config New provides a singleton for creating the configuration Once handles the cases where multiple routines are trying to initialize the config file

func (*Configuration) AddCluster

func (c *Configuration) AddCluster(cluster Cluster) error

UpdateConfig will update the config file to latest after addition or removal of an account from the cluster

func (*Configuration) MatchAcc

func (c *Configuration) MatchAcc(acc string) (int, []string)

func (*Configuration) RemoveCluster

func (c *Configuration) RemoveCluster(context string) error

func (*Configuration) SetVersion added in v0.0.16

func (c *Configuration) SetVersion(version string)

func (*Configuration) UpdateContext

func (c *Configuration) UpdateContext(context string) error

Jump to

Keyboard shortcuts

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