instance

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const AttributesOptionsText = "An attribute in the format NAME=VALUE\n(Repeat as required, san only)"
View Source
const EnvsOptionsText = "An environment variable for instance start-up\n(Repeat as required)"
View Source
const GatewaysOptionstext = "A gateway connection in the format HOSTNAME:PORT\n(Repeat as required, san and floating only)"
View Source
const IncludeValuesOptionsText = "An include file in the format `PRIORITY:[PATH|URL]`\n(Repeat as required, gateway only)"

IncludeValuesOptionsText is the default help text for command to use for options setting include files

View Source
const TypesOptionsText = "A type NAME\n(Repeat as required, san only)"
View Source
const VarsOptionsText = "A variable in the format [TYPE:]NAME=VALUE\n(Repeat as required, san only)"

Variables

This section is empty.

Functions

func Abs

func Abs(i geneos.Instance, file string) (result string)

Abs returns an absolute path to file prepended with the instance working directory if file is not already an absolute path. If file is empty then an empty result is returned.

func AtLeastVersion added in v1.5.0

func AtLeastVersion(i geneos.Instance, version string) bool

AtLeastVersion returns true if the installed version for instance i is version or greater. If the version of the instance is somehow unparseable then this returns false.

func BaseVersion added in v1.6.0

func BaseVersion(i geneos.Instance) (dir string)

BaseVersion returns the absolute path of the base package directory for the instance i.

func BuildCmd

func BuildCmd(i geneos.Instance, noDecode bool, options ...StartOptions) (cmd *exec.Cmd)

BuildCmd gathers the path to the binary, arguments and any environment variables for an instance and returns an exec.Cmd, almost ready for execution. Callers will add more details such as working directories, user and group etc.

If noDecode is set then any secure environment variables are not decoded, so can be used for display

Any extras arguments are appended without further checks

func ByKeyValues added in v1.11.0

func ByKeyValues(h *geneos.Host, ct *geneos.Component, values ...string) (confs []geneos.Instance)

ByKeyValues returns a slice of instances where the instance configuration matches all the given parameter values in the form "parameter=value".

func ByName added in v1.8.0

func ByName(h *geneos.Host, ct *geneos.Component, name string) (i geneos.Instance, err error)

ByName looks for exactly one matching instance across types and hosts returns Invalid Args if zero if there is more than a single match

func ByNameAll added in v1.8.0

func ByNameAll(h *geneos.Host, ct *geneos.Component, name string) (instances []geneos.Instance)

ByNameAll constructs and returns a slice of instances that have a matching name. Host h is used to validate the host portion of the full name of the instance, if given.

func ByNames added in v1.8.0

func ByNames(h *geneos.Host, ct *geneos.Component, names ...string) (instances []geneos.Instance, err error)

ByNames returns a slice of instances that match any of the names given, using the host h as a validation check against names with a host qualification

func Clean

func Clean(i geneos.Instance, full bool) (err error)

Clean removes all the files and directories listed in the component type of the instance i for removal. First all entries in the CleanList are removed and then, if full is true, the instance is stopped and the entries in FullClean are removed. Any instances stopped are started up, but any that were already stopped will be left stopped.

func ComponentFilename

func ComponentFilename(i geneos.Instance, extensions ...string) string

ComponentFilename returns the filename for the component used by the instance i with the extensions appended, joined with a ".". If no extensions are given then the current configuration file type is used, e.g. "json" or "yaml".

func ComponentFilepath

func ComponentFilepath(i geneos.Instance, extensions ...string) string

ComponentFilepath returns an absolute path to a file named for the component type of the instance with any extensions joined using ".", e.g. is c is a netprobe instance then

path := instance.ComponentFilepath(c, "xml", "orig")

will return /path/to/netprobe/netprobe.xml.orig

If no extensions are passed then the default us to add an extension of the instance.ConfigType, which defaults to "json", e.g. using the same instance as above:

path := instance.ComponentPath(c)

will return /path/to/netprobe/netprobe.json

func ConfigFileType added in v1.4.1

func ConfigFileType() (conftype string)

ConfigFileType returns the current primary configuration file extension

func ConfigFileTypes added in v1.4.1

func ConfigFileTypes() []string

ConfigFileTypes contains a list of supported configuration file extensions

func Copy added in v1.7.0

func Copy(ct *geneos.Component, source, destination string, options ...CopyOptions) (err error)

Copy copies the instance named source to destination for component type ct. If the move argument is true then the source is deleted after the copy.

Both source and destination can include host labels as well as being only host labels to indicate all instances of type ct on that host. If source is in the form `@host` then destination must also be a host - and different - or the function returns an error, but is it valid to have a specific source and a destination of only `@host` and then the name of the instance is used, as with file system operations on files and directories normally.

If ct is nil that all component types are considered

func CreateAESKeyFile added in v1.13.0

func CreateAESKeyFile(i geneos.Instance) (err error)

CreateAESKeyFile creates a new key file, for secure passwords as per https://docs.itrsgroup.com/docs/geneos/current/Gateway_Reference_Guide/gateway_secure_passwords.htm

func DeleteSettingFromMap added in v1.4.1

func DeleteSettingFromMap(i geneos.Instance, from map[string]interface{}, key string)

DeleteSettingFromMap removes key from the map from and if it is registered as an alias it also removes the key that alias refers to.

func Disable added in v1.5.0

func Disable(i geneos.Instance) (err error)

Disable the instance i. Does not try to stop a running instance and returns an error if it is running.

func DisplayName

func DisplayName(i geneos.Instance) string

DisplayName returns the type, name and non-local host as a string suitable for display.

func Enable added in v1.5.0

func Enable(i geneos.Instance) (err error)

Enable removes the disabled flag, if any,m from instance i.

func ExecuteTemplate added in v1.7.0

func ExecuteTemplate(i geneos.Instance, p string, name string, defaultTemplate []byte) (err error)

ExecuteTemplate loads templates from TYPE/templates/[tmpl]* and parse them, using the instance data write it out to a single file. If tmpl is empty, load all files

func FileOf added in v1.7.0

func FileOf(i geneos.Instance, name string) (filename string)

FileOf returns the basename of the file identified by the configuration parameter name.

If the parameter is unset or empty then an empty path is returned.

func Filepaths added in v1.6.3

func Filepaths(i geneos.Instance, names ...string) (filenames []string)

Filepaths returns the full paths to the files identified by the list of parameters in names.

If the instance configuration is valid an empty slice is returned. If a parameter is unset or empty then an empty path is returned.

func Files

func Files(i geneos.Instance) (openfiles map[int]OpenFiles)

Files returns a map of file descriptor (int) to file details (InstanceProcFiles) for all open, real, files for the process running as the instance. All paths that are not absolute paths are ignored. An empty map is returned if the process cannot be found.

func Get

func Get(ct *geneos.Component, name string) (i geneos.Instance, err error)

Get return an instance of component ct, and loads the config. It is an error if the config cannot be loaded.

func GetAll

func GetAll(h *geneos.Host, ct *geneos.Component) (instances []geneos.Instance)

GetAll returns a slice of instances for a given component type on remote h

func GetAllPorts added in v1.9.0

func GetAllPorts(h *geneos.Host) (ports map[uint16]bool)

GetAllPorts gets all used ports in config files on a specific remote and also all listening ports on the same host. Returns a map of port to bool "true" for each lookup.

func GetPID

func GetPID(i geneos.Instance) (pid int, err error)

GetPID returns the PID of the process running for the instance. If not found then an err of os.ErrProcessDone is returned.

The process is identified by checking the conventions used to start Geneos processes.

func GetPIDInfo

func GetPIDInfo(i geneos.Instance) (pid int, uid int, gid int, mtime time.Time, err error)

GetPIDInfo returns the PID of the process for the instance i along with the owner uid and gid and the start time.

func Home added in v1.7.0

func Home(i geneos.Instance) (home string)

Home return the directory for the instance. It checks for the first existing directory from:

  • The one configured for the instance factory and in the configuration parameter "home"
  • In the default component instances directory (component.InstanceDir)
  • If the instance's component type has a parent component then in the legacy instances directory

If no directory is found then a default built using PathTo() is returned

func IsA added in v1.5.0

func IsA(i geneos.Instance, names ...string) bool

IsA returns true if instance i has a type that is component of one of names. Any name that does not

func IsAutoStart added in v1.6.1

func IsAutoStart(i geneos.Instance) bool

IsAutoStart returns true is the instance is set to autostart

func IsDisabled

func IsDisabled(i geneos.Instance) bool

IsDisabled returns true if the instance i is disabled.

func IsProtected

func IsProtected(i geneos.Instance) bool

IsProtected returns true if instance i is marked protected

func IsRunning added in v1.5.0

func IsRunning(i geneos.Instance) bool

IsRunning returns true if the instance is running

func ListeningPorts added in v1.6.3

func ListeningPorts(i geneos.Instance) (ports []int)

ListeningPorts returns all TCP ports currently open for the process running as the instance. An empty slice is returned if the process cannot be found. The instance may be on a remote host.

func ListeningPortsStrings added in v1.7.0

func ListeningPortsStrings(i geneos.Instance) (ports []string)

ListeningPorts returns all TCP ports currently open for the process running as the instance. An empty slice is returned if the process cannot be found. The instance may be on a remote host.

func LiveVersion added in v1.7.0

func LiveVersion(i geneos.Instance, pid int) (base string, version string, actual string, err error)

LiveVersion returns the base package name, the underlying package version and the actual version in use for the instance i. If base is not a link, then base is also returned as the symlink. If there are more than 10 levels of symlink then return symlink set to "loop-detected" and err set to syscall.ELOOP to prevent infinite loops. If the instance is not running or the executable path cannot be determined then actual will be returned as "unknown".

func LoadConfig

func LoadConfig(i geneos.Instance) (err error)

LoadConfig will load the JSON config file if available, otherwise try to load the "legacy" .rc file

The modtime of the underlying config file is recorded in ConfigLoaded and checked before re-loading

support cache?

error check core values - e.g. Name

func LogFilePath added in v1.7.0

func LogFilePath(i geneos.Instance) (logfile string)

LogFilePath returns the full path to the log file for the instance.

func Match

func Match(h *geneos.Host, ct *geneos.Component, patterns ...string) (names []string)

Match applies file glob patterns to all instance names (stripped of hostname) on the host h and of the component type ct and returns all matches. Valid patterns are the same as for path.Match.

The returned slice is sorted and duplicates are removed.

Patterns that resolve to empty (e.g. @hostname) are returned unchanged and unchecked against valid names.

func Migrate

func Migrate(i geneos.Instance) (err error)

Migrate is a helper that checks if the configuration was loaded from a legacy .rc file and if it has it then saves the current configuration (it does not reload the .rc file) in a new format file and renames the .rc file to .rc.orig to allow Revert to work.

Also now check if instance directory path has changed. If so move it.

func Names added in v1.7.0

func Names(h *geneos.Host, ct *geneos.Component) (names []string)

Names returns a slice of all instance names for a given component ct on host h. No checking is done to validate that the directory is a populated instance. Names are qualified with the host name.

To support the move to parent types we do a little more, looking for legacy locations in here

func NextPort

func NextPort(h *geneos.Host, ct *geneos.Component) uint16

NextPort returns the next available (unallocated and unused) TCP listening port for component ct on host h.

The range of ports available for a component is defined in the configuration for the user and for each component type. A port is available if it is neither allocated to any other instance on the same host (of any component type) and also is not in use by any other process which may not be a Geneos instance.

Each range is a comma separated list of single port number, e.g. "7036", a min-max inclusive range, e.g. "7036-8036" or a 'start-' open ended range, e.g. "7041-". Ranges can also be denoted by double-dot in addition to single dashes '-'.

some limits based on https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

not concurrency safe at this time

func PathOf added in v1.7.0

func PathOf(i geneos.Instance, name string) string

PathOf returns the full path to the file identified by the configuration parameter name. If the parameters value is already an absolute path then it is returned as-is, otherwise it is joined with the home directory of the instance and returned. The path is only useful on the host that instance i is on.

If the parameter is unset or empty then an empty path is returned.

func ReadAESKeyFile added in v1.13.0

func ReadAESKeyFile(i geneos.Instance, setting ...string) (keyfile config.KeyFile, kv *config.KeyValues, crc uint32, err error)

ReadAESKeyFile locates the path to the keyfile in the instance configuration, using the first setting if passed otherwise defaulting to `keyfile`. If found, return the key values in kv or an error,

func ReadCert

func ReadCert(i geneos.Instance) (cert *x509.Certificate, valid bool, chainfile string, err error)

ReadCert reads the instance certificate for c. It verifies the certificate against any chain file and, if that fails, against system certificates.

func ReadKVConfig added in v1.13.0

func ReadKVConfig(r host.Host, p string) (kvs map[string]string, err error)

ReadKVConfig reads a file containing key=value lines, returning a map of key to value. We need this to preserve the case of keys, which viper forces to lowercase, when writing this file back out via WriteKVConfig().

func ReadKey

func ReadKey(i geneos.Instance) (key *memguard.Enclave, err error)

ReadKey reads the instance RSA private key

func ReadRCConfig added in v1.8.0

func ReadRCConfig(r host.Host, cf *config.Config, p string, prefix string, aliases map[string]string) (err error)

ReadRCConfig reads an old-style, legacy Geneos "ctl" layout configuration file and sets values in cf corresponding to updated equivalents.

All empty lines and those beginning with "#" comments are ignored.

The rest of the lines are treated as `name=value` pairs and are processed as follows:

  • If `name` is either `binsuffix` (case-insensitive) or `prefix`+`name` then it saved as a config item. This is looked up in the `aliases` map and if there is a match then this new name is used.
  • All other `name=value` entries are saved as environment variables in the configuration for the instance under the `Env` key.

func RemovePaths

func RemovePaths(i geneos.Instance, paths string) (err error)

RemovePaths removes all files and directories in paths, each file or directory is separated by ListSeperator

func ReservedName

func ReservedName(name string) (ok bool)

ReservedName returns true if name is a reserved word. Reserved names are checked against all the values registered by components at start-up.

func RollAESKeyFile added in v1.13.0

func RollAESKeyFile(i geneos.Instance, nkv *config.KeyValues, backup string) (keyfile config.KeyFile, crc uint32, err error)

RollAESKeyFile moves any existing instance key file to a "previous" filename unless it is in a shared keyfiles directory, in which case it sets `prevkeyfile` to this path and saves the new key file values nkv to the instance directory.

Otherwise, the current keyfile is renamed to a file where the backup string is appended to the base name before the extension and the key file values nkv are written to a new file and the instance settings updated.

func SaveConfig added in v1.7.0

func SaveConfig(i geneos.Instance, values ...map[string]any) (err error)

SaveConfig writes the first values map or, if none, the instance configuration to the standard file for that instance. All legacy parameter (aliases) are removed from the set of values saved.

func SetDefaults

func SetDefaults(i geneos.Instance, name string) (err error)

SetDefaults is a common function called by component factory functions to iterate over the component specific instance struct and set the defaults as defined in the 'defaults' struct tags.

func SetInstanceValues added in v1.7.0

func SetInstanceValues(i geneos.Instance, set SetConfigValues, keyfile config.KeyFile) (err error)

SetInstanceValues applies the settings in values to instance i by iterating through the fields and calling the appropriate helper function. SecureEnvs overwrite any set by Envs earlier.

func SetSecureArgs

func SetSecureArgs(i geneos.Instance) (args []string)

SetSecureArgs returns a slice of arguments to enable secure connections if the correct configuration values are set. The private key may be in the certificate file and the chain is optional.

func Shared added in v1.7.0

func Shared(i geneos.Instance, subs ...interface{}) string

Shared returns the full path to a directory or file in the instances component type shared directory joined to any parts subs - the last element can be a filename. If the instance is not loaded then "." is returned for the current directory.

func Signal

func Signal(i geneos.Instance, signal syscall.Signal) (err error)

Signal sends the signal to the instance

func SplitName

func SplitName(in string, defaultHost *geneos.Host) (ct *geneos.Component, name string, h *geneos.Host)

SplitName returns the parts of an instance name given an instance name in the format [TYPE:]NAME[@HOST] and a default host, return a *geneos.Component for the TYPE if given, a string for the NAME and a *geneos.Host - the latter being either from the name or the default provided

func Start

func Start(i geneos.Instance, opts ...any) (err error)

Start runs the instance.

func Stop

func Stop(i geneos.Instance, force, kill bool) (err error)

Stop an instance

func UnsetInstanceValues added in v1.7.0

func UnsetInstanceValues(i geneos.Instance, unset UnsetConfigValues) (changed bool)

XXX abstract this for a general case

func ValidName added in v1.7.0

func ValidName(name string) (ok bool)

ValidName returns true if name is considered a valid instance name. It is not checked against the list of reserved names.

XXX used to consume instance names until parameters are then passed down

func Version

func Version(i geneos.Instance) (base string, version string, err error)

Version returns the base package name, the underlying package version and the actual version in use for the instance i. If base is not a link, then base is also returned as the symlink. If there are more than 10 levels of symlink then return symlink set to "loop-detected" and err set to syscall.ELOOP to prevent infinite loops. If the instance is not running or the executable path cannot be determined then actual will be returned as "unknown".

func WriteAESKeyFile added in v1.13.0

func WriteAESKeyFile(i geneos.Instance, kv *config.KeyValues) (keyfile config.KeyFile, crc uint32, err error)

WriteAESKeyFile writes key values to a an instance key file, for secure passwords as per https://docs.itrsgroup.com/docs/geneos/current/Gateway_Reference_Guide/gateway_secure_passwords.htm

If the instance config is updated then it is also saved.

func WriteCert

func WriteCert(i geneos.Instance, cert *x509.Certificate) (err error)

WriteCert writes the certificate for the instance i and updates the "certificate" instance parameter. It does not save the instance configuration.

func WriteKVConfig added in v1.13.0

func WriteKVConfig(r host.Host, p string, kvs map[string]string) (err error)

WriteKVConfig writes out the map kvs to the file on host r at path p.

TODO: write to tmp file and rotate to protect

func WriteKey

func WriteKey(i geneos.Instance, key *memguard.Enclave) (err error)

WriteKey writes the key for the instance i and updates the "privatekey" instance parameter. It does not save the instance configuration.

func WriterDefaultOptions added in v1.8.0

func WriterDefaultOptions(options ...WriterOptions)

WriterDefaultOptions sets and defaults for calls to instance.Write

The defaults, unless otherwise set are to write errors to os.Stderr and to ignore os.ErrProcessDone and geneos.ErrNotSupported errors and to skip other outputs for each response on non-ignored errors.

Types

type CopyOptions added in v1.11.0

type CopyOptions func(*copyOptions)

func Move added in v1.11.0

func Move() CopyOptions

Move tells Copy to remove the source instance(s) after the copy.

func Params added in v1.11.0

func Params(p ...string) CopyOptions

Params add key=value parameters to the copied/moved destination, overriding the values of the source. Currently only supports plain paramaters, not structured ones like environments.

type Gateways added in v1.7.0

type Gateways map[string]string

gateway - name:port

func (*Gateways) Set added in v1.7.0

func (i *Gateways) Set(value string) error

func (*Gateways) String added in v1.7.0

func (i *Gateways) String() string

func (*Gateways) Type added in v1.7.0

func (i *Gateways) Type() string

type ImportFiles added in v1.6.0

type ImportFiles []string

ImportFiles fulfils the Var interface for pflag

func (*ImportFiles) Set added in v1.6.0

func (i *ImportFiles) Set(value string) error

func (*ImportFiles) String added in v1.6.0

func (i *ImportFiles) String() string

func (*ImportFiles) Type added in v1.6.0

func (i *ImportFiles) Type() string

type Includes added in v1.7.0

type Includes map[string]string

Includes is a map of include file priority to path include file - priority:url|path

func (*Includes) Set added in v1.7.0

func (i *Includes) Set(value string) error

func (*Includes) String added in v1.7.0

func (i *Includes) String() string

String is the string method for the IncludeValues type

func (*Includes) Type added in v1.7.0

func (i *Includes) Type() string

type Instance

type Instance struct {
	geneos.Instance `json:"-"`
	Conf            *config.Config    `json:"-"`
	InstanceHost    *geneos.Host      `json:"-"`
	Component       *geneos.Component `json:"-"`
	ConfigLoaded    time.Time         `json:"-"`
}

The Instance type is the common data shared by all instances

type NameValues added in v1.8.0

type NameValues []string

attribute - name=value

func (*NameValues) Set added in v1.8.0

func (i *NameValues) Set(value string) error

func (*NameValues) String added in v1.8.0

func (i *NameValues) String() string

func (*NameValues) Type added in v1.8.0

func (i *NameValues) Type() string

type OpenFiles added in v1.4.3

type OpenFiles struct {
	Path   string
	Stat   fs.FileInfo
	FD     string
	FDMode fs.FileMode
}

type Response added in v1.8.0

type Response struct {
	Instance  geneos.Instance
	Line      string     // single line response,
	Lines     []string   // Lines of output
	Rows      [][]string // rows of values (for CSV)
	Value     any
	Start     time.Time
	Finish    time.Time
	Completed []string // simple past tense verbs of completed actions, e.g. "stopped", "started" etc.
	Err       error
}

Response is a consolidated set of responses from commands

func CreateCert

func CreateCert(i geneos.Instance, duration time.Duration) (resp *Response)

CreateCert creates a new certificate for an instance.

If the root and signing certs are readable then create an instance specific chain file, otherwise set the instance to point to the system chain file.

this also creates a new private key

skip if certificate exists and is valid

func MergeResponse added in v1.8.0

func MergeResponse(r1, r2 *Response) (resp *Response)

MergeResponse merges r1 and r2 and returns a single response pointer. Instance is set to r1.Instance, and the r2.Instance value is ignored. Single value fields are turned into multi-value fields if both r1 and r2 have them set. if both Value fields are set them they are turned into a slice of both. The Finish time from r2 is copied to r1, the Start time is only copied if r1.Start is unset. The Err fields are joined using errors.Join()

This should only be used where a sequence of actions are being performed and a single response is expected.

func NewResponse added in v1.8.0

func NewResponse(i geneos.Instance) *Response

NewResponse returns a pointer to an intialised Response structure, using instance i. The Start time is set to time.Now().

type Responses added in v1.8.0

type Responses []*Response

func Do added in v1.8.0

func Do(h *geneos.Host, ct *geneos.Component, names []string, f func(geneos.Instance, ...any) *Response, values ...any) (responses Responses)

Do calls function f for each matching instance and gathers the return values into a slice of Response for handling by the caller. The functions are executed in goroutines and must be concurrency safe.

The values are passed to each function called and must not be changes by the called function. The called function should validate and cast values for use.

Do calls ByNames() to resolve the names given to a list of matching instances on host h (which can be geneos.ALL to look on all hosts) and for type ct, which can be nil to look across all component types.

func (Responses) Len added in v1.8.0

func (r Responses) Len() int

func (Responses) Less added in v1.8.0

func (r Responses) Less(i, j int) bool

func (Responses) Swap added in v1.8.0

func (r Responses) Swap(i, j int)

func (Responses) Write added in v1.8.0

func (responses Responses) Write(writer any, options ...WriterOptions)

Write iterates over responses and outputs a formatted response to writer.

If instance.WriterSkipOnErr(true) is set then any response with a non-nil Err field, where errors are not ignored with instance.WriterIgnoreErr() or instance.WriterIgnoreErrs(), then the other outputs are skipped (even if the error writer is the default io.Discard). Errors then written as described below.

If writer is a *tabwriter.Writer String and Strings are written with a trailing newline.

If writer is a *csv.Writer then Strings and Rows are written.

Otherwise if Value is not nil then it is treated as a slice of any values which are marshalled as a JSON array and written to writer. If any value is a slice then it is unrolled and each element is instead written as a top-level array element, allowing values to contain their own arrays of responses. Any non-empty String or any Strings elements are output with a trailing newline. Any newline already present is removed to ensure only one newline between lines.

If an error writer is set with instance.WriteStderr() then all non-ignored errors are written out, prefixed with the Instance.String() and a colon. Note that this format may change if and when structured logging is introduced.

Write calls Flush() after writing to CSV or Tab writers.

func (Responses) WriteHTML added in v1.8.0

func (responses Responses) WriteHTML(writer any, options ...WriterOptions)

WriteHTML will structure the responses in a way that can be displayed well in an HTML container. Currently does nothing.

type SecureValue added in v1.7.0

type SecureValue struct {
	Value      string
	Plaintext  *config.Plaintext
	Ciphertext string
}

type SecureValues added in v1.7.0

type SecureValues []*SecureValue

func (*SecureValues) Set added in v1.7.0

func (p *SecureValues) Set(v string) error

Set a SecureValue. If there is a "=VALUE" part then this is saved in Plaintext, otherwise only the NAME is set. This allows later processing to either encode the Plaintext into Ciphertext or to prompt the user for a plaintext

func (*SecureValues) String added in v1.7.0

func (p *SecureValues) String() string

func (*SecureValues) Type added in v1.7.0

func (p *SecureValues) Type() string

type SetConfigValues added in v1.7.0

type SetConfigValues struct {
	// Includes are include files for Gateway templates, keyed by priority
	Includes Includes

	// Gateways are gateway connections for SAN templates
	Gateways Gateways

	// Attributes are name=value pairs for attributes for Gateway templates
	Attributes NameValues

	// Environment variables for all instances as name=value pairs
	Envs NameValues

	// Variables for SAN templates, keyed by variable name
	Variables Vars

	// Types for SAN templates
	Types Types

	// Params are key=value pairs set directly in the configuration after checking
	Params []string

	// SecureParams parameters name[=value] where value will be prompted
	// for if not supplied and are encoded with a keyfile
	SecureParams SecureValues

	// SecureEnvs are environment variables in the form name[=value]
	// where value will be prompted for if not supplied and are encoded
	// with a keyfile
	SecureEnvs SecureValues
}

SetConfigValues defined the set of non-simple configuration options that can be accepted by various commands

type SortInstanceResponses added in v1.8.0

type SortInstanceResponses struct {
	Instances []geneos.Instance
	Results   []interface{}
}

func (SortInstanceResponses) Len added in v1.8.0

func (s SortInstanceResponses) Len() int

func (SortInstanceResponses) Less added in v1.8.0

func (s SortInstanceResponses) Less(i, j int) bool

func (SortInstanceResponses) Swap added in v1.8.0

func (s SortInstanceResponses) Swap(i, j int)

type StartOptions added in v1.8.0

type StartOptions func(*startOptions)

func StartingEnvs added in v1.8.0

func StartingEnvs(envs NameValues) StartOptions

StartingEnvs takes a NameValues list of extra environment variables to append to the standard list for the instance.

func StartingExtras added in v1.8.0

func StartingExtras(extras string) StartOptions

StartingExtras sets extra command line parameters by splitting extras on spaces. Quotes, escaping and other shell-like separators are ignored.

type Types added in v1.7.0

type Types []string

attribute - name=value

func (*Types) Set added in v1.7.0

func (i *Types) Set(value string) error

func (*Types) String added in v1.7.0

func (i *Types) String() string

func (*Types) Type added in v1.7.0

func (i *Types) Type() string

type UnsetConfigValues added in v1.5.0

type UnsetConfigValues struct {
	Attributes UnsetValues
	Envs       UnsetValues
	Gateways   UnsetValues
	Includes   UnsetValues
	Keys       UnsetValues
	Types      UnsetValues
	Variables  UnsetVars
}

type UnsetValues added in v1.5.0

type UnsetValues []string

unset Var flags take just the key, either a name or a priority for include files

func (*UnsetValues) Set added in v1.7.0

func (i *UnsetValues) Set(value string) error

func (*UnsetValues) String added in v1.7.0

func (i *UnsetValues) String() string

func (*UnsetValues) Type added in v1.7.0

func (i *UnsetValues) Type() string

type UnsetVars added in v1.7.0

type UnsetVars []string

func (*UnsetVars) Set added in v1.7.0

func (i *UnsetVars) Set(value string) error

func (*UnsetVars) String added in v1.7.0

func (i *UnsetVars) String() string

func (*UnsetVars) Type added in v1.7.0

func (i *UnsetVars) Type() string

type VarValue added in v1.5.0

type VarValue struct {
	Type  string
	Name  string
	Value string
}

variables - [TYPE:]NAME=VALUE

type Vars added in v1.7.0

type Vars map[string]VarValue

func (*Vars) Set added in v1.7.0

func (i *Vars) Set(value string) error

func (*Vars) String added in v1.7.0

func (i *Vars) String() string

func (*Vars) Type added in v1.7.0

func (i *Vars) Type() string

type WriterOptions added in v1.8.0

type WriterOptions func(*writeOptions)

WriterOptions controls to behaviour of the instance.Write method

func WriterIgnoreErr added in v1.8.0

func WriterIgnoreErr(err error) WriterOptions

WriteIgnoreErr adds err to the list of errors for instance.Write to skip.

func WriterIgnoreErrs added in v1.8.0

func WriterIgnoreErrs(errs ...error) WriterOptions

WriterIgnoreErrs sets the errors that the instance.Write method will skip outputting. It replaces any existing set.

func WriterIndent added in v1.8.0

func WriterIndent(indent bool) WriterOptions

WriterIndent sets the JSON indentation to true or false for the output of Values in instance.Write

func WriterPlainValue added in v1.8.0

func WriterPlainValue() WriterOptions

WriterPlainValue overrides the output of Value as JSON and instead it is written as a string, in the format `prefix + value as %s + suffix`, where prefix and suffix can be set ising WriterPrefix and WriterSuffix respectively, if the defaults are not suitable.

func WriterPrefix added in v1.8.0

func WriterPrefix(prefix string) WriterOptions

WriterPrefix is the Printf-style format to prefix plain text output (only once per Lines). It can have one argument, the instance as a geneos.Instance. The default is `"%s "`.

func WriterShowTimes added in v1.8.0

func WriterShowTimes() WriterOptions

WriterShowTimes enables the output of the duration of each call. The format of the output can be changed using WriterTimingFormat.

func WriterSkipOnErr added in v1.8.0

func WriterSkipOnErr(skip bool) WriterOptions

WriterSkipOnErr sets the behaviour of instance.Write regarding the output of other responses data if an error is present. If skip is true then any response that has a non-ignored error will output the error (subject to WriterStderr) and skip other returned data.

func WriterStderr added in v1.8.0

func WriterStderr(stderr io.Writer) WriterOptions

WriteStderr sets the writer to use for errors. It defaults to os.Stderr

func WriterSuffix added in v1.8.0

func WriterSuffix(suffix string) WriterOptions

WriterSuffix is the suffix added to plain text output. The default is a single newline (`\n`).

func WriterTimingFormat added in v1.8.0

func WriterTimingFormat(format string) WriterOptions

WriterTimingFormat sets the output format of any timing information. It is a Printf-style format with the instance (as a geneos.Instance) and the duration (as a time.Duration) as the two arguments.

Jump to

Keyboard shortcuts

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