config

package module
v0.0.0-...-cb6fb96 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: GPL-3.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

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

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

...

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

	Server  serverConfig
	Client  clientConfig
	Default defaultConfig
}

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) GetDefaultOrder

func (config *Config) GetDefaultOrder() string

GetDefaultOrder returns the default order. If empty returns the default order

func (*Config) GetKeyring

func (config *Config) GetKeyring() string

GetKeyring returns the keyring to use

func (*Config) GetKeystore

func (config *Config) GetKeystore() (*libdatamanager.Keystore, error)

GetKeystore returns the keystore assigned to the config

func (*Config) GetMachineID

func (config *Config) GetMachineID() string

GetMachineID returns the machineID

func (*Config) GetPreviewURL

func (config *Config) GetPreviewURL(file string) string

GetPreviewURL gets preview URL

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) KeystoreDirValid

func (config *Config) KeystoreDirValid() error

KeystoreDirValid return nil if keystore is valid

func (*Config) KeystoreEnabled

func (config *Config) KeystoreEnabled() bool

KeystoreEnabled return true if user wants to save keyfiles in a specified directory

func (Config) MustGetRequestConfig

func (config Config) MustGetRequestConfig() *libdatamanager.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) SetKeystoreDir

func (config *Config) SetKeystoreDir(newDir string) error

SetKeystoreDir sets new KeyStoreDir and 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() (*libdatamanager.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) UnsetKeystoreDir

func (config *Config) UnsetKeystoreDir() error

UnsetKeystoreDir removes keystore dir from confi and saves it

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