mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
33 lines
867 B
Go
33 lines
867 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import "reflect"
|
|
|
|
// GetCronSettings maps the cron subsection to the provided config
|
|
func GetCronSettings(name string, config any) (any, error) {
|
|
return getCronSettings(CfgProvider, name, config)
|
|
}
|
|
|
|
func getCronSettings(rootCfg ConfigProvider, name string, config any) (any, error) {
|
|
if err := rootCfg.Section("cron." + name).MapTo(config); err != nil {
|
|
return config, err
|
|
}
|
|
|
|
typ := reflect.TypeOf(config).Elem()
|
|
val := reflect.ValueOf(config).Elem()
|
|
|
|
for i := 0; i < typ.NumField(); i++ {
|
|
field := val.Field(i)
|
|
tpField := typ.Field(i)
|
|
if tpField.Type.Kind() == reflect.Struct && tpField.Anonymous {
|
|
if err := rootCfg.Section("cron." + name).MapTo(field.Addr().Interface()); err != nil {
|
|
return config, err
|
|
}
|
|
}
|
|
}
|
|
|
|
return config, nil
|
|
}
|