优化
This commit is contained in:
@@ -66,6 +66,16 @@ func (r *initializationRepo) ConfigurationJSON() (json.RawMessage, error) {
|
||||
}
|
||||
}
|
||||
maskDataSecrets(dataConfig)
|
||||
safeAdmin := cloneAdminConfig(adminConfig)
|
||||
if safeAdmin != nil {
|
||||
if safeAdmin.Jwt != nil {
|
||||
safeAdmin.Jwt.SigningKey = "******"
|
||||
}
|
||||
if safeAdmin.Email != nil {
|
||||
safeAdmin.Email.Secret = "******"
|
||||
}
|
||||
maskStorageSecrets(safeAdmin.Storage)
|
||||
}
|
||||
dataMap := map[string]any{}
|
||||
if dataConfig != nil {
|
||||
raw, err := protojson.MarshalOptions{UseProtoNames: true}.Marshal(dataConfig)
|
||||
@@ -76,7 +86,9 @@ func (r *initializationRepo) ConfigurationJSON() (json.RawMessage, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return json.Marshal(map[string]any{"config": map[string]any{"admin": admin, "email": email, "data": dataMap}})
|
||||
config := gvaConfiguration(dataConfig, safeAdmin)
|
||||
config["admin"], config["email"], config["data"] = admin, email, dataMap
|
||||
return json.Marshal(map[string]any{"config": config})
|
||||
}
|
||||
|
||||
func (r *initializationRepo) SaveConfigurationJSON(ctx context.Context, raw json.RawMessage) error {
|
||||
@@ -86,6 +98,9 @@ func (r *initializationRepo) SaveConfigurationJSON(ctx context.Context, raw json
|
||||
}
|
||||
nextData := cloneDataConfig(currentData)
|
||||
nextAdmin := proto.Clone(currentAdmin).(*conf.AdminBackend)
|
||||
if err := applyGVAConfiguration(raw, nextData, nextAdmin); err != nil {
|
||||
return err
|
||||
}
|
||||
var value configurationEnvelope
|
||||
if err := json.Unmarshal(raw, &value); err != nil {
|
||||
return err
|
||||
@@ -154,6 +169,13 @@ func cloneDataConfig(value *conf.Data) *conf.Data {
|
||||
return proto.Clone(value).(*conf.Data)
|
||||
}
|
||||
|
||||
func cloneAdminConfig(value *conf.AdminBackend) *conf.AdminBackend {
|
||||
if value == nil {
|
||||
return &conf.AdminBackend{}
|
||||
}
|
||||
return proto.Clone(value).(*conf.AdminBackend)
|
||||
}
|
||||
|
||||
func refreshDatabaseSources(value *conf.Data) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
@@ -222,6 +244,11 @@ func applyDataPatch(target, patch *conf.Data) {
|
||||
func applyAdminPatch(target, patch *conf.AdminBackend) {
|
||||
target.RouterPrefix = patch.RouterPrefix
|
||||
if patch.System != nil {
|
||||
if target.System != nil {
|
||||
patch.System.Addr = target.System.Addr
|
||||
patch.System.IplimitCount = target.System.IplimitCount
|
||||
patch.System.IplimitTime = target.System.IplimitTime
|
||||
}
|
||||
target.System = patch.System
|
||||
}
|
||||
if patch.Jwt != nil {
|
||||
@@ -234,6 +261,9 @@ func applyAdminPatch(target, patch *conf.AdminBackend) {
|
||||
target.Local = patch.Local
|
||||
}
|
||||
if patch.Media != nil {
|
||||
if patch.Media.ChunkDir == "" && target.Media != nil {
|
||||
patch.Media.ChunkDir = target.Media.ChunkDir
|
||||
}
|
||||
target.Media = patch.Media
|
||||
}
|
||||
if patch.Storage != nil {
|
||||
|
||||
Reference in New Issue
Block a user