Skip to content

Commit

Permalink
Merge pull request #27 from drone/FFM-1108
Browse files Browse the repository at this point in the history
[FFM-1108]: Add a log when the segment in variation map is invalid
  • Loading branch information
hannah-tang authored Jun 23, 2021
2 parents 0be7fa1 + f310173 commit a779e3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions evaluation/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"reflect"
"strconv"

"github.com/labstack/gommon/log"

"github.com/drone/ff-golang-server-sdk/types"
)

Expand Down Expand Up @@ -227,11 +229,15 @@ func (fc FeatureConfig) GetVariationName(target *Target) string {

if variationMap.TargetSegments != nil {
for _, segmentIdentifier := range variationMap.TargetSegments {
segment := fc.Segments[segmentIdentifier]
if segment.Included != nil {
for _, t := range segment.Included {
if t == target.Identifier {
return variationMap.Variation
segment, ok := fc.Segments[segmentIdentifier]
if !ok {
log.Error("The segment in variation map is invalid")
} else {
if segment.Included != nil {
for _, t := range segment.Included {
if t == target.Identifier {
return variationMap.Variation
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/hashicorp/golang-lru v0.5.4
github.com/jarcoal/httpmock v1.0.8
github.com/json-iterator/go v1.1.10
github.com/labstack/gommon v0.3.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.3.3
github.com/r3labs/sse v0.0.0-20201126193848-34e640891548
Expand Down

0 comments on commit a779e3a

Please sign in to comment.