feat: [CDE-549]: Handle no tag (#3140)

* feat: [CDE-549]: use --src-tls-verify
* feat: [CDE-549]: Handle no tag
This commit is contained in:
Vikyath Harekal 2024-12-10 09:46:48 +00:00 committed by Harness
parent 65a9253a9b
commit 93c1462fec

View File

@ -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]
}