config

package
v0.0.0-...-4df811a Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNoPublicKey  error = errors.New("no public key")
	ErrorNoPrivateKey       = errors.New("no private key")
)

Functions

func AddAccount

func AddAccount(account map[string]string) int

Adds an account to the config ! does not write to disk

func AddHook

func AddHook(command string)

func CheckExpiredTokenError

func CheckExpiredTokenError(err *kserrors.Error)

CheckExpiredTokenError function checks if the API error is a token exipiration and logsout the user if so

func ConfigDir

func ConfigDir() (dirpath string, err error)

ConfigDir function returns the path to the config dir, and creates it if it doesn't exist

func ConfigPath

func ConfigPath() (configPath string, err error)

ConfigPath function returns the path to the config file.

func GetAllAccounts

func GetAllAccounts() []map[string]string

Reads all accounts from disk

func GetAuthToken

func GetAuthToken() string

GetAuthToken function returns the latest auth token we obtained

func GetCurrentAccount

func GetCurrentAccount() (user models.User, index int)

Reads the current account from disk Returns the account as a map, and its index If the user is logged out, the map is empty, and the index is -1

func GetDeviceName

func GetDeviceName() string

GetDeviceName function returns the current device name

func GetDeviceUID

func GetDeviceUID() string

GetDeviceUID function returns the current device UID

func GetHook

func GetHook() (string, bool)

func GetServiceApiKey

func GetServiceApiKey(serviceName string) string

GetServiceApiKey function returns the API Key for the named CI service

func GetUserPrivateKey

func GetUserPrivateKey() (privateKey []byte, err error)

GetUserPrivateKey function returns the currently logged in user's private key

func GetUserPublicKey

func GetUserPublicKey() (publicKey []byte, err error)

GetUserPublicKey function returns the currently logged in users's public key

func InitConfig

func InitConfig(cfgFile string) (err error)

initConfig reads in config file and ENV variables if set.

func IsLoggedIn

func IsLoggedIn() bool

Returns `true` if the user is logged in

func Logout

func Logout()

Logout function logs the user oud

func RemoveHook

func RemoveHook()

func RevokeDevice

func RevokeDevice() error

RevokeDevice removes device information (including keys) from the configuration file

func SetAuthToken

func SetAuthToken(token string)

Saves the jwt token

func SetCurrentAccount

func SetCurrentAccount(index int)

Sets the current account as the index at `index` Means the user is logged in as the user of that account

func SetServiceApiKey

func SetServiceApiKey(serviceName string, token string)

SetServiceApiKey function sets the API Key for the named CI service

func SetUserPrivateKey

func SetUserPrivateKey(privateKey []byte)

SetUserPrivateKey function sets the private key for the currenty logged in user

func SetUserPublicKey

func SetUserPublicKey(publicKey []byte)

SetUserPublicKey function sets the pulblic key for the currently logged in use

func UserFromAccount

func UserFromAccount(account map[string]string) (user models.User)

UserFromAccount function returns a `models.User` instance from an account map

func Write

func Write()

Writes the global config to the disk Exits with 1 status code

Types

This section is empty.

Jump to

Keyboard shortcuts

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