@@ -2,7 +2,6 @@ package main
2
2
3
3
import (
4
4
"context"
5
- "encoding/json"
6
5
"fmt"
7
6
"io"
8
7
"log"
@@ -15,7 +14,6 @@ import (
15
14
"time"
16
15
17
16
"github.com/docker/docker/api/types/container"
18
- "github.com/docker/docker/api/types/mount"
19
17
"github.com/docker/go-connections/nat"
20
18
"github.com/testcontainers/testcontainers-go"
21
19
"github.com/testcontainers/testcontainers-go/wait"
@@ -40,45 +38,6 @@ type fileInfo struct {
40
38
relPath string
41
39
}
42
40
43
- func getDockerSocketPath () (string , error ) {
44
- contextCmd := exec .Command ("docker" , "context" , "show" )
45
- contextOutput , err := contextCmd .Output ()
46
- if err != nil {
47
- return "" , fmt .Errorf ("failed to get docker context: %w" , err )
48
- }
49
- contextName := strings .TrimSpace (string (contextOutput ))
50
-
51
- inspectCmd := exec .Command ("docker" , "context" , "inspect" , contextName )
52
- inspectOutput , err := inspectCmd .Output ()
53
- if err != nil {
54
- return "" , fmt .Errorf ("failed to inspect docker context %s: %w" , contextName , err )
55
- }
56
-
57
- var contexts []struct {
58
- Endpoints struct {
59
- Docker struct {
60
- Host string `json:"Host"`
61
- } `json:"docker"`
62
- } `json:"Endpoints"`
63
- }
64
-
65
- if err := json .Unmarshal (inspectOutput , & contexts ); err != nil {
66
- return "" , fmt .Errorf ("failed to parse docker context inspect output: %w" , err )
67
- }
68
-
69
- if len (contexts ) == 0 {
70
- return "" , fmt .Errorf ("no docker contexts found" )
71
- }
72
-
73
- host := contexts [0 ].Endpoints .Docker .Host
74
- if ! strings .HasPrefix (host , "unix://" ) {
75
- return "" , fmt .Errorf ("docker host is not a unix socket: %s" , host )
76
- }
77
-
78
- socketPath := strings .TrimPrefix (host , "unix://" )
79
- return socketPath , nil
80
- }
81
-
82
41
func executeCommand (command string , args []string , taskDescription string ) {
83
42
fmt .Printf ("%s...\n " , taskDescription )
84
43
@@ -130,9 +89,6 @@ func prepareContainerFiles(absTestDir string) ([]testcontainers.ContainerFile, [
130
89
131
90
// Create a container request based on the test directory
132
91
func createContainerRequest (dirName string , port int , networkName string , containerFiles []testcontainers.ContainerFile ) testcontainers.ContainerRequest {
133
- pyroscope := strings .Contains (dirName , "pyroscope" )
134
- beyla := dirName == "beyla"
135
-
136
92
natPort , err := nat .NewPort ("tcp" , strconv .Itoa (port ))
137
93
if err != nil {
138
94
panic (fmt .Sprintf ("failed to build natPort: %v" , err ))
@@ -152,19 +108,9 @@ func createContainerRequest(dirName string, port int, networkName string, contai
152
108
},
153
109
Privileged : true ,
154
110
}
155
- dockerSocketPath , err := getDockerSocketPath ()
156
- if err != nil {
157
- panic (fmt .Sprintf ("failed to get docker socket path: %v" , err ))
158
- }
159
- if beyla || pyroscope {
111
+
112
+ if dirName == "beyla" {
160
113
req .HostConfigModifier = func (hostConfig * container.HostConfig ) {
161
- if pyroscope {
162
- hostConfig .Mounts = append (hostConfig .Mounts , mount.Mount {
163
- Type : mount .TypeBind ,
164
- Source : dockerSocketPath ,
165
- Target : "/host-docker.sock" ,
166
- })
167
- }
168
114
hostConfig .Privileged = true
169
115
hostConfig .CapAdd = []string {"SYS_ADMIN" , "SYS_PTRACE" , "SYS_RESOURCE" }
170
116
hostConfig .SecurityOpt = []string {"apparmor:unconfined" }
0 commit comments