CI 测试 / go vet + go test (push) Successful in 49s
- 全项目版本号统一:v3.x 迭代号(26.9/26.9/26.9/26.9 及裸 v2/v3)→ 26.9, 覆盖 Go 注释 / 文档 / openapi.yaml / README×4 / 前端源码(80+ 处) - v31_test.go 更名 custom_code_test.go;TestV2AccessorDefaults → TestKVAccessorDefaults - docs/api/00-overview.md 更新日志合并为单条 26.9 条目(修复错位拼接) - .goreleaser.yaml 头部注释与实际一致(Pro 2.18.1 / GITEA_TOKEN / semver tag 要求) - CI:release-image.yml → ci.yml,仅保留 vet+test 门禁; 镜像发布移交 GoReleaser Pro(原 build-push 的 tag 校验与 26.9 版本方案冲突,历史 9 次失败) - 前端重建:server/web/dist 与 web-embed 同步(docs 文案嵌入更新)
88 lines
3.5 KiB
Go
88 lines
3.5 KiB
Go
// Package settings — schema.go:26.9 配置键 schema 常量与元数据表。
|
||
//
|
||
// 键名常量的单一事实来源在 internal/config/schema.go(defaults() 需引用);
|
||
// 本文件 re-export 供 API/管理层使用,并提供「键名/类型/默认值」全量表,
|
||
// 供管理端设置页与文档生成(t4)对齐。新增键必须同步:
|
||
// 1. config/schema.go 键名与边界常量
|
||
// 2. config/config.go defaults() 默认值
|
||
// 3. 本文件 KVSchema() 元数据行
|
||
// 4. schema 同步测试(config schema_test / settings schema_test)
|
||
package settings
|
||
|
||
import "fileshare/internal/config"
|
||
|
||
// —— 键名 re-export(与 config 包保持同一字符串,避免魔法值散落)——
|
||
const (
|
||
// 需求 ① 背景图
|
||
KeyBackground = config.KeyBackground
|
||
KeyBackgroundURL = config.KeyBackgroundURL
|
||
// 需求 ② 页脚
|
||
KeyFooterText = config.KeyFooterText
|
||
KeyFooterBeian = config.KeyFooterBeian
|
||
// 需求 ③ 系统通知
|
||
KeyNotifyEnabled = config.KeyNotifyEnabled
|
||
KeyNotifyTitle = config.KeyNotifyTitle
|
||
KeyNotifyContent = config.KeyNotifyContent
|
||
// 需求 ④ 保存策略与上传频率限制
|
||
KeyMaxSaveSeconds = config.KeyMaxSaveSeconds
|
||
KeyMaxSaveCount = config.KeyMaxSaveCount
|
||
KeyExpireStyle = config.KeyExpireStyle
|
||
KeyUploadCount = config.KeyUploadCount
|
||
KeyUploadMinute = config.KeyUploadMinute
|
||
// 需求 ④⑩ 存储策略
|
||
KeyUploadSize = config.KeyUploadSize
|
||
KeyMaxFileSize = config.KeyMaxFileSize
|
||
KeyAllowedTypes = config.KeyAllowedTypes
|
||
KeyStorageLimit = config.KeyStorageLimit
|
||
KeyOpenUpload = config.KeyOpenUpload
|
||
// 26.9 存储引擎
|
||
KeyStorageEngine = config.KeyStorageEngine
|
||
)
|
||
|
||
// —— 取值边界 re-export ——
|
||
const (
|
||
MaxSaveSecondsMax = config.MaxSaveSecondsMax // 最长保存秒数上限(365 天)
|
||
MaxSaveCountMax = config.MaxSaveCountMax // 保存次数上限
|
||
MaxFileSizeMax = config.MaxFileSizeMax // 单文件大小上限(10 GiB)
|
||
BackgroundURLMaxLen = config.BackgroundURLMaxLen // 背景图 URL 长度上限
|
||
FooterTextMaxLen = config.FooterTextMaxLen // 页脚内容长度上限
|
||
FooterBeianMaxLen = config.FooterBeianMaxLen // 备案号长度上限
|
||
NotifyTitleMaxLen = config.NotifyTitleMaxLen // 通知标题长度上限
|
||
NotifyContentMaxLen = config.NotifyContentMaxLen // 通知内容长度上限
|
||
)
|
||
|
||
// 敏感键:不允许出现在管理端 config get 下发/前端可见集合中(双模式下一致生效)。
|
||
// 26.9:引擎凭据(webdav_password/s3_secret_access_key/aws_session_token)加入敏感集——
|
||
// 管理端 get 返回掩码占位,update 时空串/掩码=不修改;公开 config 永不下发。
|
||
var SensitiveKeys = []string{
|
||
"admin_token", "jwt_secret",
|
||
"webdav_password", "s3_secret_access_key", "aws_session_token",
|
||
}
|
||
|
||
// SensitiveMaskValue 敏感键掩码占位(管理端 get 展示用)。
|
||
const SensitiveMaskValue = "******"
|
||
|
||
// IsSensitiveKey 判断键是否为敏感键(config get 必须屏蔽)。
|
||
func IsSensitiveKey(key string) bool {
|
||
for _, k := range SensitiveKeys {
|
||
if k == key {
|
||
return true
|
||
}
|
||
}
|
||
return false
|
||
}
|
||
|
||
// KVSchema 返回 26.9 全量配置键元数据(键名/类型/默认值/边界/说明)。
|
||
// 默认值必须与 config defaults() 一致(schema 同步测试保证)。
|
||
func KVSchema() []config.KVSchemaEntry { return config.KVSchema() }
|
||
|
||
// KVSchemaByKey 以键名为索引查看 schema;未知键返回 nil。
|
||
func KVSchemaByKey(key string) *config.KVSchemaEntry {
|
||
for i := range config.KVSchema() {
|
||
if config.KVSchema()[i].Key == key {
|
||
return &config.KVSchema()[i]
|
||
}
|
||
}
|
||
return nil
|
||
}
|