loading up the forgejo repo on tangled to test page performance
1// Copyright 2019 The Gitea Authors. All rights reserved.
2// SPDX-License-Identifier: MIT
3
4package setting
5
6import "reflect"
7
8// GetCronSettings maps the cron subsection to the provided config
9func GetCronSettings(name string, config any) (any, error) {
10 return getCronSettings(CfgProvider, name, config)
11}
12
13func getCronSettings(rootCfg ConfigProvider, name string, config any) (any, error) {
14 if err := rootCfg.Section("cron." + name).MapTo(config); err != nil {
15 return config, err
16 }
17
18 typ := reflect.TypeOf(config).Elem()
19 val := reflect.ValueOf(config).Elem()
20
21 for i := 0; i < typ.NumField(); i++ {
22 field := val.Field(i)
23 tpField := typ.Field(i)
24 if tpField.Type.Kind() == reflect.Struct && tpField.Anonymous {
25 if err := rootCfg.Section("cron." + name).MapTo(field.Addr().Interface()); err != nil {
26 return config, err
27 }
28 }
29 }
30
31 return config, nil
32}