File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 6
6
"reflect"
7
7
"strconv"
8
8
9
+ "github.com/labstack/gommon/log"
10
+
9
11
"github.com/drone/ff-golang-server-sdk/types"
10
12
)
11
13
@@ -227,11 +229,15 @@ func (fc FeatureConfig) GetVariationName(target *Target) string {
227
229
228
230
if variationMap .TargetSegments != nil {
229
231
for _ , segmentIdentifier := range variationMap .TargetSegments {
230
- segment := fc .Segments [segmentIdentifier ]
231
- if segment .Included != nil {
232
- for _ , t := range segment .Included {
233
- if t == target .Identifier {
234
- return variationMap .Variation
232
+ segment , ok := fc .Segments [segmentIdentifier ]
233
+ if ! ok {
234
+ log .Error ("The segment in variation map is invalid" )
235
+ } else {
236
+ if segment .Included != nil {
237
+ for _ , t := range segment .Included {
238
+ if t == target .Identifier {
239
+ return variationMap .Variation
240
+ }
235
241
}
236
242
}
237
243
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ require (
11
11
github.com/hashicorp/golang-lru v0.5.4
12
12
github.com/jarcoal/httpmock v1.0.8
13
13
github.com/json-iterator/go v1.1.10
14
+ github.com/labstack/gommon v0.3.0 // indirect
14
15
github.com/mitchellh/go-homedir v1.1.0
15
16
github.com/mitchellh/mapstructure v1.3.3
16
17
github.com/r3labs/sse v0.0.0-20201126193848-34e640891548
You can’t perform that action at this time.
0 commit comments