44
44
// DockerComposeExecutableName is the OS dependent Docker CLI binary name
45
45
DockerComposeExecutableName = "docker-" + compose .PluginName
46
46
47
- // DockerScanExecutableName is the OS dependent Docker CLI binary name
47
+ // DockerScanExecutableName is the OS dependent Docker Scan plugin binary name
48
48
DockerScanExecutableName = "docker-scan"
49
49
50
+ // DockerBuildxExecutableName is the Os dependent Buildx plugin binary name
51
+ DockerBuildxExecutableName = "docker-buildx"
52
+
50
53
// WindowsExecutableSuffix is the Windows executable suffix
51
54
WindowsExecutableSuffix = ".exe"
52
55
)
@@ -56,6 +59,7 @@ func init() {
56
59
DockerExecutableName += WindowsExecutableSuffix
57
60
DockerComposeExecutableName += WindowsExecutableSuffix
58
61
DockerScanExecutableName += WindowsExecutableSuffix
62
+ DockerBuildxExecutableName += WindowsExecutableSuffix
59
63
}
60
64
}
61
65
@@ -133,8 +137,13 @@ func initializePlugins(t testing.TB, configDir string) {
133
137
if os .IsNotExist (err ) {
134
138
t .Logf ("WARNING: docker-compose cli-plugin not found" )
135
139
}
140
+ buildxPlugin , err := findPluginExecutable (DockerBuildxExecutableName )
141
+ if os .IsNotExist (err ) {
142
+ t .Logf ("WARNING: docker-buildx cli-plugin not found" )
143
+ }
136
144
if err == nil {
137
145
CopyFile (t , composePlugin , filepath .Join (configDir , "cli-plugins" , DockerComposeExecutableName ))
146
+ CopyFile (t , buildxPlugin , filepath .Join (configDir , "cli-plugins" , DockerBuildxExecutableName ))
138
147
// We don't need a functional scan plugin, but a valid plugin binary
139
148
CopyFile (t , composePlugin , filepath .Join (configDir , "cli-plugins" , DockerScanExecutableName ))
140
149
}
@@ -166,6 +175,22 @@ func findExecutable(executableName string) (string, error) {
166
175
return "" , errors .Wrap (os .ErrNotExist , "executable not found" )
167
176
}
168
177
178
+ func findPluginExecutable (pluginExecutableName string ) (string , error ) {
179
+ dockerUserDir := ".docker/cli-plugins"
180
+ userDir , err := os .UserHomeDir ()
181
+ if err != nil {
182
+ return "" , err
183
+ }
184
+ bin , err := filepath .Abs (filepath .Join (userDir , dockerUserDir , pluginExecutableName ))
185
+ if err != nil {
186
+ return "" , err
187
+ }
188
+ if _ , err := os .Stat (bin ); err == nil {
189
+ return bin , nil
190
+ }
191
+ return "" , errors .Wrap (os .ErrNotExist , fmt .Sprintf ("plugin not found %s" , pluginExecutableName ))
192
+ }
193
+
169
194
// CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
170
195
func CopyFile (t testing.TB , sourceFile string , destinationFile string ) {
171
196
t .Helper ()
0 commit comments