From 93c1462fecddcd1367e06e35cfea729a35ab009c Mon Sep 17 00:00:00 2001 From: Vikyath Harekal Date: Tue, 10 Dec 2024 09:46:48 +0000 Subject: [PATCH] feat: [CDE-549]: Handle no tag (#3140) * feat: [CDE-549]: use --src-tls-verify * feat: [CDE-549]: Handle no tag --- .../container/devcontainer_container_utils.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/gitspace/orchestrator/container/devcontainer_container_utils.go b/app/gitspace/orchestrator/container/devcontainer_container_utils.go index c99844d37..6fc91a8c9 100644 --- a/app/gitspace/orchestrator/container/devcontainer_container_utils.go +++ b/app/gitspace/orchestrator/container/devcontainer_container_utils.go @@ -369,7 +369,7 @@ func CopyImage( // Build skopeo command platform := getPlatform(runArgsMap) - args := []string{"copy", "--debug", "--tls-verify=false"} + args := []string{"copy", "--debug", "--src-tls-verify=false"} if platform != "" { args = append(args, "--override-os", platform) @@ -385,8 +385,8 @@ func CopyImage( // Source and destination source := "docker://" + imageName - // TODO: if imageName doesn't have tag, use latest in destination - destination := "docker-daemon:" + imageName + image, tag := splitImageName(imageName) + destination := "docker-daemon:" + image + ":" + tag args = append(args, source, destination) cmd := exec.CommandContext(ctx, "skopeo", args...) @@ -628,3 +628,12 @@ func buildImagePullOptions( return pullOpts, nil } + +func splitImageName(image string) (name, tag string) { + parts := strings.Split(image, ":") + if len(parts) == 1 { + // If there's no tag, default to "latest" + return parts[0], "latest" + } + return parts[0], parts[1] +}