Skip to content

Commit a01414f

Browse files
temirlantemirlan
authored andcommitted
add flag tags to models Result
1 parent 67341a8 commit a01414f

File tree

8 files changed

+43
-0
lines changed

8 files changed

+43
-0
lines changed

docs/api_docs/bundle.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,12 @@ definitions:
13531353
flagSnapshotID:
13541354
type: integer
13551355
format: int64
1356+
flagTags:
1357+
description: flagTags. flagTags looks up flags by tag. Either works.
1358+
type: array
1359+
x-omitempty: true
1360+
items:
1361+
type: string
13561362
segmentID:
13571363
type: integer
13581364
format: int64

integration_tests/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ networks:
77

88
services:
99
mysql:
10+
platform: linux/x86_64
1011
image: mysql:5.6
1112
container_name: flagr-mysql
1213
environment:

integration_tests/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ step_11_test_tag_batch_evaluation() {
349349
matches "\"flagID\":1"
350350
matches "\"variantKey\":\"key_1\""
351351
matches "\"variantID\":1"
352+
contains "flagTags"
352353

353354
}
354355

@@ -361,12 +362,14 @@ step_12_test_tag_operator_batch_evaluation() {
361362
matches "\"flagID\":1"
362363
matches "\"variantKey\":\"key_1\""
363364
matches "\"variantID\":1"
365+
contains "flagTags"
364366

365367
shakedown POST "$flagr_url"/evaluation/batch -H 'Content-Type:application/json' -d '{"entities":[{ "entityType": "externalalert", "entityContext": {"property_1": "value_2"} }],"flagTags": ["value_1", "value_3"], "flagTagsOperator": "ANY", "enableDebug": false }'
366368
status 200
367369
matches "\"flagID\":1"
368370
matches "\"variantKey\":\"key_1\""
369371
matches "\"variantID\":1"
372+
contains "flagTags"
370373

371374
}
372375

pkg/handler/eval.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,16 @@ func BlankResult(f *entity.Flag, evalContext models.EvalContext, msg string) *mo
105105
flagID := uint(0)
106106
flagKey := ""
107107
flagSnapshotID := uint(0)
108+
flagTags := []string{}
108109
if f != nil {
109110
flagID = f.ID
110111
flagSnapshotID = f.SnapshotID
111112
flagKey = f.Key
113+
if len(f.Tags) > 0 {
114+
for _, tag := range f.Tags {
115+
flagTags = append(flagTags, tag.Value)
116+
}
117+
}
112118
}
113119
return &models.EvalResult{
114120
EvalContext: &evalContext,
@@ -119,6 +125,7 @@ func BlankResult(f *entity.Flag, evalContext models.EvalContext, msg string) *mo
119125
FlagID: int64(flagID),
120126
FlagKey: flagKey,
121127
FlagSnapshotID: int64(flagSnapshotID),
128+
FlagTags: flagTags,
122129
Timestamp: util.TimeNow(),
123130
}
124131
}

pkg/handler/eval_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ func TestPostEvaluation(t *testing.T) {
488488
EntityID: "entityID1",
489489
EntityType: "entityType1",
490490
FlagID: int64(100),
491+
FlagTags: []string{"tag1", "tag2"},
491492
},
492493
})
493494
assert.NotNil(t, resp)

swagger/index.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,12 @@ definitions:
481481
flagSnapshotID:
482482
type: integer
483483
format: int64
484+
flagTags:
485+
description: flagTags. flagTags looks up flags by tag. Either works.
486+
type: array
487+
x-omitempty: true
488+
items:
489+
type: string
484490
segmentID:
485491
type: integer
486492
format: int64

swagger_gen/models/eval_result.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swagger_gen/restapi/embedded_spec.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)