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