config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const UnknownCodeOwner = "???"

UnknownCodeOwner is the value represented by CodeOwner() when no repo is specified

View Source
const UnknownCodeRepo = "???"

UnknownCodeRepo is the value represented by CodeRepo() when no repo is specified

Variables

View Source
var ErrAPIURLUnparsable = errors.New("Unable to parse API URL")

ErrAPIURLUnparsable is the error returned when the given APIURL cannot be parsed

View Source
var ErrAccessKeyNotSet = errors.New("Access Key has not been specified")

ErrAccessKeyNotSet is the error returned when the provided access key is blank

View Source
var ErrConfigFileDoesNotExist = errors.New("Config file does not exist")

ErrConfigFileDoesNotExist is the error returned when the config file cannot be found at the time of (attempted) parsing

View Source
var ErrSecretKeyMalformed = errors.New("Secret Key is malformed")

ErrSecretKeyMalformed is the error returned when the provided secret key cannot be base64-decoded

View Source
var ErrSecretKeyNotSet = errors.New("Secret Key has not been specified")

ErrSecretKeyNotSet is the error returned when the provided secret key is blank

Functions

func APIURL added in v1.1.0

func APIURL() string

APIURL is an accessor for the currently loaded value of APIURL

func ASHIRTConfigPath added in v1.1.0

func ASHIRTConfigPath() string

ASHIRTConfigPath points to the configuration file used by the ASHIRT application

func ATermConfigPath added in v1.1.0

func ATermConfigPath() string

ATermConfigPath points to where the terminal recorder config is located

func AccessKey added in v1.1.0

func AccessKey() string

AccessKey is an accessor for the currently loaded value of AccessKey

func BuildDate added in v1.1.0

func BuildDate() string

BuildDate extracts the build date from the build flags and formats the date in rfc 3339 format

func CodeOwner added in v1.1.0

func CodeOwner() string

CodeOwner extracts the owner portion of the owner/repo build flag

func CodeRepo added in v1.1.0

func CodeRepo() string

CodeRepo extracts the repository portion of the owner/repo build flag

func CommitHash added in v1.1.0

func CommitHash() string

CommitHash extracts the commit hash from the build flags

func GoRuntime added in v1.1.0

func GoRuntime() string

GoRuntime retrieves the current runtime data

func OperationSlug added in v1.1.0

func OperationSlug() string

OperationSlug is an accessor for the currently loaded value of OperationSlug

func OutputDir added in v1.1.0

func OutputDir() string

OutputDir is an accessor for the currently loaded value of OutputDir

func OutputFileName added in v1.1.0

func OutputFileName() string

OutputFileName is an accessor for the currently loaded value of OutputFileName

func ParseConfig added in v1.1.0

func ParseConfig(overrides CLIOptions) error

ParseConfig returns the parsed configuration, based on built-in defaults, config file values, system environment configuration, and CLI overrides, in that order. See ParseConfigNoOverrides for a version with CLI overrides.

func PrintConfigTo added in v1.1.0

func PrintConfigTo(t TermRecorderConfig, w io.Writer)

PrintConfigTo writes the provided configuration to the provided io.Writer. This is optimized for human reading, rather than as a serialization format. All errors that are encountered while writing are ignored.

func PrintConfigWithHeaderTo added in v1.1.0

func PrintConfigWithHeaderTo(header string, t TermRecorderConfig, w io.Writer)

PrintConfigWithHeaderTo writes the provided configuration to the provided io.Writer. This is optimized for human reading, rather than as a serialization format. All errors that are encountered while writing are ignored.

func PrintLoadedConfig added in v1.1.0

func PrintLoadedConfig(w io.Writer)

func RecordingShell added in v1.1.0

func RecordingShell() string

RecordingShell is an accessor for the currently loaded value of RecordingShell

func SecretKey added in v1.1.0

func SecretKey() string

SecretKey is an accessor for the currently loaded value of SecretKey

func SetConfig added in v1.1.0

func SetConfig(newConfig TermRecorderConfig)

func ValidateConfig added in v1.1.0

func ValidateConfig(tConfig TermRecorderConfig) error

ValidateConfig checks the provided configuration for issues. Current issues include: * AccessKey is set * SecretKey set and decodable * APIURL parsable Returns an error. This error is a go-multierror, and can indicate multiple errors. Errors can be checked via errors.Is function

func ValidateLoadedConfig added in v1.1.0

func ValidateLoadedConfig() error

ValidateLoadedConfig is shorthand for calling ValidateConfig(loadedConfig). i.e. it validates the loaded configuration, rather than an arbitrary configuration

func Version added in v1.1.0

func Version() string

Version extracts the tagged version from the build flags

func WriteConfig added in v1.1.0

func WriteConfig() error

Types

type CLIOptions added in v1.1.0

type CLIOptions struct {
	OutputFileNamePrefix string
	OperationSlug        string
	RecordingShell       string
	ShowMenu             bool
	PrintConfig          bool
	ForceFirstRun        bool
	HardReset            bool
	PrintVersion         bool
}

CLIOptions wraps the values that can be retrieved from the command line. Note that no-values are actually represented as zero-value

func ParseCLI added in v1.1.0

func ParseCLI() CLIOptions

ParseCLI parses all (supported) arguments from the command line and stores them in a CLIOptions struct

type TermRecorderConfig

type TermRecorderConfig struct {
	ConfigVersion  int64  `yaml:"configVersion"`
	APIURL         string `yaml:"apiURL"         split_words:"true" envconfig:"api_url"`
	OutputDir      string `yaml:"outputDir"      split_words:"true"`
	AccessKey      string `yaml:"accessKey"      split_words:"true"`
	SecretKey      string `yaml:"secretKey"      split_words:"true" envconfig:"secret_key"`
	OutputFileName string `yaml:"-"              split_words:"true"`
	OperationSlug  string `yaml:"operationSlug"  split_words:"true"`
	RecordingShell string `yaml:"recordingShell" split_words:"true"`
}

func CurrentConfig added in v1.1.0

func CurrentConfig() TermRecorderConfig

func ParseConfigNoOverrides added in v1.1.0

func ParseConfigNoOverrides() (TermRecorderConfig, error)

ParseConfigNoOverrides returns the parsed configuration, based on built-in defaults, config file values and system environment configuration, in that order. Note that this parses and returns the configuration, rather than storing it for later use

func PreviewUpdatedConfig added in v1.1.0

func PreviewUpdatedConfig(overrides TermRecorderConfigOverrides) TermRecorderConfig

PreviewUpdatedConfig provides a mechanism to generate a TermRecorderConfig without changing the loaded configuration. Can be chained with SetConfig to alter the current state of the application, and can modify the permanent state of the configuration with WriteConfig

func PreviewUpdatedInstanceConfig added in v1.1.0

func PreviewUpdatedInstanceConfig(cfg TermRecorderConfig, overrides TermRecorderConfigOverrides) TermRecorderConfig

PreviewUpdatedInstanceConfig provides a mechanism to generate a TermRecorderConfig without changing the provided configuration. Can be chained with SetConfig to alter the current state of the application, and can modify the permanent state of the configuration with WriteConfig

func TermRecorderConfigWithDefaults added in v1.1.0

func TermRecorderConfigWithDefaults() TermRecorderConfig

TermRecorderConfigWithDefaults generates a TermRecorderConfig struct with some common default values

func (*TermRecorderConfig) WriteConfigToFile added in v1.1.0

func (t *TermRecorderConfig) WriteConfigToFile(configFilePath string) error

type TermRecorderConfigOverrides added in v1.1.0

type TermRecorderConfigOverrides struct {
	APIURL         *string `json:"apiURL"`
	OutputDir      *string `json:"evidenceRepo"`
	AccessKey      *string `json:"accessKey"`
	SecretKey      *string `json:"secretKey"`
	OutputFileName *string
	OperationSlug  *string
	RecordingShell *string
}

func CloneConfigAsOverrides added in v1.1.0

func CloneConfigAsOverrides(cfg TermRecorderConfig) TermRecorderConfigOverrides

func CloneLoadedConfigAsOverrides added in v1.1.0

func CloneLoadedConfigAsOverrides() TermRecorderConfigOverrides

Jump to

Keyboard shortcuts

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