fix: backup storage edit external url (#23916)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2025-12-09 19:43:54 +08:00
committed by GitHub
co-authored by Qiu Jian
parent eca000b52e
commit 16f15ac0fc
+14
View File
@@ -96,6 +96,12 @@ func (bs *SBackupStorageManager) ValidateCreateData(ctx context.Context, userCre
if input.ObjectSecret == "" {
return input, httperrors.NewInputParameterError("object_secret is required when storage type is object")
}
if len(input.ObjectBucketUrlExt) > 0 {
_, err := url.Parse(input.ObjectBucketUrlExt)
if err != nil {
return input, httperrors.NewInputParameterError("invalid object_bucket_url_ext %s: %s", input.ObjectBucketUrlExt, err)
}
}
}
return input, nil
}
@@ -117,6 +123,9 @@ func (bs *SBackupStorage) CustomizeCreate(ctx context.Context, userCred mcclient
ObjectBucketUrl: input.ObjectBucketUrl,
ObjectAccessKey: input.ObjectAccessKey,
ObjectSecret: input.ObjectSecret,
ObjectSignVer: input.ObjectSignVer,
ObjectBucketUrlExt: input.ObjectBucketUrlExt,
}
return bs.SEnabledStatusInfrasResourceBase.CustomizeCreate(ctx, userCred, ownerId, query, data)
}
@@ -175,6 +184,7 @@ func (bs *SBackupStorage) getMoreDetails(ctx context.Context, out api.BackupStor
out.ObjectBucketUrl = bs.AccessInfo.ObjectBucketUrl
out.ObjectAccessKey = bs.AccessInfo.ObjectAccessKey
out.ObjectSignVer = bs.AccessInfo.ObjectSignVer
out.ObjectBucketUrlExt = bs.AccessInfo.ObjectBucketUrlExt
// should not return secret
out.ObjectSecret = "" // bs.AccessInfo.ObjectSecret
return out
@@ -326,6 +336,10 @@ func (bs *SBackupStorage) PostUpdate(ctx context.Context, userCred mcclient.Toke
accessInfo.ObjectSignVer = input.ObjectSignVer
accessInfoChanged = true
}
if len(input.ObjectBucketUrlExt) > 0 {
accessInfo.ObjectBucketUrlExt = input.ObjectBucketUrlExt
accessInfoChanged = true
}
}
if accessInfoChanged {
_, err = db.Update(bs, func() error {