MCPcopy Index your code
hub / github.com/getsops/sops / valueFromPathAndLeaf

Function valueFromPathAndLeaf

sops.go:173–200  ·  view source on GitHub ↗
(path []interface{}, leaf interface{})

Source from the content-addressed store, hash-verified

171}
172
173func valueFromPathAndLeaf(path []interface{}, leaf interface{}) interface{} {
174 switch component := path[0].(type) {
175 case int:
176 if len(path) == 1 {
177 return []interface{}{
178 leaf,
179 }
180 }
181 return []interface{}{
182 valueFromPathAndLeaf(path[1:], leaf),
183 }
184 default:
185 if len(path) == 1 {
186 return TreeBranch{
187 TreeItem{
188 Key: component,
189 Value: leaf,
190 },
191 }
192 }
193 return TreeBranch{
194 TreeItem{
195 Key: component,
196 Value: valueFromPathAndLeaf(path[1:], leaf),
197 },
198 }
199 }
200}
201
202func set(branch interface{}, path []interface{}, value interface{}) (interface{}, bool) {
203 switch branch := branch.(type) {

Callers 1

setFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected