MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / saveTemplate

Function saveTemplate

initialization.go:112–136  ·  view source on GitHub ↗
(as map[string]*Access, key string)

Source from the content-addressed store, hash-verified

110}
111
112func saveTemplate(as map[string]*Access, key string) string {
113 out := make(map[string][]access.Access)
114
115 for _, a := range as {
116
117 out[a.Group] = append(out[a.Group], access.Access{
118 Name: a.Name,
119 CName: a.Cname,
120 Desc: a.Desc,
121 })
122 }
123 buf := &bytes.Buffer{}
124 err := yaml.NewEncoder(buf).Encode(out)
125 if err != nil {
126 log.Fatal(err)
127 return ""
128 }
129 filePath := fmt.Sprintf("access.%s.yml", key)
130 err = os.WriteFile(filePath, buf.Bytes(), 0666)
131 if err != nil {
132 log.Fatal(err)
133
134 }
135 return filePath
136}
137
138type Access struct {
139 Key string

Callers 1

doCheckFunction · 0.85

Calls 1

EncodeMethod · 0.80

Tested by

no test coverage detected