Documentation ¶
Index ¶
- Constants
- Variables
- func GenMachineID() string
- func GetDefaultConfigFile() string
- func IsTokenValid(token string) bool
- func IsUnlockError(err error) bool
- type Config
- func (config *Config) ClearKeyring(username string) error
- func (config *Config) GetDefaultOrder() string
- func (config *Config) GetKeyring() string
- func (config *Config) GetKeystore() (*libdatamanager.Keystore, error)
- func (config *Config) GetMachineID() string
- func (config *Config) GetPreviewURL(file string) string
- func (config *Config) GetToken() (string, error)
- func (config *Config) InsertUser(user, token string)
- func (config Config) IsDefault() bool
- func (config *Config) IsLoggedIn() bool
- func (config *Config) KeystoreDirValid() error
- func (config *Config) KeystoreEnabled() bool
- func (config Config) MustGetRequestConfig() *libdatamanager.RequestConfig
- func (config *Config) MustSetToken(token string)
- func (config *Config) Save() error
- func (config *Config) SetKeystoreDir(newDir string) error
- func (config *Config) SetMachineID()
- func (config *Config) SetToken(token string) error
- func (config Config) ToRequestConfig() (*libdatamanager.RequestConfig, error)
- func (config *Config) UnsetKeystoreDir() error
- func (config *Config) Validate() error
- func (config Config) View(redactSecrets bool) string
Constants ¶
const ( // File constants DataDir = ".dmanager" DefaultConfigFile = "config.yaml" // Keyring constants DefaultKeyring = "login" KeyringServiceName = "DataManagerCLI" )
...
Variables ¶
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 ¶
IsTokenValid return true if given token is a vaild session token
func IsUnlockError ¶
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 ¶
InitConfig inits the configfile
func (*Config) ClearKeyring ¶
ClearKeyring removes session from keyring
func (*Config) GetDefaultOrder ¶
GetDefaultOrder returns the default order. If empty returns the default order
func (*Config) GetKeyring ¶
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 ¶
GetMachineID returns the machineID
func (*Config) GetPreviewURL ¶
GetPreviewURL gets preview URL
func (*Config) InsertUser ¶
InsertUser insert a new user
func (*Config) IsLoggedIn ¶
IsLoggedIn return true if sessiondata is available
func (*Config) KeystoreDirValid ¶
KeystoreDirValid return nil if keystore is valid
func (*Config) KeystoreEnabled ¶
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 ¶
MustSetToken fatals on error
func (*Config) SetKeystoreDir ¶
SetKeystoreDir sets new KeyStoreDir and saves the config
func (*Config) SetMachineID ¶
func (config *Config) SetMachineID()
SetMachineID sets machineID if empty
func (*Config) SetToken ¶
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 ¶
UnsetKeystoreDir removes keystore dir from confi and saves it