github.com/koko1123/flow-go-1@v0.29.6/admin/commands/common/list_configs.go (about) 1 package common 2 3 import ( 4 "context" 5 6 "github.com/koko1123/flow-go-1/admin" 7 "github.com/koko1123/flow-go-1/admin/commands" 8 "github.com/koko1123/flow-go-1/module/updatable_configs" 9 ) 10 11 var _ commands.AdminCommand = (*ListConfigCommand)(nil) 12 13 // ListConfigCommand is an admin command which lists all config fields which may 14 // by dynamically modified via admin command. 15 type ListConfigCommand struct { 16 configs *updatable_configs.Manager 17 } 18 19 func NewListConfigCommand(configs *updatable_configs.Manager) *ListConfigCommand { 20 return &ListConfigCommand{ 21 configs: configs, 22 } 23 } 24 25 func (s *ListConfigCommand) Handler(_ context.Context, _ *admin.CommandRequest) (interface{}, error) { 26 fields := s.configs.AllFields() 27 28 // create a response 29 res := make(map[string]any, len(fields)) 30 for _, field := range fields { 31 res[field.Name] = map[string]any{ 32 "type": field.TypeName, 33 } 34 } 35 return res, nil 36 } 37 38 func (s *ListConfigCommand) Validator(req *admin.CommandRequest) error { 39 return nil 40 }