config

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrefixEncrypted prefix used in encrypted string fields to identify when a string is encrypted or not
	PrefixEncrypted = "{encrypted}"

	KeyFileName = ".key"
)

Functions

This section is empty.

Types

type CliConfiguration

type CliConfiguration struct {

	// Persistent settings (stored to file)
	Persistent *viper.Viper

	// SecureData accessor to encrypt/decrypt data
	SecureData *encrypt.SecureData

	// Passphrase used for encrypting/decrypting fields
	Passphrase string

	// KeyFile path to the key file used to test encryption
	KeyFile string

	// SecretText used to test the encryption passphrase
	SecretText string

	Logger *logger.Logger
	// contains filtered or unexported fields
}

CliConfiguration cli configuration settings

func NewCliConfiguration

func NewCliConfiguration(v *viper.Viper, secureData *encrypt.SecureData, home string, passphrase string) *CliConfiguration

NewCliConfiguration returns a new CLI configuration object

func (*CliConfiguration) BindAuthorization

func (c *CliConfiguration) BindAuthorization() error

func (*CliConfiguration) CheckEncryption

func (c *CliConfiguration) CheckEncryption(encryptedText ...string) (string, error)

func (*CliConfiguration) CreateKeyFile

func (c *CliConfiguration) CreateKeyFile(keyText string) error

func (CliConfiguration) Debug

func (c CliConfiguration) Debug()

func (*CliConfiguration) DecryptString

func (c *CliConfiguration) DecryptString(value string) (string, error)

DecryptString returns the decrypted string if the string is encrypted

func (CliConfiguration) GetCookies

func (c CliConfiguration) GetCookies() []*http.Cookie

GetCookies gets the cookies stored in the configuration

func (*CliConfiguration) GetDefaultUsername

func (c *CliConfiguration) GetDefaultUsername() string

func (*CliConfiguration) GetDescription added in v1.8.0

func (c *CliConfiguration) GetDescription() string

GetDescription returns the name description of the current session

func (*CliConfiguration) GetEncryptedString

func (c *CliConfiguration) GetEncryptedString(key string) string

GetEncryptedString returns string value of a potentially encrypted field in the configuration If the fields starts with the encrypted prefix, then it will be decrypted using the CLI passphrase, otherwise the value will be returned as is.

func (CliConfiguration) GetEnvKey

func (c CliConfiguration) GetEnvKey(key string) string

GetEnvKey returns the environment key value associated

func (CliConfiguration) GetEnvironmentVariables

func (c CliConfiguration) GetEnvironmentVariables() map[string]interface{}

func (*CliConfiguration) GetHost

func (c *CliConfiguration) GetHost() string

GetHost returns the Cumulocity host URL

func (*CliConfiguration) GetName added in v1.8.0

func (c *CliConfiguration) GetName() string

GetName returns the name of the current session

func (*CliConfiguration) GetPassword

func (c *CliConfiguration) GetPassword() (string, error)

GetPassword returns the decrypted password of the current session

func (*CliConfiguration) GetSessionFilePath added in v1.8.0

func (c *CliConfiguration) GetSessionFilePath() string

GetSessionFilePath returns the session file path

func (*CliConfiguration) GetString

func (c *CliConfiguration) GetString(key string) string

GetString returns a string from the configuration

func (*CliConfiguration) GetTOTP

func (c *CliConfiguration) GetTOTP(t time.Time) (string, error)

GetTOTP returns a TOTP generated by a TOTP secret (if present)

func (*CliConfiguration) GetTenant

func (c *CliConfiguration) GetTenant() string

GetTenant returns the Cumulocity tenant id

func (*CliConfiguration) GetUsername

func (c *CliConfiguration) GetUsername() string

func (*CliConfiguration) IsCIMode

func (c *CliConfiguration) IsCIMode() bool

IsCIMode return true if the cli is running in CI mode

func (*CliConfiguration) IsEncryptionEnabled

func (c *CliConfiguration) IsEncryptionEnabled() bool

IsEncryptionEnabled indicates if session encryption is enabled or not

func (*CliConfiguration) IsPasswordEncrypted

func (c *CliConfiguration) IsPasswordEncrypted() bool

GetPasswordRaw return ture if the password is encrypted

func (*CliConfiguration) MustGetPassword

func (c *CliConfiguration) MustGetPassword() string

func (*CliConfiguration) ReadConfig

func (c *CliConfiguration) ReadConfig(file string) error

ReadConfig reads the given file and loads it into the persistent session config

func (*CliConfiguration) ReadKeyFile

func (c *CliConfiguration) ReadKeyFile() error

func (*CliConfiguration) SetAuthorizationCookies

func (c *CliConfiguration) SetAuthorizationCookies(cookies []*http.Cookie)

SetAuthorizationCookies saves the authorization cookies

func (*CliConfiguration) SetEncryptedString

func (c *CliConfiguration) SetEncryptedString(key, value string) error

SetEncryptedString encrypts and sets a value in the configuration. If the give value is empty, then the value will be read from the configuration file

func (*CliConfiguration) SetLogger

func (c *CliConfiguration) SetLogger(l *logger.Logger)

SetLogger sets the logger

func (*CliConfiguration) SetPassword

func (c *CliConfiguration) SetPassword(p string)

func (*CliConfiguration) SetSessionFilePath added in v1.8.0

func (c *CliConfiguration) SetSessionFilePath(v string)

SetSessionFilePath sets the session's file path

func (*CliConfiguration) SetTenant

func (c *CliConfiguration) SetTenant(value string)

func (*CliConfiguration) WritePersistentConfig

func (c *CliConfiguration) WritePersistentConfig() error

WritePersistentConfig saves the configuration to file

Jump to

Keyboard shortcuts

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