mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 12:01:15 +02:00
Introduce service accounts and bootstrap tokens (#22)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package structpath
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Lookup(target interface{}, path []string) (s string, ok bool) {
|
||||
currentValue := reflect.ValueOf(target)
|
||||
|
||||
for _, pathElement := range path {
|
||||
pathElement := pathElement
|
||||
|
||||
field := currentValue.FieldByNameFunc(func(fieldName string) bool {
|
||||
return strings.EqualFold(fieldName, pathElement)
|
||||
})
|
||||
|
||||
if !field.IsValid() {
|
||||
return "", false
|
||||
}
|
||||
|
||||
currentValue = field
|
||||
}
|
||||
|
||||
result, ok := currentValue.Interface().(string)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
|
||||
return result, true
|
||||
}
|
||||
Reference in New Issue
Block a user