MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / init

Function init

resources/permit/template.go:31–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31func init() {
32 autowire.Auto[permit.IPermitInitialize](func() reflect.Value {
33 v := new(imlPermitData)
34 permitData := make(map[string]map[string][]string)
35 err := yaml.Unmarshal(templateData, permitData)
36 if err != nil {
37 log.Fatal("read permit initialize data :", err)
38 }
39 v.data = make(map[string]map[string][]string)
40 for group, grants := range permitData {
41 domain, has := domainForGroup[group]
42 if !has {
43 continue
44 }
45
46 if _, h := v.data[domain]; !h {
47 v.data[domain] = make(map[string][]string)
48 }
49
50 for access, ts := range grants {
51 v.data[domain][fmt.Sprintf("%s.%s", group, access)] = utils.SliceToSlice(ts, func(s string) string {
52 return permit_type.Special.KeyOf(s)
53 })
54 }
55 }
56
57 return reflect.ValueOf(v)
58 })
59}
60
61var (
62 domainForGroup = map[string]string{

Callers

nothing calls this directly

Calls 1

KeyOfMethod · 0.80

Tested by

no test coverage detected