From 3406aa52de81738119a61425d9c088430145e5b9 Mon Sep 17 00:00:00 2001 From: Horiodino Date: Mon, 5 Aug 2024 15:22:56 +0530 Subject: [PATCH] fix: --dest-creds cant be nil Signed-off-by: Horiodino --- pkg/oci/skopeo.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/oci/skopeo.go b/pkg/oci/skopeo.go index 87b470ce..a9d5bf22 100644 --- a/pkg/oci/skopeo.go +++ b/pkg/oci/skopeo.go @@ -34,11 +34,14 @@ func LoadPodman(dir, imageName string) error { // Push image to registry func Push(dir, imageName string, destcreds string, digestPath string) error { var cmd *exec.Cmd - if digestPath != "" { + if digestPath != "" && destcreds != "" { cmd = exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName+"@@unknown-digest@@", "--digestfile="+digestPath, "--dest-creds", destcreds) - - } else { + } else if digestPath != "" && destcreds == "" { + cmd = exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName+"@@unknown-digest@@", "--digestfile="+digestPath) + } else if destcreds != "" && digestPath == "" { cmd = exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName, "--dest-creds", destcreds) + } else { + cmd = exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName) } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr