问题(log.astx.club/storage):
1. 编辑存储时 Access Key / Secret Key 都是空的,点「测试连接」提示
请先填写 Bucket 与 Access Key / Secret Key,无法测试也无法保存;
2. 提示"桶不存在,已自动创建"但疑似没有真正创建;
3. 测试失败提示用 toast 弹到右下角,不在弹框内。
修复:
1. models/storage.go Sanitized() 返回 accessKey / secretKey 明文
(内网运维工具,管理员需要在编辑弹框里看到并测试连接;脱敏会导致
编辑时字段为空、校验失败)
2. 前端 StorageConfig 类型补 accessKey / secretKey 字段;
编辑弹框打开时回填这两个字段(原来只有 secretKey 且强制置空);
Secret Key 标签去掉「留空保持不变」
3. services/storage_check.go 建桶后二次 ListBuckets 校验:
不同对象存储 CreateBucket 语义不同(腾讯云 COS 要求桶名放 Host、
路径为 /),直接 PUT /<bucket> 可能返回 200 但未真正创建。
现在创建后重新列举桶,找不到就报"创建后校验失败"并提示检查
Endpoint / Region / 桶名(COS 需带 APPID)
4. 前端「请先填写 Bucket 与 Access Key / Secret Key」改为在弹框内
testResult 区域显示(原来 toast 弹右下角)
镜像:lghost/lokistack:latest + v0.1 = sha256:6b6cc9769e79
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
type StorageConfig struct {
|
|
ID uint `json:"id"`
|
|
Name string `json:"name"`
|
|
StorageType string `json:"storageType"`
|
|
Endpoint string `json:"endpoint"`
|
|
Bucket string `json:"bucket"`
|
|
Region string `json:"region"`
|
|
AccessKey string `json:"accessKey"`
|
|
SecretKey string `json:"secretKey"`
|
|
PathPrefix string `json:"pathPrefix"`
|
|
Insecure bool `json:"insecure"`
|
|
IsDefault bool `json:"isDefault"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
func (s *StorageConfig) Sanitized() map[string]interface{} {
|
|
return map[string]interface{}{
|
|
"id": s.ID,
|
|
"name": s.Name,
|
|
"storageType": s.StorageType,
|
|
"endpoint": s.Endpoint,
|
|
"bucket": s.Bucket,
|
|
"region": s.Region,
|
|
// accessKey / secretKey 明文返回:本平台为内网运维工具,管理员需要在
|
|
// 编辑弹框里看到并「测试连接」,脱敏会导致编辑时字段为空无法保存/测试。
|
|
"accessKey": s.AccessKey,
|
|
"secretKey": s.SecretKey,
|
|
"pathPrefix": s.PathPrefix,
|
|
"insecure": s.Insecure,
|
|
"isDefault": s.IsDefault,
|
|
"hasSecretKey": s.SecretKey != "",
|
|
"createdAt": s.CreatedAt,
|
|
"updatedAt": s.UpdatedAt,
|
|
}
|
|
}
|