Documentation
¶
Overview ¶
Package util provides utility methods for the agent.
Index ¶
- Constants
- Variables
- func GetEC2InstanceID(ctx context.Context) (string, error)
- func KillSpawnedProcs(ctx context.Context, key, workingDir, execUser string, logger grip.Journaler) error
- func S3DefaultURL(bucket, key string) string
- func S3PathURL(bucket, key string) string
- func S3VirtualHostedURL(bucket, key string) string
- func TrackProcess(key string, pid int, logger grip.Journaler)
- type DynamicExpansions
- func (e *DynamicExpansions) Get(key string) string
- func (e *DynamicExpansions) GetRedacted() []RedactInfo
- func (e *DynamicExpansions) Put(key, value string)
- func (e *DynamicExpansions) PutAndRedact(key, value string)
- func (e *DynamicExpansions) Redact(key, value string)
- func (e *DynamicExpansions) RedactKey(key string)
- func (e *DynamicExpansions) Remove(expansion string)
- func (e *DynamicExpansions) Update(newExpansions map[string]string)
- func (e *DynamicExpansions) UpdateFromYaml(filename string) ([]string, error)
- func (e *DynamicExpansions) UpdateFromYamlAndRedact(filename string) ([]string, error)
- type RedactInfo
Constants ¶
const ( MarkerTaskID = "EVR_TASK_ID" MarkerAgentPID = "EVR_AGENT_PID" MarkerInEvergreen = "IN_EVERGREEN" )
Variables ¶
var ErrPSTimeout = errors.New("ps timeout")
Functions ¶
func GetEC2InstanceID ¶
GetEC2InstanceID returns the instance ID from the metadata endpoint if it's an EC2 instance.
func KillSpawnedProcs ¶
func KillSpawnedProcs(ctx context.Context, key, workingDir, execUser string, logger grip.Journaler) error
KillSpawnedProcs kills processes that descend from the agent and waits for them to terminate.
func S3DefaultURL ¶
S3DefaultURL returns the S3 URL for the given bucket containing the object key. The style of the S3 URL is determined based on the bucket name.
func S3PathURL ¶
S3PathURL returns the path-style S3 URL for the given bucket containing the object key.
func S3VirtualHostedURL ¶
S3VirtualHostedURL returns the virtual hosted-style S3 URL for the given bucket containing the object key.
Types ¶
type DynamicExpansions ¶
type DynamicExpansions struct { util.Expansions // contains filtered or unexported fields }
DynamicExpansions wraps expansions for safe concurrent access as they are dynamically updated. It also contains logic to redact values that should not be exposed.
This should be expanded to support better expansion handling during a task run.
func NewDynamicExpansions ¶
func NewDynamicExpansions(e util.Expansions) *DynamicExpansions
func (*DynamicExpansions) Get ¶
func (e *DynamicExpansions) Get(key string) string
func (*DynamicExpansions) GetRedacted ¶
func (e *DynamicExpansions) GetRedacted() []RedactInfo
GetRedacted gets the expansions that should be redacted.
func (*DynamicExpansions) Put ¶
func (e *DynamicExpansions) Put(key, value string)
func (*DynamicExpansions) PutAndRedact ¶
func (e *DynamicExpansions) PutAndRedact(key, value string)
PutAndRedact puts the expansions followed by marking it for redaction.
func (*DynamicExpansions) Redact ¶
func (e *DynamicExpansions) Redact(key, value string)
Redact adds a key and value pair to be redacted. This should only be used for generated keys not exposed to the task.
func (*DynamicExpansions) RedactKey ¶
func (e *DynamicExpansions) RedactKey(key string)
Redact marks the expansion with given key for redaction.
func (*DynamicExpansions) Remove ¶
func (e *DynamicExpansions) Remove(expansion string)
Remove deletes a value from the expansions.
func (*DynamicExpansions) Update ¶
func (e *DynamicExpansions) Update(newExpansions map[string]string)
func (*DynamicExpansions) UpdateFromYaml ¶
func (e *DynamicExpansions) UpdateFromYaml(filename string) ([]string, error)
func (*DynamicExpansions) UpdateFromYamlAndRedact ¶
func (e *DynamicExpansions) UpdateFromYamlAndRedact(filename string) ([]string, error)
UpdateFromYamlAndRedact updates the expansions from the given yaml file and then marks the expansions for redaction.