MCPcopy Create free account
hub / github.com/ddev/ddev / DownloadDockerCompose

Function DownloadDockerCompose

pkg/dockerutil/docker_compose.go:259–288  ·  view source on GitHub ↗

DownloadDockerCompose gets the docker-compose binary and puts it into ~/.ddev/.bin

()

Source from the content-addressed store, hash-verified

257// DownloadDockerCompose gets the docker-compose binary and puts it into
258// ~/.ddev/.bin
259func DownloadDockerCompose() error {
260 globalBinDir := globalconfig.GetDDEVBinDir()
261 destFile, _ := globalconfig.GetDockerComposePath()
262
263 composeURL, shasumURL, err := dockerComposeDownloadLink()
264 if err != nil {
265 return err
266 }
267 util.Debug("Downloading '%s' to '%s' ...", composeURL, destFile)
268
269 _ = os.Remove(destFile)
270
271 _ = os.MkdirAll(globalBinDir, 0777)
272 err = util.DownloadFile(destFile, composeURL, globalconfig.IsInteractive(), shasumURL)
273 if err != nil {
274 _ = os.Remove(destFile)
275 return err
276 }
277 output.UserErr.Printf("Download complete.")
278
279 // Remove the cached DockerComposeVersion
280 globalconfig.DockerComposeVersion = ""
281
282 err = util.Chmod(destFile, 0755)
283 if err != nil {
284 return err
285 }
286
287 return nil
288}
289
290// dockerComposeDownloadLink returns the URL and SHASUM-file link for docker-compose
291func dockerComposeDownloadLink() (composeURL string, shasumURL string, err error) {

Callers 1

Calls 7

GetDDEVBinDirFunction · 0.92
GetDockerComposePathFunction · 0.92
DebugFunction · 0.92
DownloadFileFunction · 0.92
IsInteractiveFunction · 0.92
ChmodFunction · 0.92

Tested by

no test coverage detected