Skip to content

Commit

Permalink
fix: 解决容器镜像推送失败的问题 (#4944)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu committed May 13, 2024
1 parent de93f84 commit d1d60d8
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions backend/app/service/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
if err != nil {
return "", err
}
options := types.ImagePullOptions{}
options := image.PullOptions{}
if repo.Auth {
authConfig := registry.AuthConfig{
Username: repo.Username,
Expand Down Expand Up @@ -373,19 +373,17 @@ func (u *ImageService) ImagePush(req dto.ImagePush) (string, error) {
if err != nil {
return "", err
}
options := types.ImagePushOptions{}
if repo.Auth {
authConfig := registry.AuthConfig{
Username: repo.Username,
Password: repo.Password,
}
encodedJSON, err := json.Marshal(authConfig)
if err != nil {
return "", err
}
authStr := base64.URLEncoding.EncodeToString(encodedJSON)
options.RegistryAuth = authStr
options := image.PushOptions{All: true}
authConfig := registry.AuthConfig{
Username: repo.Username,
Password: repo.Password,
}
encodedJSON, err := json.Marshal(authConfig)
if err != nil {
return "", err
}
authStr := base64.URLEncoding.EncodeToString(encodedJSON)
options.RegistryAuth = authStr
newName := fmt.Sprintf("%s/%s", repo.DownloadUrl, req.Name)
if newName != req.TagName {
if err := client.ImageTag(context.TODO(), req.TagName, newName); err != nil {
Expand Down

0 comments on commit d1d60d8

Please sign in to comment.