config

package module
v0.0.0-...-84cde26 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// File constants
	DataDir           = ".remotebuild"
	DefaultConfigFile = "config.yaml"

	// Keyring constants
	DefaultKeyring     = "login"
	KeyringServiceName = "RemoteBuild"
)

...

Variables

View Source
var (
	// ErrUnlockingKeyring error if keyring is available but can't be unlocked
	ErrUnlockingKeyring = errors.New("Error unlocking keyring")
)

Functions

func GenMachineID

func GenMachineID() string

GenMachineID detect the machineID. If not detected return random string

func GetDefaultConfigFile

func GetDefaultConfigFile() string

GetDefaultConfigFile return path of default config

func IsTokenValid

func IsTokenValid(token string) bool

IsTokenValid return true if given token is a vaild session token

func IsUnlockError

func IsUnlockError(err error) bool

IsUnlockError return true if err is unlock error

Types

type Config

type Config struct {
	File            string
	MachineID       string
	User            userConfig
	DefaultUploadTo string

	Server serverConfig

	DataManager dataManager
}

Config Configuration structure

func InitConfig

func InitConfig(defaultFile, file string) (*Config, error)

InitConfig inits the configfile

func (*Config) ClearKeyring

func (config *Config) ClearKeyring(username string) error

ClearKeyring removes session from keyring

func (*Config) GetKeyring

func (config *Config) GetKeyring() string

GetKeyring returns the keyring to use

func (*Config) GetMachineID

func (config *Config) GetMachineID() string

GetMachineID returns the machineID

func (*Config) GetNamspace

func (config *Config) GetNamspace(jobType libremotebuild.JobType) string

GetNamspace return namespace to use for a given job

func (*Config) GetToken

func (config *Config) GetToken() (string, error)

GetToken returns user token

func (*Config) InsertUser

func (config *Config) InsertUser(user, token string)

InsertUser insert a new user

func (Config) IsDefault

func (config Config) IsDefault() bool

IsDefault returns true if config is equal to the default config

func (*Config) IsLoggedIn

func (config *Config) IsLoggedIn() bool

IsLoggedIn return true if sessiondata is available

func (Config) MustGetRequestConfig

func (config Config) MustGetRequestConfig() *libremotebuild.RequestConfig

MustGetRequestConfig create a libdm requestconfig from given cli client config and fatal on error

func (*Config) MustSetToken

func (config *Config) MustSetToken(token string)

MustSetToken fatals on error

func (*Config) Save

func (config *Config) Save() error

Save saves the config

func (*Config) SetMachineID

func (config *Config) SetMachineID()

SetMachineID sets machineID if empty

func (*Config) SetToken

func (config *Config) SetToken(token string) error

SetToken sets token for client Tries to save token in a keyring, if not supported save it unencrypted

func (Config) ToRequestConfig

func (config Config) ToRequestConfig() (*libremotebuild.RequestConfig, error)

ToRequestConfig create a libdm requestconfig from given cli client config If token is not set, error has a value and token is equal to an empty string

func (*Config) Validate

func (config *Config) Validate() error

Validate check the config

func (Config) View

func (config Config) View(redactSecrets bool) string

View view config

Jump to

Keyboard shortcuts

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