MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / fillOperationDetail

Function fillOperationDetail

core/middleware/operation.go:203–225  ·  view source on GitHub ↗
(operationDic *operationJson, formatMap map[string]interface{})

Source from the content-addressed store, hash-verified

201}
202
203func fillOperationDetail(operationDic *operationJson, formatMap map[string]interface{}) {
204 for key, value := range formatMap {
205 if !strings.Contains(operationDic.FormatEN, "["+key+"]") {
206 continue
207 }
208 t := reflect.TypeOf(value)
209 if t == nil || (t.Kind() != reflect.Array && t.Kind() != reflect.Slice) {
210 operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", fmt.Sprintf("[%v]", value))
211 operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", fmt.Sprintf("[%v]", value))
212 continue
213 }
214
215 val := reflect.ValueOf(value)
216 length := val.Len()
217 elements := make([]string, 0, length)
218 for i := 0; i < length; i++ {
219 elements = append(elements, fmt.Sprintf("%v", val.Index(i).Interface()))
220 }
221 replaced := fmt.Sprintf("[%v]", strings.Join(elements, ","))
222 operationDic.FormatZH = strings.ReplaceAll(operationDic.FormatZH, "["+key+"]", replaced)
223 operationDic.FormatEN = strings.ReplaceAll(operationDic.FormatEN, "["+key+"]", replaced)
224 }
225}
226
227type operationJson struct {
228 API string `json:"api"`

Callers 1

OperationLogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected