You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cron.go 740B

12345678910111213141516171819202122232425262728
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package setting
  4. import "reflect"
  5. // GetCronSettings maps the cron subsection to the provided config
  6. func GetCronSettings(name string, config interface{}) (interface{}, error) {
  7. if err := Cfg.Section("cron." + name).MapTo(config); err != nil {
  8. return config, err
  9. }
  10. typ := reflect.TypeOf(config).Elem()
  11. val := reflect.ValueOf(config).Elem()
  12. for i := 0; i < typ.NumField(); i++ {
  13. field := val.Field(i)
  14. tpField := typ.Field(i)
  15. if tpField.Type.Kind() == reflect.Struct && tpField.Anonymous {
  16. if err := Cfg.Section("cron." + name).MapTo(field.Addr().Interface()); err != nil {
  17. return config, err
  18. }
  19. }
  20. }
  21. return config, nil
  22. }