MCPcopy
hub / github.com/getsops/sops / walkValue

Method walkValue

sops.go:339–366  ·  view source on GitHub ↗
(in interface{}, path []string, commentsStack [][]string, onLeaves func(in interface{}, path []string, commentsStack [][]string) (interface{}, error))

Source from the content-addressed store, hash-verified

337}
338
339func (branch TreeBranch) walkValue(in interface{}, path []string, commentsStack [][]string, onLeaves func(in interface{}, path []string, commentsStack [][]string) (interface{}, error)) (interface{}, error) {
340 switch in := in.(type) {
341 case string:
342 return onLeaves(in, path, commentsStack)
343 case []byte:
344 return onLeaves(string(in), path, commentsStack)
345 case int:
346 return onLeaves(in, path, commentsStack)
347 case bool:
348 return onLeaves(in, path, commentsStack)
349 case float64:
350 return onLeaves(in, path, commentsStack)
351 case time.Time:
352 return onLeaves(in, path, commentsStack)
353 case Comment:
354 return onLeaves(in, path, commentsStack)
355 case TreeBranch:
356 return branch.walkBranch(in, path, commentsStack, onLeaves)
357 case []interface{}:
358 return branch.walkSlice(in, path, commentsStack, onLeaves)
359 case nil:
360 // the value returned remains the same since it doesn't make
361 // sense to encrypt or decrypt a nil value
362 return nil, nil
363 default:
364 return nil, fmt.Errorf("Cannot walk value, unknown type: %T", in)
365 }
366}
367
368func (branch TreeBranch) walkSlice(in []interface{}, path []string, commentsStack [][]string, onLeaves func(in interface{}, path []string, commentsStack [][]string) (interface{}, error)) ([]interface{}, error) {
369 // Because append returns a new slice, the original stack is not changed.

Callers 2

walkSliceMethod · 0.95
walkBranchMethod · 0.95

Calls 2

walkBranchMethod · 0.95
walkSliceMethod · 0.95

Tested by

no test coverage detected