Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api_docs/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,12 @@ definitions:
flagSnapshotID:
type: integer
format: int64
flagTags:
description: flagTags. flagTags looks up flags by tag. Either works.
type: array
x-omitempty: true
items:
type: string
segmentID:
type: integer
format: int64
Expand Down
1 change: 1 addition & 0 deletions integration_tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ networks:

services:
mysql:
platform: linux/x86_64
image: mysql:5.6
container_name: flagr-mysql
environment:
Expand Down
3 changes: 3 additions & 0 deletions integration_tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ step_11_test_tag_batch_evaluation() {
matches "\"flagID\":1"
matches "\"variantKey\":\"key_1\""
matches "\"variantID\":1"
contains "flagTags"

}

Expand All @@ -361,12 +362,14 @@ step_12_test_tag_operator_batch_evaluation() {
matches "\"flagID\":1"
matches "\"variantKey\":\"key_1\""
matches "\"variantID\":1"
contains "flagTags"

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 }'
status 200
matches "\"flagID\":1"
matches "\"variantKey\":\"key_1\""
matches "\"variantID\":1"
contains "flagTags"

}

Expand Down
7 changes: 7 additions & 0 deletions pkg/handler/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ func BlankResult(f *entity.Flag, evalContext models.EvalContext, msg string) *mo
flagID := uint(0)
flagKey := ""
flagSnapshotID := uint(0)
flagTags := []string{}
if f != nil {
flagID = f.ID
flagSnapshotID = f.SnapshotID
flagKey = f.Key
if len(f.Tags) > 0 {
for _, tag := range f.Tags {
flagTags = append(flagTags, tag.Value)
}
}
}
return &models.EvalResult{
EvalContext: &evalContext,
Expand All @@ -119,6 +125,7 @@ func BlankResult(f *entity.Flag, evalContext models.EvalContext, msg string) *mo
FlagID: int64(flagID),
FlagKey: flagKey,
FlagSnapshotID: int64(flagSnapshotID),
FlagTags: flagTags,
Timestamp: util.TimeNow(),
}
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/handler/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func TestEvalFlag(t *testing.T) {
})
assert.NotNil(t, result)
assert.NotZero(t, result.VariantID)
assert.NotEmpty(t, result.FlagTags)
assert.Len(t, result.FlagTags, 2)
assert.Contains(t, result.FlagTags, "tag1")
assert.Contains(t, result.FlagTags, "tag2")
})

t.Run("test happy code path with flagKey", func(t *testing.T) {
Expand Down Expand Up @@ -467,6 +471,10 @@ func TestEvalFlagsByTags(t *testing.T) {
})
assert.NotZero(t, len(results))
assert.NotZero(t, results[0].VariantID)
assert.NotEmpty(t, results[0].FlagTags)
assert.Len(t, results[0].FlagTags, 2)
assert.Contains(t, results[0].FlagTags, "tag1")
assert.Contains(t, results[0].FlagTags, "tag2")
})
}

Expand Down Expand Up @@ -515,6 +523,7 @@ func TestPostEvaluationBatch(t *testing.T) {
assert.NotNil(t, resp)
})
}

func TestTagsPostEvaluationBatch(t *testing.T) {
t.Run("test happy code path", func(t *testing.T) {
defer gostub.StubFunc(&EvalFlag, &models.EvalResult{}).Reset()
Expand Down
6 changes: 6 additions & 0 deletions swagger/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ definitions:
flagSnapshotID:
type: integer
format: int64
flagTags:
description: flagTags. flagTags looks up flags by tag. Either works.
type: array
x-omitempty: true
items:
type: string
segmentID:
type: integer
format: int64
Expand Down
3 changes: 3 additions & 0 deletions swagger_gen/models/eval_result.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions swagger_gen/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading