/
agent_docker.go
28 lines (23 loc) · 1023 Bytes
/
agent_docker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package client
type agentDockerExecutor struct {
dockerClient *Docker
agentContainerName string
}
var _ agentCommandExecutor = &agentDockerExecutor{}
func newAgentDockerExecutor(dockerClient *Docker, agentContainerName string) *agentDockerExecutor {
return &agentDockerExecutor{
dockerClient: dockerClient,
agentContainerName: agentContainerName,
}
}
func (ae agentDockerExecutor) execute(arguments []string) (string, error) {
// We consider that in a container, "agent" is always in path and is the single entrypoint.
// It's mostly incorrect but it's what we have ATM.
// TODO: Support all agents and Windows
arguments = append([]string{"agent"}, arguments...)
return ae.dockerClient.ExecuteCommandWithErr(ae.agentContainerName, arguments...)
}