@@ -67,14 +67,14 @@ func groupByKeys(entries []*RuntimeContainer, key string) []string {
67
67
}
68
68
69
69
// Generalized where function
70
- func generalizedWhere (entries interface {}, key string , test func (interface {}) bool ) (interface {}, error ) {
70
+ func generalizedWhere (funcName string , entries interface {}, key string , test func (interface {}) bool ) (interface {}, error ) {
71
71
entriesVal := reflect .ValueOf (entries )
72
72
73
73
switch entriesVal .Kind () {
74
74
case reflect .Array , reflect .Slice :
75
75
break
76
76
default :
77
- return nil , fmt .Errorf ("Must pass an array or slice to 'where '; received %v" , entries )
77
+ return nil , fmt .Errorf ("Must pass an array or slice to '%s '; received %v" , funcName , entries )
78
78
}
79
79
80
80
selection := make ([]interface {}, 0 )
@@ -92,28 +92,28 @@ func generalizedWhere(entries interface{}, key string, test func(interface{}) bo
92
92
93
93
// selects entries based on key
94
94
func where (entries interface {}, key string , cmp interface {}) (interface {}, error ) {
95
- return generalizedWhere (entries , key , func (value interface {}) bool {
95
+ return generalizedWhere ("where" , entries , key , func (value interface {}) bool {
96
96
return reflect .DeepEqual (value , cmp )
97
97
})
98
98
}
99
99
100
100
// selects entries where a key exists
101
101
func whereExist (entries interface {}, key string ) (interface {}, error ) {
102
- return generalizedWhere (entries , key , func (value interface {}) bool {
102
+ return generalizedWhere ("whereExist" , entries , key , func (value interface {}) bool {
103
103
return value != nil
104
104
})
105
105
}
106
106
107
107
// selects entries where a key does not exist
108
108
func whereNotExist (entries interface {}, key string ) (interface {}, error ) {
109
- return generalizedWhere (entries , key , func (value interface {}) bool {
109
+ return generalizedWhere ("whereNotExist" , entries , key , func (value interface {}) bool {
110
110
return value == nil
111
111
})
112
112
}
113
113
114
114
// selects entries based on key. Assumes key is delimited and breaks it apart before comparing
115
115
func whereAny (entries interface {}, key , sep string , cmp []string ) (interface {}, error ) {
116
- return generalizedWhere (entries , key , func (value interface {}) bool {
116
+ return generalizedWhere ("whereAny" , entries , key , func (value interface {}) bool {
117
117
if value == nil {
118
118
return false
119
119
} else {
@@ -126,7 +126,7 @@ func whereAny(entries interface{}, key, sep string, cmp []string) (interface{},
126
126
// selects entries based on key. Assumes key is delimited and breaks it apart before comparing
127
127
func whereAll (entries interface {}, key , sep string , cmp []string ) (interface {}, error ) {
128
128
req_count := len (cmp )
129
- return generalizedWhere (entries , key , func (value interface {}) bool {
129
+ return generalizedWhere ("whereAll" , entries , key , func (value interface {}) bool {
130
130
if value == nil {
131
131
return false
132
132
} else {
0 commit comments