diff --git a/pkg/openfeature/client.go b/pkg/openfeature/client.go index 848f6a29..eeb495c4 100644 --- a/pkg/openfeature/client.go +++ b/pkg/openfeature/client.go @@ -213,25 +213,26 @@ func (c Client) evaluate( return evalDetails, err } + flatCtx := flattenContext(evalCtx) var resolution ResolutionDetail switch flagType { case Object: - resolution = api.provider.ObjectEvaluation(flag, defaultValue, evalCtx) + resolution = api.provider.ObjectEvaluation(flag, defaultValue, flatCtx) case Boolean: defValue := defaultValue.(bool) - res := api.provider.BooleanEvaluation(flag, defValue, evalCtx) + res := api.provider.BooleanEvaluation(flag, defValue, flatCtx) resolution = res.ResolutionDetail case String: defValue := defaultValue.(string) - res := api.provider.StringEvaluation(flag, defValue, evalCtx) + res := api.provider.StringEvaluation(flag, defValue, flatCtx) resolution = res.ResolutionDetail case Float: defValue := defaultValue.(float64) - res := api.provider.FloatEvaluation(flag, defValue, evalCtx) + res := api.provider.FloatEvaluation(flag, defValue, flatCtx) resolution = res.ResolutionDetail case Int: defValue := defaultValue.(int64) - res := api.provider.IntEvaluation(flag, defValue, evalCtx) + res := api.provider.IntEvaluation(flag, defValue, flatCtx) resolution = res.ResolutionDetail } @@ -254,6 +255,17 @@ func (c Client) evaluate( return evalDetails, nil } +func flattenContext(evalCtx EvaluationContext) map[string]interface{} { + flatCtx := map[string]interface{}{} + if evalCtx.Attributes != nil { + flatCtx = evalCtx.Attributes + } + if evalCtx.TargetingKey != "" { + flatCtx[TargetingKey] = evalCtx.TargetingKey + } + return flatCtx +} + func (c Client) beforeHooks( hookCtx HookContext, hooks []Hook, evalCtx EvaluationContext, options EvaluationOptions, ) (EvaluationContext, error) { diff --git a/pkg/openfeature/client_test.go b/pkg/openfeature/client_test.go index d1f51a6a..749cc360 100644 --- a/pkg/openfeature/client_test.go +++ b/pkg/openfeature/client_test.go @@ -1,6 +1,7 @@ package openfeature import ( + "reflect" "testing" "github.com/golang/mock/gomock" @@ -208,6 +209,8 @@ func TestRequirement_1_4_4(t *testing.T) { func TestRequirement_1_4_9(t *testing.T) { client := NewClient("test-client") flagKey := "flag-key" + evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) ctrl := gomock.NewController(t) @@ -217,7 +220,7 @@ func TestRequirement_1_4_9(t *testing.T) { defaultValue := true mockProvider.EXPECT().Metadata().Times(2) mockProvider.EXPECT().Hooks().AnyTimes() - mockProvider.EXPECT().BooleanEvaluation(flagKey, defaultValue, EvaluationContext{}). + mockProvider.EXPECT().BooleanEvaluation(flagKey, defaultValue, flatCtx). Return(BoolResolutionDetail{ Value: false, ResolutionDetail: ResolutionDetail{ @@ -228,7 +231,7 @@ func TestRequirement_1_4_9(t *testing.T) { }).Times(2) SetProvider(mockProvider) - value, err := client.BooleanValue(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + value, err := client.BooleanValue(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected BooleanValue to return an error, got nil") } @@ -237,7 +240,7 @@ func TestRequirement_1_4_9(t *testing.T) { t.Errorf("expected default value from BooleanValue, got %v", value) } - valueDetails, err := client.BooleanValueDetails(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + valueDetails, err := client.BooleanValueDetails(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected BooleanValueDetails to return an error, got nil") } @@ -253,7 +256,7 @@ func TestRequirement_1_4_9(t *testing.T) { defaultValue := "default" mockProvider.EXPECT().Metadata().Times(2) mockProvider.EXPECT().Hooks().AnyTimes() - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, EvaluationContext{}). + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx). Return(StringResolutionDetail{ Value: "foo", ResolutionDetail: ResolutionDetail{ @@ -264,7 +267,7 @@ func TestRequirement_1_4_9(t *testing.T) { }).Times(2) SetProvider(mockProvider) - value, err := client.StringValue(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + value, err := client.StringValue(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected StringValue to return an error, got nil") } @@ -273,7 +276,7 @@ func TestRequirement_1_4_9(t *testing.T) { t.Errorf("expected default value from StringValue, got %v", value) } - valueDetails, err := client.StringValueDetails(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + valueDetails, err := client.StringValueDetails(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected StringValueDetails to return an error, got nil") } @@ -289,7 +292,7 @@ func TestRequirement_1_4_9(t *testing.T) { defaultValue := 3.14159 mockProvider.EXPECT().Metadata().Times(2) mockProvider.EXPECT().Hooks().AnyTimes() - mockProvider.EXPECT().FloatEvaluation(flagKey, defaultValue, EvaluationContext{}). + mockProvider.EXPECT().FloatEvaluation(flagKey, defaultValue, flatCtx). Return(FloatResolutionDetail{ Value: 0, ResolutionDetail: ResolutionDetail{ @@ -300,7 +303,7 @@ func TestRequirement_1_4_9(t *testing.T) { }).Times(2) SetProvider(mockProvider) - value, err := client.FloatValue(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + value, err := client.FloatValue(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected FloatValue to return an error, got nil") } @@ -309,7 +312,7 @@ func TestRequirement_1_4_9(t *testing.T) { t.Errorf("expected default value from FloatValue, got %v", value) } - valueDetails, err := client.FloatValueDetails(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + valueDetails, err := client.FloatValueDetails(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected FloatValueDetails to return an error, got nil") } @@ -325,7 +328,7 @@ func TestRequirement_1_4_9(t *testing.T) { var defaultValue int64 = 3 mockProvider.EXPECT().Metadata().Times(2) mockProvider.EXPECT().Hooks().AnyTimes() - mockProvider.EXPECT().IntEvaluation(flagKey, defaultValue, EvaluationContext{}). + mockProvider.EXPECT().IntEvaluation(flagKey, defaultValue, flatCtx). Return(IntResolutionDetail{ Value: 0, ResolutionDetail: ResolutionDetail{ @@ -336,7 +339,7 @@ func TestRequirement_1_4_9(t *testing.T) { }).Times(2) SetProvider(mockProvider) - value, err := client.IntValue(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + value, err := client.IntValue(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected IntValue to return an error, got nil") } @@ -345,7 +348,7 @@ func TestRequirement_1_4_9(t *testing.T) { t.Errorf("expected default value from IntValue, got %v", value) } - valueDetails, err := client.IntValueDetails(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + valueDetails, err := client.IntValueDetails(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected FloatValueDetails to return an error, got nil") } @@ -364,7 +367,7 @@ func TestRequirement_1_4_9(t *testing.T) { defaultValue := obj{foo: "bar"} mockProvider.EXPECT().Metadata().Times(2) mockProvider.EXPECT().Hooks().AnyTimes() - mockProvider.EXPECT().ObjectEvaluation(flagKey, defaultValue, EvaluationContext{}). + mockProvider.EXPECT().ObjectEvaluation(flagKey, defaultValue, flatCtx). Return(ResolutionDetail{ Value: obj{foo: "foo"}, ErrorCode: "GENERAL", @@ -372,7 +375,7 @@ func TestRequirement_1_4_9(t *testing.T) { }).Times(2) SetProvider(mockProvider) - value, err := client.ObjectValue(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + value, err := client.ObjectValue(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected ObjectValue to return an error, got nil") } @@ -381,7 +384,7 @@ func TestRequirement_1_4_9(t *testing.T) { t.Errorf("expected default value from ObjectValue, got %v", value) } - valueDetails, err := client.ObjectValueDetails(flagKey, defaultValue, EvaluationContext{}, EvaluationOptions{}) + valueDetails, err := client.ObjectValueDetails(flagKey, defaultValue, evalCtx, EvaluationOptions{}) if err == nil { t.Error("expected ObjectValueDetails to return an error, got nil") } @@ -477,3 +480,80 @@ func TestClient_ProviderEvaluationReturnsUnexpectedType(t *testing.T) { } }) } + +func TestFlattenContext(t *testing.T) { + tests := map[string]struct { + inCtx EvaluationContext + outCtx map[string]interface{} + }{ + "happy path": { + inCtx: EvaluationContext{ + Attributes: map[string]interface{}{ + "1": "string", + "2": 0.01, + "3": false, + }, + TargetingKey: "user", + }, + outCtx: map[string]interface{}{ + TargetingKey: "user", + "1": "string", + "2": 0.01, + "3": false, + }, + }, + "no targeting key": { + inCtx: EvaluationContext{ + Attributes: map[string]interface{}{ + "1": "string", + "2": 0.01, + "3": false, + }, + }, + outCtx: map[string]interface{}{ + "1": "string", + "2": 0.01, + "3": false, + }, + }, + "duplicated key": { + inCtx: EvaluationContext{ + TargetingKey: "user", + Attributes: map[string]interface{}{ + TargetingKey: "not user", + "1": "string", + "2": 0.01, + "3": false, + }, + }, + outCtx: map[string]interface{}{ + TargetingKey: "user", + "1": "string", + "2": 0.01, + "3": false, + }, + }, + "no attributes": { + inCtx: EvaluationContext{ + TargetingKey: "user", + }, + outCtx: map[string]interface{}{ + TargetingKey: "user", + }, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + out := flattenContext(test.inCtx) + if !reflect.DeepEqual(test.outCtx, out) { + t.Fatalf( + "%s, unexpected value received from flatten context, expected %v got %v", + name, + test.outCtx, + out, + ) + } + }) + } +} diff --git a/pkg/openfeature/evaluation_context_test.go b/pkg/openfeature/evaluation_context_test.go index fcde3919..3004ab3e 100644 --- a/pkg/openfeature/evaluation_context_test.go +++ b/pkg/openfeature/evaluation_context_test.go @@ -132,7 +132,8 @@ func TestRequirement_3_2_2(t *testing.T) { "user": 1, }, } - mockProvider.EXPECT().StringEvaluation(gomock.Any(), gomock.Any(), expectedMergedEvalCtx) + flatCtx := flattenContext(expectedMergedEvalCtx) + mockProvider.EXPECT().StringEvaluation(gomock.Any(), gomock.Any(), flatCtx) _, err := client.StringValue("foo", "bar", invocationEvalCtx, EvaluationOptions{}) if err != nil { diff --git a/pkg/openfeature/hooks_test.go b/pkg/openfeature/hooks_test.go index efd31338..850149b7 100644 --- a/pkg/openfeature/hooks_test.go +++ b/pkg/openfeature/hooks_test.go @@ -160,13 +160,14 @@ func TestRequirement_4_3_2(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) evalOptions := NewEvaluationOptions([]Hook{mockHook}, HookHints{}) mockProvider.EXPECT().Metadata() mockProvider.EXPECT().Hooks().AnyTimes() // assert that the Before hooks are executed prior to the flag evaluation - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx). + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx). After(mockHook.EXPECT().Before(gomock.Any(), gomock.Any())) mockHook.EXPECT().After(gomock.Any(), gomock.Any(), gomock.Any()) mockHook.EXPECT().Finally(gomock.Any(), gomock.Any()) @@ -219,8 +220,9 @@ func TestRequirement_4_3_3(t *testing.T) { evaluationContext: evalCtx, } hook1EvalCtxResult := &EvaluationContext{TargetingKey: "mockHook1"} + hook1EvalCtxResultFlat := flattenContext(*hook1EvalCtxResult) mockHook1.EXPECT().Before(hook1Ctx, gomock.Any()).Return(hook1EvalCtxResult, nil) - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, *hook1EvalCtxResult) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, hook1EvalCtxResultFlat) // assert that the evaluation context returned by the first hook is passed into the second hook hook2Ctx := hook1Ctx @@ -299,7 +301,7 @@ func TestRequirement_4_3_4(t *testing.T) { "beatsClient": true, }, } - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, expectedMergedContext) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flattenContext(expectedMergedContext)) mockHook.EXPECT().After(gomock.Any(), gomock.Any(), gomock.Any()) mockHook.EXPECT().Finally(gomock.Any(), gomock.Any()) @@ -324,6 +326,7 @@ func TestRequirement_4_3_5(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) evalOptions := NewEvaluationOptions([]Hook{mockHook}, HookHints{}) mockProvider.EXPECT().Metadata() @@ -332,7 +335,7 @@ func TestRequirement_4_3_5(t *testing.T) { mockHook.EXPECT().Before(gomock.Any(), gomock.Any()) // assert that the After hooks are executed after the flag evaluation mockHook.EXPECT().After(gomock.Any(), gomock.Any(), gomock.Any()). - After(mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx)) + After(mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx)) mockHook.EXPECT().Finally(gomock.Any(), gomock.Any()) _, err := client.StringValueDetails(flagKey, defaultValue, evalCtx, evalOptions) @@ -365,6 +368,7 @@ func TestRequirement_4_3_6(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) t.Run("error hook MUST run when errors are encountered in the before stage", func(t *testing.T) { mockHook := NewMockHook(ctrl) @@ -401,7 +405,7 @@ func TestRequirement_4_3_6(t *testing.T) { // assert that the Error hooks are executed after the failed flag evaluation mockHook.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()). After( - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx). + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx). Return(StringResolutionDetail{ResolutionDetail: ResolutionDetail{ErrorCode: "forced"}}), ) mockHook.EXPECT().Finally(gomock.Any(), gomock.Any()) @@ -423,7 +427,7 @@ func TestRequirement_4_3_6(t *testing.T) { mockProvider.EXPECT().Hooks().AnyTimes() mockHook.EXPECT().Before(gomock.Any(), gomock.Any()) - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx) // assert that the Error hooks are executed after the failed After hooks mockHook.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()). After(mockHook.EXPECT().After(gomock.Any(), gomock.Any(), gomock.Any()).Return(errors.New("forced"))) @@ -458,6 +462,7 @@ func TestRequirement_4_3_7(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) t.Run("finally hook MUST run after the before & after stages", func(t *testing.T) { mockHook := NewMockHook(ctrl) @@ -473,7 +478,7 @@ func TestRequirement_4_3_7(t *testing.T) { mockHook.EXPECT().Finally(gomock.Any(), gomock.Any()). After(mockHook.EXPECT().After(gomock.Any(), gomock.Any(), gomock.Any())). After(mockHook.EXPECT().Before(gomock.Any(), gomock.Any())) - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx) _, err := client.StringValueDetails(flagKey, defaultValue, evalCtx, evalOptions) if err != nil { @@ -587,6 +592,7 @@ func TestRequirement_4_4_2(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) t.Run("before, after & finally hooks MUST be evaluated in the following order", func(t *testing.T) { defer t.Cleanup(initSingleton) @@ -623,7 +629,7 @@ func TestRequirement_4_4_2(t *testing.T) { After(mockInvocationHook.EXPECT().Finally(gomock.Any(), gomock.Any())). After(mockProviderHook.EXPECT().Finally(gomock.Any(), gomock.Any())) - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx) _, err := client.StringValueDetails(flagKey, defaultValue, evalCtx, evalOptions) if err != nil { @@ -694,6 +700,7 @@ func TestRequirement_4_4_6(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) t.Run( "if an error occurs during the evaluation of before hooks, any remaining before hooks MUST NOT be invoked", @@ -744,7 +751,7 @@ func TestRequirement_4_4_6(t *testing.T) { mockHook2.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()) mockHook2.EXPECT().Finally(gomock.Any(), gomock.Any()) - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx) _, err := client.StringValueDetails(flagKey, defaultValue, evalCtx, evalOptions) if err == nil { @@ -799,6 +806,7 @@ func TestRequirement_4_5_2(t *testing.T) { flagKey := "foo" defaultValue := "bar" evalCtx := EvaluationContext{} + flatCtx := flattenContext(evalCtx) t.Run("hook hints must be passed to before, after & finally hooks", func(t *testing.T) { defer t.Cleanup(initSingleton) @@ -816,7 +824,7 @@ func TestRequirement_4_5_2(t *testing.T) { mockHook.EXPECT().After(gomock.Any(), gomock.Any(), hookHints) mockHook.EXPECT().Finally(gomock.Any(), hookHints) - mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, evalCtx) + mockProvider.EXPECT().StringEvaluation(flagKey, defaultValue, flatCtx) _, err := client.StringValueDetails(flagKey, defaultValue, evalCtx, evalOptions) if err != nil { diff --git a/pkg/openfeature/noop_provider.go b/pkg/openfeature/noop_provider.go index a44ffa4a..20cb5f09 100644 --- a/pkg/openfeature/noop_provider.go +++ b/pkg/openfeature/noop_provider.go @@ -9,7 +9,7 @@ func (e NoopProvider) Metadata() Metadata { } // BooleanEvaluation returns a boolean flag. -func (e NoopProvider) BooleanEvaluation(flag string, defaultValue bool, evalCtx EvaluationContext) BoolResolutionDetail { +func (e NoopProvider) BooleanEvaluation(flag string, defaultValue bool, evalCtx map[string]interface{}) BoolResolutionDetail { return BoolResolutionDetail{ Value: defaultValue, ResolutionDetail: ResolutionDetail{ @@ -20,7 +20,7 @@ func (e NoopProvider) BooleanEvaluation(flag string, defaultValue bool, evalCtx } // StringEvaluation returns a string flag. -func (e NoopProvider) StringEvaluation(flag string, defaultValue string, evalCtx EvaluationContext) StringResolutionDetail { +func (e NoopProvider) StringEvaluation(flag string, defaultValue string, evalCtx map[string]interface{}) StringResolutionDetail { return StringResolutionDetail{ Value: defaultValue, ResolutionDetail: ResolutionDetail{ @@ -31,7 +31,7 @@ func (e NoopProvider) StringEvaluation(flag string, defaultValue string, evalCtx } // FloatEvaluation returns a float flag. -func (e NoopProvider) FloatEvaluation(flag string, defaultValue float64, evalCtx EvaluationContext) FloatResolutionDetail { +func (e NoopProvider) FloatEvaluation(flag string, defaultValue float64, evalCtx map[string]interface{}) FloatResolutionDetail { return FloatResolutionDetail{ Value: defaultValue, ResolutionDetail: ResolutionDetail{ @@ -42,7 +42,7 @@ func (e NoopProvider) FloatEvaluation(flag string, defaultValue float64, evalCtx } // IntEvaluation returns an int flag. -func (e NoopProvider) IntEvaluation(flag string, defaultValue int64, evalCtx EvaluationContext) IntResolutionDetail { +func (e NoopProvider) IntEvaluation(flag string, defaultValue int64, evalCtx map[string]interface{}) IntResolutionDetail { return IntResolutionDetail{ Value: defaultValue, ResolutionDetail: ResolutionDetail{ @@ -53,7 +53,7 @@ func (e NoopProvider) IntEvaluation(flag string, defaultValue int64, evalCtx Eva } // ObjectEvaluation returns an object flag -func (e NoopProvider) ObjectEvaluation(flag string, defaultValue interface{}, evalCtx EvaluationContext) ResolutionDetail { +func (e NoopProvider) ObjectEvaluation(flag string, defaultValue interface{}, evalCtx map[string]interface{}) ResolutionDetail { return ResolutionDetail{ Value: defaultValue, Variant: "default-variant", diff --git a/pkg/openfeature/provider.go b/pkg/openfeature/provider.go index 03d85c0f..2b45f2f0 100644 --- a/pkg/openfeature/provider.go +++ b/pkg/openfeature/provider.go @@ -6,19 +6,21 @@ const ( DISABLED string = "disabled" // variant returned because feature is disabled TARGETING_MATCH string = "target match" // variant returned because matched target rule DEFAULT string = "default" // variant returned the default - UNKNOWN string = "unknown" //variant returned for unknown reason + UNKNOWN string = "unknown" // variant returned for unknown reason ERROR string = "error" // variant returned due to error + + TargetingKey string = "targetingKey" // evaluation context map key. The targeting key uniquely identifies the subject (end-user, or client service) of a flag evaluation. ) // FeatureProvider interface defines a set of functions that can be called in order to evaluate a flag. // vendors should implement type FeatureProvider interface { Metadata() Metadata - BooleanEvaluation(flag string, defaultValue bool, evalCtx EvaluationContext) BoolResolutionDetail - StringEvaluation(flag string, defaultValue string, evalCtx EvaluationContext) StringResolutionDetail - FloatEvaluation(flag string, defaultValue float64, evalCtx EvaluationContext) FloatResolutionDetail - IntEvaluation(flag string, defaultValue int64, evalCtx EvaluationContext) IntResolutionDetail - ObjectEvaluation(flag string, defaultValue interface{}, evalCtx EvaluationContext) ResolutionDetail + BooleanEvaluation(flag string, defaultValue bool, evalCtx map[string]interface{}) BoolResolutionDetail + StringEvaluation(flag string, defaultValue string, evalCtx map[string]interface{}) StringResolutionDetail + FloatEvaluation(flag string, defaultValue float64, evalCtx map[string]interface{}) FloatResolutionDetail + IntEvaluation(flag string, defaultValue int64, evalCtx map[string]interface{}) IntResolutionDetail + ObjectEvaluation(flag string, defaultValue interface{}, evalCtx map[string]interface{}) ResolutionDetail Hooks() []Hook } diff --git a/pkg/openfeature/provider_mock_test.go b/pkg/openfeature/provider_mock_test.go index ae001ebc..2ec3bff1 100644 --- a/pkg/openfeature/provider_mock_test.go +++ b/pkg/openfeature/provider_mock_test.go @@ -34,7 +34,7 @@ func (m *MockFeatureProvider) EXPECT() *MockFeatureProviderMockRecorder { } // BooleanEvaluation mocks base method. -func (m *MockFeatureProvider) BooleanEvaluation(flag string, defaultValue bool, evalCtx EvaluationContext) BoolResolutionDetail { +func (m *MockFeatureProvider) BooleanEvaluation(flag string, defaultValue bool, evalCtx map[string]interface{}) BoolResolutionDetail { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BooleanEvaluation", flag, defaultValue, evalCtx) ret0, _ := ret[0].(BoolResolutionDetail) @@ -48,7 +48,7 @@ func (mr *MockFeatureProviderMockRecorder) BooleanEvaluation(flag, defaultValue, } // FloatEvaluation mocks base method. -func (m *MockFeatureProvider) FloatEvaluation(flag string, defaultValue float64, evalCtx EvaluationContext) FloatResolutionDetail { +func (m *MockFeatureProvider) FloatEvaluation(flag string, defaultValue float64, evalCtx map[string]interface{}) FloatResolutionDetail { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FloatEvaluation", flag, defaultValue, evalCtx) ret0, _ := ret[0].(FloatResolutionDetail) @@ -76,7 +76,7 @@ func (mr *MockFeatureProviderMockRecorder) Hooks() *gomock.Call { } // IntEvaluation mocks base method. -func (m *MockFeatureProvider) IntEvaluation(flag string, defaultValue int64, evalCtx EvaluationContext) IntResolutionDetail { +func (m *MockFeatureProvider) IntEvaluation(flag string, defaultValue int64, evalCtx map[string]interface{}) IntResolutionDetail { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IntEvaluation", flag, defaultValue, evalCtx) ret0, _ := ret[0].(IntResolutionDetail) @@ -104,7 +104,7 @@ func (mr *MockFeatureProviderMockRecorder) Metadata() *gomock.Call { } // ObjectEvaluation mocks base method. -func (m *MockFeatureProvider) ObjectEvaluation(flag string, defaultValue interface{}, evalCtx EvaluationContext) ResolutionDetail { +func (m *MockFeatureProvider) ObjectEvaluation(flag string, defaultValue interface{}, evalCtx map[string]interface{}) ResolutionDetail { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ObjectEvaluation", flag, defaultValue, evalCtx) ret0, _ := ret[0].(ResolutionDetail) @@ -118,7 +118,7 @@ func (mr *MockFeatureProviderMockRecorder) ObjectEvaluation(flag, defaultValue, } // StringEvaluation mocks base method. -func (m *MockFeatureProvider) StringEvaluation(flag, defaultValue string, evalCtx EvaluationContext) StringResolutionDetail { +func (m *MockFeatureProvider) StringEvaluation(flag, defaultValue string, evalCtx map[string]interface{}) StringResolutionDetail { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StringEvaluation", flag, defaultValue, evalCtx) ret0, _ := ret[0].(StringResolutionDetail) diff --git a/pkg/openfeature/provider_test.go b/pkg/openfeature/provider_test.go index a780f7ed..8902539e 100644 --- a/pkg/openfeature/provider_test.go +++ b/pkg/openfeature/provider_test.go @@ -41,11 +41,11 @@ func TestRequirement_2_2(t *testing.T) { mockProvider := NewMockFeatureProvider(ctrl) type requirements interface { - BooleanEvaluation(flag string, defaultValue bool, evalCtx EvaluationContext) BoolResolutionDetail - StringEvaluation(flag string, defaultValue string, evalCtx EvaluationContext) StringResolutionDetail - FloatEvaluation(flag string, defaultValue float64, evalCtx EvaluationContext) FloatResolutionDetail - IntEvaluation(flag string, defaultValue int64, evalCtx EvaluationContext) IntResolutionDetail - ObjectEvaluation(flag string, defaultValue interface{}, evalCtx EvaluationContext) ResolutionDetail + BooleanEvaluation(flag string, defaultValue bool, evalCtx map[string]interface{}) BoolResolutionDetail + StringEvaluation(flag string, defaultValue string, evalCtx map[string]interface{}) StringResolutionDetail + FloatEvaluation(flag string, defaultValue float64, evalCtx map[string]interface{}) FloatResolutionDetail + IntEvaluation(flag string, defaultValue int64, evalCtx map[string]interface{}) IntResolutionDetail + ObjectEvaluation(flag string, defaultValue interface{}, evalCtx map[string]interface{}) ResolutionDetail } var mockProviderI interface{} = mockProvider