cfg

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Ask prompts a string, asks, and returns what user entered

View Source
var AskPasswordWithPrompt = DefaultAskPasswordWithPrompt

AskPasswordWithPrompt prints a prompt and gets password

View Source
var DefaultEncTimeout = 10 * time.Minute

DefaultEncTimeout is 10 minutes, the default idle timeout for the took decrypt agent

View Source
var UserCfgFile string

Functions

func AskPassword added in v1.6.0

func AskPassword() string

AskPassword asks "Password" and reads the password

func AskPasswordStartDecrypt added in v1.6.0

func AskPasswordStartDecrypt(timeout time.Duration, configFile string)

AskPasswordStartDecrypt asks password and starts the decrypt server with the given timout

func AskUsername added in v1.6.0

func AskUsername() string

AskUsername asks "user name" and reads input

func ConnectEncServer added in v1.6.0

func ConnectEncServer(name string) (*rpc.RequestProcessorClient, error)

ConnectEncServer attempts to connect the decryption agent

func ConvertMap added in v1.6.0

func ConvertMap(in interface{}) interface{}

ConvertMap converts map[interface{}]interface{} into map[string]interface{}

func Decode

func Decode(in, out interface{})

Decode a map[] into a structure

func DecryptUserConfig added in v1.6.0

func DecryptUserConfig(file string)

DecryptUserConfig decrypts the user config if it is encrypted. After this call, Data and Configuration members of the configuration are set, and EData and ECfg are set to empty

func DefaultAsk added in v1.7.0

func DefaultAsk(prompt string) string

DefaultAsk asks something to the user and returns it. Panics on error

func DefaultAskPasswordWithPrompt added in v1.7.0

func DefaultAskPasswordWithPrompt(prompt string) string

DefaultAskPasswordWithPrompt prompts, and asks password

func InsecureAllowed added in v1.6.0

func InsecureAllowed() bool

InsecureAllowed returns true if program path has -insecure in it.

func MustConnectEncServer added in v1.6.0

func MustConnectEncServer(file string) *rpc.RequestProcessorClient

MustConnectEncServer connects to decryption agent and exists if fails

func ReadUserConfig

func ReadUserConfig(file string)

ReadUserConfig reads the user configuration file and sets UserCfg

func StartDecrypt added in v1.6.0

func StartDecrypt(password string, timeout time.Duration, configFile string)

StartDecrypt starts another copy of took with decrypt x flag, and passes the password. Panics on fail

func ValidateInsecureURL added in v1.6.0

func ValidateInsecureURL(url string)

ValidateInsecureURL validates that a URL is https, or insecure URLs are allowd

func WriteConfig

func WriteConfig(cfgFile string, cfg Configuration) error

WriteConfig writes configuration to the file

func WriteUserConfig

func WriteUserConfig(cfgFile string) error

WriteUserConfig writes the user config file

Types

type Configuration

type Configuration struct {
	AuthKey        string             `yaml:"key,omitempty"`
	Remotes        map[string]Remote  `yaml:"remotes,omitempty"`
	ServerProfiles map[string]Profile `yaml:"serverProfiles,omitempty"`
}

Configuration declares the structure of the config file

var CommonCfg Configuration

CommonCfg is the common config from /etc/tool.yaml

var UserCfg Configuration

UserCfg is the user's config

func ReadCommonConfig

func ReadCommonConfig() Configuration

ReadCommonConfig reads the common configuration file under /etc/took.yaml

func ReadConfig

func ReadConfig(cfgFile string) Configuration

ReadConfig reads the cfgFile.

func (Configuration) GetServerProfile

func (c Configuration) GetServerProfile(name string) Profile

GetServerProfile returns a server profile by name. Returns empty profile if not found

type Profile

type Profile struct {
	Type          string      `yaml:"type"`
	Configuration interface{} `yaml:"cfg,omitempty"`
}

Profile is combines the type and the type-specific configuration of a server profile

func GetServerProfile

func GetServerProfile(name string) Profile

GetServerProfile returns the server profile from user cfg. If there is none, then it returns the profile from common cfg. If common cfg does not have a profile, it'll return empty profile

type Remote

type Remote struct {
	// Type is the auth protocol
	Type string `yaml:"type"`
	// Configuration is the prototocol specific configuration
	Configuration interface{} `yaml:"cfg,omitempty"`
	// Data contains the protocol specific token information
	Data interface{} `yaml:"data,omitempty"`
	// ECfg is the encrypted configuration. Only one of Configuration or Ecfg is nonempty
	ECfg string `yaml:"ecfg,omitempty"`
	// EData is the encrypted data. Only one of Data or EData is nonempty
	EData string `yaml:"edata,omitempty"`
}

Remote defines a remote auth configuration

Jump to

Keyboard shortcuts

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