Skip to content

Commit 935968f

Browse files
committed
add buildx plugin to e2e configuration directory
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 91371fe commit 935968f

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pkg/e2e/framework.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ var (
4444
// DockerComposeExecutableName is the OS dependent Docker CLI binary name
4545
DockerComposeExecutableName = "docker-" + compose.PluginName
4646

47-
// DockerScanExecutableName is the OS dependent Docker CLI binary name
47+
// DockerScanExecutableName is the OS dependent Docker Scan plugin binary name
4848
DockerScanExecutableName = "docker-scan"
4949

50+
// DockerBuildxExecutableName is the Os dependent Buildx plugin binary name
51+
DockerBuildxExecutableName = "docker-buildx"
52+
5053
// WindowsExecutableSuffix is the Windows executable suffix
5154
WindowsExecutableSuffix = ".exe"
5255
)
@@ -56,6 +59,7 @@ func init() {
5659
DockerExecutableName += WindowsExecutableSuffix
5760
DockerComposeExecutableName += WindowsExecutableSuffix
5861
DockerScanExecutableName += WindowsExecutableSuffix
62+
DockerBuildxExecutableName += WindowsExecutableSuffix
5963
}
6064
}
6165

@@ -133,8 +137,13 @@ func initializePlugins(t testing.TB, configDir string) {
133137
if os.IsNotExist(err) {
134138
t.Logf("WARNING: docker-compose cli-plugin not found")
135139
}
140+
buildxPlugin, err := findPluginExecutable(DockerBuildxExecutableName)
141+
if os.IsNotExist(err) {
142+
t.Logf("WARNING: docker-buildx cli-plugin not found")
143+
}
136144
if err == nil {
137145
CopyFile(t, composePlugin, filepath.Join(configDir, "cli-plugins", DockerComposeExecutableName))
146+
CopyFile(t, buildxPlugin, filepath.Join(configDir, "cli-plugins", DockerBuildxExecutableName))
138147
// We don't need a functional scan plugin, but a valid plugin binary
139148
CopyFile(t, composePlugin, filepath.Join(configDir, "cli-plugins", DockerScanExecutableName))
140149
}
@@ -166,6 +175,22 @@ func findExecutable(executableName string) (string, error) {
166175
return "", errors.Wrap(os.ErrNotExist, "executable not found")
167176
}
168177

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+
169194
// CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
170195
func CopyFile(t testing.TB, sourceFile string, destinationFile string) {
171196
t.Helper()

0 commit comments

Comments
 (0)