@@ -133,17 +133,19 @@ func initializePlugins(t testing.TB, configDir string) {
133
133
134
134
require .NoError (t , os .MkdirAll (filepath .Join (configDir , "cli-plugins" ), 0o755 ),
135
135
"Failed to create cli-plugins directory" )
136
- composePlugin , err := findExecutable (DockerComposeExecutableName )
136
+ composePlugin , err := findExecutable (t , DockerComposeExecutableName )
137
137
if err != nil {
138
138
t .Errorf ("WARNING: docker-compose cli-plugin not found %s" , err .Error ())
139
139
}
140
- buildxPlugin , err := findPluginExecutable (DockerBuildxExecutableName )
141
- if os .IsNotExist (err ) {
142
- t .Logf ("WARNING: docker-buildx cli-plugin not found" )
143
- }
140
+
144
141
if err == nil {
145
142
CopyFile (t , composePlugin , filepath .Join (configDir , "cli-plugins" , DockerComposeExecutableName ))
146
- CopyFile (t , buildxPlugin , filepath .Join (configDir , "cli-plugins" , DockerBuildxExecutableName ))
143
+ buildxPlugin , err := findPluginExecutable (DockerBuildxExecutableName )
144
+ if err != nil {
145
+ t .Logf ("WARNING: docker-buildx cli-plugin not found, using default buildx installation." )
146
+ } else {
147
+ CopyFile (t , buildxPlugin , filepath .Join (configDir , "cli-plugins" , DockerBuildxExecutableName ))
148
+ }
147
149
// We don't need a functional scan plugin, but a valid plugin binary
148
150
CopyFile (t , composePlugin , filepath .Join (configDir , "cli-plugins" , DockerScanExecutableName ))
149
151
}
@@ -158,19 +160,24 @@ func dirContents(dir string) []string {
158
160
return res
159
161
}
160
162
161
- func findExecutable (executableName string ) (string , error ) {
163
+ func findExecutable (t testing. TB , executableName string ) (string , error ) {
162
164
filename , err := os .Getwd ()
163
165
if err != nil {
164
166
return "" , err
165
167
}
168
+ t .Logf ("Current dir %s" , filename )
166
169
root := filepath .Join (filepath .Dir (filename ), ".." )
170
+ t .Logf ("Root dir %s" , root )
171
+
167
172
buildPath := filepath .Join (root , "bin" , "build" )
168
173
169
174
bin , err := filepath .Abs (filepath .Join (buildPath , executableName ))
170
175
if err != nil {
176
+ t .Errorf ("Error finding compose binary %s" , err .Error ())
171
177
return "" , err
172
178
}
173
179
180
+ t .Logf ("binary path %s" , bin )
174
181
if _ , err := os .Stat (bin ); err == nil {
175
182
return bin , nil
176
183
}
@@ -197,19 +204,28 @@ func findPluginExecutable(pluginExecutableName string) (string, error) {
197
204
// CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
198
205
func CopyFile (t testing.TB , sourceFile string , destinationFile string ) {
199
206
t .Helper ()
207
+ t .Logf ("copy %s to %s" , sourceFile , destinationFile )
200
208
201
209
src , err := os .Open (sourceFile )
202
210
require .NoError (t , err , "Failed to open source file: %s" )
203
211
//nolint:errcheck
204
212
defer src .Close ()
213
+ t .Logf ("Source file opened %s " , src .Name ())
205
214
206
215
dst , err := os .OpenFile (destinationFile , os .O_RDWR | os .O_CREATE | os .O_TRUNC , 0o755 )
207
216
require .NoError (t , err , "Failed to open destination file: %s" , destinationFile )
208
217
//nolint:errcheck
209
218
defer dst .Close ()
219
+ t .Logf ("Destination file opened %s " , dst .Name ())
210
220
211
221
_ , err = io .Copy (dst , src )
212
222
require .NoError (t , err , "Failed to copy file: %s" , sourceFile )
223
+ t .Logf ("File copied? %s " , err )
224
+ fileStat , err := dst .Stat ()
225
+ if err != nil {
226
+ t .Logf ("Can't get file stat %s " , err )
227
+ }
228
+ t .Logf ("File stat: %+v" , fileStat )
213
229
}
214
230
215
231
// BaseEnvironment provides the minimal environment variables used across all
@@ -330,7 +346,7 @@ func ComposeStandalonePath(t testing.TB) string {
330
346
if ! composeStandaloneMode {
331
347
require .Fail (t , "Not running in standalone mode" )
332
348
}
333
- composeBinary , err := findExecutable (DockerComposeExecutableName )
349
+ composeBinary , err := findExecutable (t , DockerComposeExecutableName )
334
350
require .NoError (t , err , "Could not find standalone Compose binary (%q)" ,
335
351
DockerComposeExecutableName )
336
352
return composeBinary
0 commit comments