Documentation ¶
Overview ¶
Package environment contains types and functions to assist in passing around environments to be used in commands and wrapping commands in those environments
Index ¶
- Constants
- func EnvironmentWrappedCommand(ctx context.Context, environ *CommandEnvironment, name string, arg ...string) *exec.Cmd
- func KerberosEnvironmentWrappedCommand(ctx context.Context, environ *CommandEnvironment, name string, arg ...string) *exec.Cmd
- type CommandEnvironment
- func (c *CommandEnvironment) Copy() *CommandEnvironment
- func (c *CommandEnvironment) GetSetting(s supportedCommandEnvironmentField) string
- func (c *CommandEnvironment) GetValue(s supportedCommandEnvironmentField) string
- func (c *CommandEnvironment) SetCondorCollectorHost(value string)
- func (c *CommandEnvironment) SetCondorCreddHost(value string)
- func (c *CommandEnvironment) SetCondorSecCredentialGettokenOpts(value string)
- func (c *CommandEnvironment) SetHtgettokenOpts(value string)
- func (c *CommandEnvironment) SetKrb5ccname(value string, t kerberosCCacheType)
- func (c *CommandEnvironment) String() string
Constants ¶
const ( Krb5ccname supportedCommandEnvironmentField = iota CondorCreddHost CondorCollectorHost HtgettokenOpts CondorSecCredentialGettokenOpts )
const ( DIR kerberosCCacheType // Indicates the location of a collection of caches FILE // Indicates the location of a single cache )
Variables ¶
This section is empty.
Functions ¶
func EnvironmentWrappedCommand ¶
func EnvironmentWrappedCommand(ctx context.Context, environ *CommandEnvironment, name string, arg ...string) *exec.Cmd
EnvironmentWrappedCommand takes an EnvironmentMapper, extracts the environment variables, and returns an *exec.Cmd that has those variables in its environment
func KerberosEnvironmentWrappedCommand ¶
func KerberosEnvironmentWrappedCommand(ctx context.Context, environ *CommandEnvironment, name string, arg ...string) *exec.Cmd
KerberosEnvironmentWrappedCommand takes an EnvironmentMapper, extracts the kerberos-related environment variables, and returns an *exec.Cmd that has those variables in its environment
Types ¶
type CommandEnvironment ¶
type CommandEnvironment struct { // Krb5ccname is the environment variable assignment for the cache directory for kerberos credentials // Values should be of the form "KRB5CCNAME=DIR:/my/kerberos/cache/dir" Krb5ccname environmentVariableSetting // CondorCreddHost is the hostname that is running the HTCondor credd. Values should be of the form // "_condor_CREDD_HOST=hostname.example.com" CondorCreddHost environmentVariableSetting // CondorCollectorHost is the hostname that is running the HTCondor collector. Values should be of the form // "_condor_COLLECTOR_HOST=hostname.example.com" CondorCollectorHost environmentVariableSetting // HtgettokenOpts is the set of options that need to be passed to condor_vault_storer, and underneath it, // htgettoken. Values should be of the form "HTGETTOKENOPTS=\"--opt1=val1 --opt2\" (note the escaped quotes)" HtgettokenOpts environmentVariableSetting // CondorSecCredentialGettokenOpts is the set of options that can be passed to override // Htgettokenopts in a condor_vault_storer command. CondorSecCredentialGettokenOpts environmentVariableSetting }
CommandEnvironment is an environment for the various token-related commands to use to obtain vault and bearer tokens The values of the fields are meant to be the full environment variable assignment statement, e.g.
c := CommandEnvironment{ CondorCreddHost: "my.credd.host", }
To set the fields of the CommandEnvironment, use the exported methods SetKrb5ccname, SetCondorCreddHost, etc. These methods will prepend the correct environment variable name. For example, to get the above CommandEnvironment, use
c := new(CommandEnvironment) c.SetCondorCreddHost = "my.credd.host"
func (*CommandEnvironment) Copy ¶
func (c *CommandEnvironment) Copy() *CommandEnvironment
Copy returns a new *CommandEnvironment with the fields set to the same values as the original
func (*CommandEnvironment) GetSetting ¶
func (c *CommandEnvironment) GetSetting(s supportedCommandEnvironmentField) string
GetSetting retrieves the full key=value setting from a supportedCommandEnvironmentField in the CommandEnvironment. For example, for the snippet:
c := CommandEnvironment{ Krb5ccname: "KRB5CCNAME=DIR:krb5ccname_setting "} setting := c.GetSetting(Krb5ccname)
setting will be "KRB5CCNAME=DIR:krb5ccname_setting" To get the value in the CommandEnvironment corresponding to the supportedCommandEnvironmentField key, use *commandEnvironment.GetValue().
func (*CommandEnvironment) GetValue ¶
func (c *CommandEnvironment) GetValue(s supportedCommandEnvironmentField) string
GetValue retrieves the full key=value setting from a supportedCommandEnvironmentField in the CommandEnvironment, trims the "key=" portion, and returns just the value For example, for the snippet:
c := CommandEnvironment{ Krb5ccname: "KRB5CCNAME=DIR:krb5ccname_setting "} value:= c.GetValue(Krb5ccname)
value will be "DIR:krb5ccname_setting"
func (*CommandEnvironment) SetCondorCollectorHost ¶
func (c *CommandEnvironment) SetCondorCollectorHost(value string)
SetCondorCollectorHost sets CondorCollectorHost field in the CommandEnvironment
func (*CommandEnvironment) SetCondorCreddHost ¶
func (c *CommandEnvironment) SetCondorCreddHost(value string)
SetCondorCreddHost sets CondorCreddHost field in the CommandEnvironment
func (*CommandEnvironment) SetCondorSecCredentialGettokenOpts ¶
func (c *CommandEnvironment) SetCondorSecCredentialGettokenOpts(value string)
SetCondorSecCredentialGettokenOpts sets the CondorSecCredentialGettokenOpts field in the CommandEnvironment
func (*CommandEnvironment) SetHtgettokenOpts ¶
func (c *CommandEnvironment) SetHtgettokenOpts(value string)
SetHtgettokenOpts sets the HtgettokenOpts field in the CommandEnvironment
func (*CommandEnvironment) SetKrb5ccname ¶
func (c *CommandEnvironment) SetKrb5ccname(value string, t kerberosCCacheType)
SetKrb5CCName sets Krb5ccname field in the CommandEnvironment. The kerberosCCache type corresponds to one of the following Supported Credential Cache Types: "DIR:", "FILE:"
func (*CommandEnvironment) String ¶
func (c *CommandEnvironment) String() string