common

package
v0.4.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	StateFile          = ".state"
	KubeCfgFile        = ".kube/config"
	KubeCfgTempName    = "autok3s-temp"
	K3sManifestsDir    = "/var/lib/rancher/k3s/server/manifests"
	MasterInstanceName = "autok3s.%s.master"
	WorkerInstanceName = "autok3s.%s.worker"
	TagClusterPrefix   = "autok3s-"
	StatusRunning      = "Running"
	StatusCreating     = "Creating"
	StatusMissing      = "Missing"
	StatusFailed       = "Failed"
	StatusUpgrading    = "Upgrading"
	UsageInfoTitle     = "=========================== Prompt Info ==========================="
	UsageContext       = "Use 'autok3s kubectl config use-context %s'"
	UsagePods          = "Use 'autok3s kubectl get pods -A' get POD status`"
	DBFolder           = ".db"
	DBFile             = "autok3s.db"
)

Variables

View Source
var (
	Debug   = false
	CfgPath = utils.UserHome() + "/.autok3s"
	Backoff = wait.Backoff{
		Duration: 30 * time.Second,
		Factor:   1,
		Steps:    5,
	} // retry 5 times, total 120 seconds.
	DefaultDB *Store
)

Functions

func GetClusterPath added in v0.3.0

func GetClusterPath(clusterName, providerName string) string

func GetDB added in v0.4.0

func GetDB() (*gorm.DB, error)

func GetDataSource added in v0.4.0

func GetDataSource() string

func GetDefaultSSHKeyPath added in v0.3.0

func GetDefaultSSHKeyPath(clusterName, providerName string) string

func GetLogFile added in v0.4.0

func GetLogFile(name string) (logFile *os.File, err error)

func GetLogPath added in v0.4.0

func GetLogPath() string

func InitStorage added in v0.4.0

func InitStorage() error

func NewLogger

func NewLogger(debug bool, w *os.File) *logrus.Logger

Types

type Broadcaster added in v0.4.0

type Broadcaster struct {
	// contains filtered or unexported fields
}

Broadcaster sends events to multiple subscribers

func NewBroadcaster added in v0.4.0

func NewBroadcaster() *Broadcaster

func (*Broadcaster) Broadcast added in v0.4.0

func (b *Broadcaster) Broadcast(v interface{})

Broadcast events to each subscriber

func (*Broadcaster) Close added in v0.4.0

func (b *Broadcaster) Close()

Close all subscribers

func (*Broadcaster) Evict added in v0.4.0

func (b *Broadcaster) Evict(s Subscriber)

Evict specified subscriber

func (*Broadcaster) Register added in v0.4.0

func (b *Broadcaster) Register(sf subscriberFunc) Subscriber

Register helps init subscriber with specified subscribe function

type ClusterState added in v0.4.0

type ClusterState struct {
	types.Metadata `json:",inline" mapstructure:",squash" gorm:"embedded"`
	Options        []byte `json:"options,omitempty" gorm:"type:bytes"`
	Status         string `json:"status" yaml:"status"`
	MasterNodes    []byte `json:"master-nodes,omitempty" gorm:"type:bytes"`
	WorkerNodes    []byte `json:"worker-nodes,omitempty" gorm:"type:bytes"`
	types.SSH      `json:",inline" mapstructure:",squash" gorm:"embedded"`
}

type Credential added in v0.4.0

type Credential struct {
	ID       int    `json:"id" gorm:"type:integer"`
	Provider string `json:"provider"`
	Secrets  []byte `json:"secrets,omitempty" gorm:"type:bytes"`
}

type Store added in v0.4.0

type Store struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func NewClusterDB added in v0.4.0

func NewClusterDB(ctx context.Context) (*Store, error)

func (*Store) CreateCredential added in v0.4.0

func (d *Store) CreateCredential(cred *Credential) error

func (*Store) CreateTemplate added in v0.4.0

func (d *Store) CreateTemplate(template *Template) error

func (*Store) DeleteCluster added in v0.4.0

func (d *Store) DeleteCluster(name, provider string) error

func (*Store) DeleteCredential added in v0.4.0

func (d *Store) DeleteCredential(id int) error

func (*Store) DeleteTemplate added in v0.4.0

func (d *Store) DeleteTemplate(name, provider string) error

func (*Store) FindCluster added in v0.4.0

func (d *Store) FindCluster(name, provider string) ([]*ClusterState, error)

func (*Store) GetCluster added in v0.4.0

func (d *Store) GetCluster(name, provider string) (*ClusterState, error)

func (*Store) GetClusterByID added in v0.4.0

func (d *Store) GetClusterByID(contextName string) (*ClusterState, error)

func (*Store) GetCredential added in v0.4.0

func (d *Store) GetCredential(id int) (*Credential, error)

func (*Store) GetCredentialByProvider added in v0.4.0

func (d *Store) GetCredentialByProvider(provider string) ([]*Credential, error)

func (*Store) GetTemplate added in v0.4.0

func (d *Store) GetTemplate(name, provider string) (*Template, error)

func (*Store) ListCluster added in v0.4.0

func (d *Store) ListCluster() ([]*ClusterState, error)

func (*Store) ListCredential added in v0.4.0

func (d *Store) ListCredential() ([]*Credential, error)

func (*Store) ListTemplates added in v0.4.0

func (d *Store) ListTemplates() ([]*Template, error)

func (*Store) Log added in v0.4.0

func (d *Store) Log(apiOp *apitypes.APIRequest, input chan *ClusterState)

func (*Store) Register added in v0.4.0

func (d *Store) Register()

func (*Store) SaveCluster added in v0.4.0

func (d *Store) SaveCluster(cluster *types.Cluster) error

func (*Store) SaveClusterState added in v0.4.0

func (d *Store) SaveClusterState(state *ClusterState) error

func (*Store) UpdateCredential added in v0.4.0

func (d *Store) UpdateCredential(cred *Credential) error

func (*Store) UpdateTemplate added in v0.4.0

func (d *Store) UpdateTemplate(template *Template) error

func (*Store) WatchCluster added in v0.4.0

func (d *Store) WatchCluster(apiOp *apitypes.APIRequest, schema *apitypes.APISchema, input chan apitypes.APIEvent)

func (*Store) WatchTemplate added in v0.4.0

func (d *Store) WatchTemplate(apiOp *apitypes.APIRequest, schema *apitypes.APISchema, input chan apitypes.APIEvent)

type Subscriber added in v0.4.0

type Subscriber chan interface{}

type Template added in v0.4.0

type Template struct {
	types.Metadata `json:",inline" mapstructure:",squash" gorm:"embedded"`
	Options        []byte `json:"options,omitempty" gorm:"type:bytes"`
	types.SSH      `json:",inline" mapstructure:",squash" gorm:"embedded"`
	IsDefault      bool `json:"is-default" gorm:"type:bool"`
}

Jump to

Keyboard shortcuts

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