Skip to content

Commit 0bf7988

Browse files
Horiodinodr-housemd
authored andcommitted
fix: --dest-creds cant be nil
Signed-off-by: Horiodino <holiodin@gmail.com>
1 parent 601cd7e commit 0bf7988

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/oci/skopeo.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ func LoadPodman(dir, imageName string) error {
3333

3434
// Push image to registry
3535
func Push(dir, imageName string, destcreds string, digestPath string) error {
36+
skoepoCmd := []string{"nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:" + dir}
37+
3638
var cmd *exec.Cmd
3739
if digestPath != "" {
38-
cmd = exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName+"@@unknown-digest@@", "--digestfile="+digestPath, "--dest-creds", destcreds)
39-
40+
skoepoCmd = append(skoepoCmd, "docker://"+imageName+"@@unknown-digest@@", "--digestfile", digestPath)
4041
} else {
41-
cmd = exec.Command("nix", "run", "nixpkgs#skopeo", "--", "copy", "--insecure-policy", "dir:"+dir, "docker://"+imageName, "--dest-creds", destcreds)
42+
skoepoCmd = append(skoepoCmd, "docker://"+imageName)
4243
}
44+
if destcreds != "" {
45+
skoepoCmd = append(skoepoCmd, "--dest-creds", destcreds)
46+
}
47+
48+
cmd = exec.Command(skoepoCmd[0], skoepoCmd[1:]...)
4349
cmd.Stdout = os.Stdout
4450
cmd.Stderr = os.Stderr
4551
err := cmd.Run()

0 commit comments

Comments
 (0)