Skip to content

Commit bcddaab

Browse files
committed
Rename where* template funcs
* whereSomeMatch -> whereAny * whereRequires -> whereAll
1 parent bbdeeb9 commit bcddaab

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

template.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func where(entries []*RuntimeContainer, key string, cmp string) []*RuntimeContai
7878
}
7979

8080
// selects entries based on key. Assumes key is delimited and breaks it apart before comparing
81-
func whereSomeMatch(entries []*RuntimeContainer, key, sep string, cmp []string) []*RuntimeContainer {
81+
func whereAny(entries []*RuntimeContainer, key, sep string, cmp []string) []*RuntimeContainer {
8282
selection := []*RuntimeContainer{}
8383
for _, v := range entries {
8484
value := deepGet(*v, key)
@@ -93,7 +93,7 @@ func whereSomeMatch(entries []*RuntimeContainer, key, sep string, cmp []string)
9393
}
9494

9595
// selects entries based on key. Assumes key is delimited and breaks it apart before comparing
96-
func whereRequires(entries []*RuntimeContainer, key, sep string, cmp []string) []*RuntimeContainer {
96+
func whereAll(entries []*RuntimeContainer, key, sep string, cmp []string) []*RuntimeContainer {
9797
selection := []*RuntimeContainer{}
9898
req_count := len(cmp)
9999
for _, v := range entries {
@@ -275,17 +275,17 @@ func generateFile(config Config, containers Context) bool {
275275
"hasPrefix": hasPrefix,
276276
"hasSuffix": hasSuffix,
277277
"json": marshalJson,
278-
"intersect": intersect,
278+
"intersect": intersect,
279279
"keys": keys,
280280
"last": arrayLast,
281281
"replace": strings.Replace,
282282
"sha1": hashSha1,
283283
"split": strings.Split,
284284
"trimPrefix": trimPrefix,
285285
"trimSuffix": trimSuffix,
286-
"where": where,
287-
"whereSomeMatch": whereSomeMatch,
288-
"whereRequires": whereRequires,
286+
"where": where,
287+
"whereAny": whereAny,
288+
"whereAll": whereAll,
289289
}).ParseFiles(templatePath)
290290
if err != nil {
291291
log.Fatalf("unable to parse template: %s", err)

template_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,19 +249,19 @@ func TestWhereSomeMatch(t *testing.T) {
249249
},
250250
}
251251

252-
if len(whereSomeMatch(containers, "Env.VIRTUAL_HOST", ",", []string{"demo1.localhost"})) != 1 {
252+
if len(whereAny(containers, "Env.VIRTUAL_HOST", ",", []string{"demo1.localhost"})) != 1 {
253253
t.Fatalf("demo1.localhost expected 1 match")
254254
}
255255

256-
if len(whereSomeMatch(containers, "Env.VIRTUAL_HOST", ",", []string{"demo2.localhost", "lala"})) != 2 {
256+
if len(whereAny(containers, "Env.VIRTUAL_HOST", ",", []string{"demo2.localhost", "lala"})) != 2 {
257257
t.Fatalf("demo2.localhost expected 2 matches")
258258
}
259259

260-
if len(whereSomeMatch(containers, "Env.VIRTUAL_HOST", ",", []string{"something", "demo3.localhost"})) != 1 {
260+
if len(whereAny(containers, "Env.VIRTUAL_HOST", ",", []string{"something", "demo3.localhost"})) != 1 {
261261
t.Fatalf("demo3.localhost expected 1 match")
262262
}
263263

264-
if len(whereSomeMatch(containers, "Env.NOEXIST", ",", []string{"demo3.localhost"})) != 0 {
264+
if len(whereAny(containers, "Env.NOEXIST", ",", []string{"demo3.localhost"})) != 0 {
265265
t.Fatalf("NOEXIST demo3.localhost expected 0 match")
266266
}
267267
}
@@ -294,19 +294,19 @@ func TestWhereRequires(t *testing.T) {
294294
},
295295
}
296296

297-
if len(whereRequires(containers, "Env.VIRTUAL_HOST", ",", []string{"demo1.localhost"})) != 1 {
297+
if len(whereAll(containers, "Env.VIRTUAL_HOST", ",", []string{"demo1.localhost"})) != 1 {
298298
t.Fatalf("demo1.localhost expected 1 match")
299299
}
300300

301-
if len(whereRequires(containers, "Env.VIRTUAL_HOST", ",", []string{"demo2.localhost", "lala"})) != 0 {
301+
if len(whereAll(containers, "Env.VIRTUAL_HOST", ",", []string{"demo2.localhost", "lala"})) != 0 {
302302
t.Fatalf("demo2.localhost,lala expected 0 matches")
303303
}
304304

305-
if len(whereRequires(containers, "Env.VIRTUAL_HOST", ",", []string{"demo3.localhost"})) != 1 {
305+
if len(whereAll(containers, "Env.VIRTUAL_HOST", ",", []string{"demo3.localhost"})) != 1 {
306306
t.Fatalf("demo3.localhost expected 1 match")
307307
}
308308

309-
if len(whereRequires(containers, "Env.NOEXIST", ",", []string{"demo3.localhost"})) != 0 {
309+
if len(whereAll(containers, "Env.NOEXIST", ",", []string{"demo3.localhost"})) != 0 {
310310
t.Fatalf("NOEXIST demo3.localhost expected 0 match")
311311
}
312312
}

0 commit comments

Comments
 (0)