Documentation ¶
Overview ¶
cmdUtils provides utilities that are meant to be used by the various executables that the managed tokens library provides
Index ¶
- func CheckExperimentOverride(experiment string) string
- func GetCondorCollectorHostFromConfiguration(checkServiceConfigPath string) string
- func GetFileCopierOptionsFromConfig(serviceConfigPath string) []string
- func GetKeytabFromConfiguration(checkServiceConfigPath string) string
- func GetPingOptsFromConfig(checkServiceConfigPath string) []string
- func GetSSHOptsFromConfig(checkServiceConfigPath string) []string
- func GetScheddsAndCollectorHostFromConfiguration(ctx context.Context, checkServiceConfigPath string) (string, []string, error)
- func GetServiceConfigOverrideKeyOrGlobalKey(checkServiceConfigPath, key string) (configPath string, overridden bool)
- func GetServiceCreddVaultTokenPathRoot(checkServiceConfigPath string) string
- func GetServiceName(s service.Service) string
- func GetUserPrincipalAndHtgettokenoptsFromConfiguration(checkServiceConfigPath string) (userPrincipal string, htgettokenOpts string)
- func GetUserPrincipalFromConfiguration(checkServiceConfigPath string) string
- func GetVaultServer(checkServiceConfigPath string) (string, error)
- func GetWorkerConfigInt(workerType, key string) int
- func GetWorkerConfigString(workerType, key string) string
- func GetWorkerConfigStringSlice(workerType, key string) []string
- func GetWorkerConfigValue(workerType, key string) any
- func ResolveDisableNotifications(services []service.Service) (bool, []string)
- func SetCondorCollectorHostInCommandEnvironment(collector string) func(*environment.CommandEnvironment)
- func SetHtgettokenOptsInCommandEnvironment(htgettokenopts string) func(*environment.CommandEnvironment)
- func Setkrb5ccnameInCommandEnvironment(krb5ccname string) func(*environment.CommandEnvironment)
- type DisableNotificationsOption
- type ExperimentOverriddenService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckExperimentOverride ¶
CheckExperimentOverride checks the configuration for a given experiment to see if it has an "experimentOverride" key defined. If it does, it will return that override value. Else, it will return the passed in experiment string
func GetCondorCollectorHostFromConfiguration ¶
GetCondorCollectorHostFromConfiguration gets the condor collector host from the Viper configuration which will be used to populate the _condor_COLLECTOR_HOST environment variable. It is preferred to use GetScheddsAndCollectorHostFromConfiguration to get the collector host, as it will also populate the schedd cache and handle failovers
func GetFileCopierOptionsFromConfig ¶
GetFileCopierOptionsFromConfig gets the fileCopierOptions from the configuration. If fileCopierOptions is overridden at the service configuration level, then the global configuration value is ignored.
func GetKeytabFromConfiguration ¶
GetKeytabFromConfiguration checks the configuration at the checkServiceConfigPath for an override for the path to the kerberos keytab. If the override does not exist, it uses the configuration to calculate the default path to the keytab
func GetPingOptsFromConfig ¶
GetPingOptsFromConfig checks the configuration at the checkServiceConfigPath for an override for extra args to pass to the ping worker. If the override does not exist, it uses the configuration to calculate the default path to the relevant directory
func GetSSHOptsFromConfig ¶
GetSSHOptsFromConfig checks the configuration at the checkServiceConfigPath for an override for extra args to pass to the fileCopier worker. If the override does not exist, it uses the configuration to calculate the default path to the relevant directory
func GetScheddsAndCollectorHostFromConfiguration ¶ added in v0.15.0
func GetScheddsAndCollectorHostFromConfiguration(ctx context.Context, checkServiceConfigPath string) (string, []string, error)
GetScheddsAndCollectorHostFromConfiguration gets the schedd names that match the configured constraint by querying the condor collector. It can be overridden by setting the checkServiceConfigPath's condorCreddHostOverride field, in which case that value will be set as the schedd. It returns the collector host used, and the list of schedds that were found. If no valid collector host or schedds are found, an error is returned.
func GetServiceConfigOverrideKeyOrGlobalKey ¶
func GetServiceConfigOverrideKeyOrGlobalKey(checkServiceConfigPath, key string) (configPath string, overridden bool)
GetServiceConfigOverrideKeyOrGlobalKey checks to see if key + "Override" is defined at the checkServiceConfigPath in the configuration. If so, the full configuration path is returned, and the overridden bool is set to true. If not, the original key is returned, and the overridden bool is set to false
func GetServiceCreddVaultTokenPathRoot ¶
GetServiceCreddVaultTokenPathRoot checks the configuration at the checkServiceConfigPath for an override for the path to the directory where the condorVaultStorer worker should look for and store service/credd-specific vault tokens. If the override does not exist, it uses the configuration to calculate the default path to the relevant directory
func GetServiceName ¶
GetServiceName type checks the service.Service passed in, and returns the appropriate service name for registration and logging purposes.
func GetUserPrincipalAndHtgettokenoptsFromConfiguration ¶
func GetUserPrincipalAndHtgettokenoptsFromConfiguration(checkServiceConfigPath string) (userPrincipal string, htgettokenOpts string)
GetUserPrincipalAndHtgettokenoptsFromConfiguration gets a worker.Config's kerberos principal and with it, the value for the HTGETTOKENOPTS environment variable
func GetUserPrincipalFromConfiguration ¶
GetUserPrincipalFromConfiguration gets the configured kerberos principal
func GetVaultServer ¶
GetVaultServer queries various sources to get the correct vault server or SEC_CREDENTIAL_GETTOKEN_OPTS setting, which condor_vault_storer needs to store the refresh token in a vault server. The order of precedence is:
1. Environment variable _condor_SEC_CREDENTIAL_GETTOKEN_OPTS 2. Configuration file for managed tokens 3. Condor configuration file SEC_CREDENTIAL_GETTOKEN_OPTS value
func GetWorkerConfigInt ¶ added in v0.15.0
GetWorkerConfigInt retrieves the configuration value for the given worker type and key, and returns it as a string. If the value is not a string, an empty string is returned.
func GetWorkerConfigString ¶ added in v0.15.0
GetWorkerConfigString retrieves the configuration value for the given worker type and key, and returns it as a string. If the value is not a string, an empty string is returned.
func GetWorkerConfigStringSlice ¶ added in v0.15.0
GetWorkerConfigStringSlice retrieves the configuration value for the given worker type and key, and returns it as a slice of strings. If the value is not a []string, an empty slice is returned.
func GetWorkerConfigValue ¶ added in v0.15.0
GetWorkerConfigValue retrieves the value of a worker-specific key from the configuration
func ResolveDisableNotifications ¶ added in v0.15.0
ResolveDisableNotifications checks each service's configuration to determine if notifications should be disabled. It takes a slice of service objects as input and returns a boolean indicating whether admin notifications should be disabled, and a slice of strings containing the names of services for which notifications should be disabled.
func SetCondorCollectorHostInCommandEnvironment ¶
func SetCondorCollectorHostInCommandEnvironment(collector string) func(*environment.CommandEnvironment)
SetCondorCollectorHostInCommandEnvironment returns a function that sets the _condor_COLLECTOR_HOST environment variable in an environment.CommandEnvironment
func SetHtgettokenOptsInCommandEnvironment ¶
func SetHtgettokenOptsInCommandEnvironment(htgettokenopts string) func(*environment.CommandEnvironment)
SetHtgettokenOptsInCommandEnvironment returns a function that sets the HTGETTOKENOPTS environment variable in an environment.CommandEnvironment
func Setkrb5ccnameInCommandEnvironment ¶
func Setkrb5ccnameInCommandEnvironment(krb5ccname string) func(*environment.CommandEnvironment)
Setkrb5ccname returns a function that sets the KRB5CCNAME directory environment variable in an environment.CommandEnvironment
Types ¶
type DisableNotificationsOption ¶ added in v0.15.0
type DisableNotificationsOption uint
const ( DISABLED_BY_CONFIGURATION DisableNotificationsOption = iota DISABLED_BY_FLAG )
func (DisableNotificationsOption) String ¶ added in v0.15.0
func (d DisableNotificationsOption) String() string
type ExperimentOverriddenService ¶
type ExperimentOverriddenService struct { // Service should contain the actual experiment name (the overridden experiment name), not the configuration key service.Service // ConfigExperiment is the configuration key under the experiments section where this // experiment can be found ConfigExperiment string // ConfigService is the service obtained by using the configExperiment concatenated with an underscore, and Service.Role() ConfigService string }
ExperimentOverriddenService is a service where the experiment is overridden. We want to monitor/act on the config key, but use the service name that might duplicate another service.
func NewExperimentOverriddenService ¶
func NewExperimentOverriddenService(serviceName, configKey string) *ExperimentOverriddenService
NewExperimentOverriddenService returns a new *ExperimentOverriddenService by using the service name and configuration key that corresponds to the name of the experiment in the configuration. For example, if there is a configuration: experiments:
experiment1: roles: role1: foo: bar experiment2: experimentOverride: experiment1 roles: role1: foo: baz
Then NewExperimentOverriddenService("experiment1_role1", "experiment2") would return an ExperimentOverriddenService whose Service field would have "experiment1" and "role1" as the experiment and role, respectively; whose ConfigExperiment field would be "experiment2", and whose ConfigService field would be "experiment2_role1".
Further, the returned ExperimentOverriddenService's Experiment() method would return "experiment2" rather than "experiment1", the Role() method would return "role1", and the Name() method would return "experiment1_role1"
func (*ExperimentOverriddenService) ConfigName ¶
func (e *ExperimentOverriddenService) ConfigName() string
ConfigName returns the value stored in the ConfigService key, meant to be a concatenation of the return value of the Experiment() method, "_", and the return value of the Role() method The reason for having this separate method is to avoid duplicated service names for multiple experiment configurations that have the same overridden experiment values and roles but are meant to be handled independently, for example, for different condor pools
func (*ExperimentOverriddenService) Experiment ¶
func (e *ExperimentOverriddenService) Experiment() string
Experiment returns the ExperimentOverriddenService's name that is guaranteed to be unique across all services
func (*ExperimentOverriddenService) Name ¶
func (e *ExperimentOverriddenService) Name() string
Name returns the ExperimentOverriddenService's Service.Name field. If there is another service with the same experiment name in the configuration file, this may not be a unique value across all services.
func (*ExperimentOverriddenService) Role ¶
func (e *ExperimentOverriddenService) Role() string