Browse Source

fix: 解决容器镜像推送失败的问题 (#4944)

pull/4954/head
ssongliu 7 months ago committed by GitHub
parent
commit
d5c75f4eee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 24
      backend/app/service/image.go

24
backend/app/service/image.go

@ -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,
@ -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 {

Loading…
Cancel
Save