Skip to content

Commit

Permalink
including only copy correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkeshav27 authored and Egor Balakin committed Nov 15, 2023
1 parent b63d891 commit 46cb37c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions cmd/imagePushToRegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ func handleCredentialsForPrivateRegistries(dockerConfigJsonPath string, registry
return errors.Wrapf(err, "failed to read enhanced file '%v'", dockerConfigJsonPath)
}
} else if len(dockerConfigJsonPath) == 0 && len(registryURL) > 0 && len(password) > 0 && len(username) > 0 {
targetConfigJson, err := docker.CreateDockerConfigJSON(registryURL, username, password, "", "/crane/.docker/config.json", fileUtils)
targetConfigJson, err := docker.CreateDockerConfigJSON(registryURL, username, password, "", "~/.docker/config.json", fileUtils)
if err != nil {
return errors.Wrap(err, "failed to create new docker config json at /crane/.docker/config.json")
return errors.Wrap(err, "failed to create new docker config json at ~/.docker/config.json")
}

dockerConfig, err = fileUtils.FileRead(targetConfigJson)
if err != nil {
return errors.Wrapf(err, "failed to read new docker config file at /crane/.docker/config.json")
return errors.Wrapf(err, "failed to read new docker config file at ~/.docker/config.json")
}
}

if err := fileUtils.FileWrite("/crane/.docker/config.json", dockerConfig, 0644); err != nil {
return errors.Wrap(err, "failed to write file '/crane/.docker/config.json'")
if err := fileUtils.FileWrite("~/.docker/config.json", dockerConfig, 0644); err != nil {
return errors.Wrap(err, "failed to write file '~/.docker/config.json'")
}
return nil
}
Expand All @@ -151,7 +151,7 @@ func pushLocalImageToTargetRegistry(localDockerImagePath string, targetRegistryU
}

func copyImage(sourceRegistry string, targetRegistry string) error {

docker.CopyImage(sourceRegistry, targetRegistry)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func ImageListWithFilePath(imageName string, excludes []string, trimDir string,
return imageList, nil
}

func (c *Client) CopyImage(src string, dest string) error {
func CopyImage(src string, dest string) error {
crane.Copy(src, dest)
return nil
}
Expand Down

0 comments on commit 46cb37c

Please sign in to comment.