feat: enhance provider with Bucketeer SDK integration and evaluation methods#3
feat: enhance provider with Bucketeer SDK integration and evaluation methods#3
Conversation
d70595e to
1957b54
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR integrates the Bucketeer SDK into the feature provider to support evaluation methods for Boolean, String, Float, Int, and Object flag types and maps Bucketeer evaluation reasons to OpenFeature reasons.
- Implements the BucketeerSDK interface with evaluation methods for various data types.
- Converts OpenFeature context into a Bucketeer user and maps evaluation reasons accordingly.
- Adds comprehensive unit tests for the new functionality.
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (1)
pkg/provider.go:120
- The variable 'flag' appears to be used without a declaration in this function; please ensure it is passed as a parameter or defined within the scope to prevent undefined variable errors.
evaluation := p.sdk.BoolVariationDetails(ctx, bucketeerUser, flag, defaultValue)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
duyhungtnn
left a comment
There was a problem hiding this comment.
Hi @nnnkkk7,
Great work!
I have a few comments—please take a look.
| assert.Equal(t, test.expectedReason, actual) | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Will you add the e2e tests ?
There was a problem hiding this comment.
Yes!
I'll add it in another PR!
There was a problem hiding this comment.
Yes, please add the document on how to initiate and use the provider, too.
0de5986 to
0293115
Compare
0293115 to
39273ad
Compare
duyhungtnn
left a comment
There was a problem hiding this comment.
Your changes look good.
I’m just wondering if we could support more data types in the OpenFeature EvaluationContext.
pkg/provider.go
Outdated
| valStr, ok := val.(string) | ||
| if !ok { | ||
| return user.User{}, | ||
| ToPtr(openfeature.NewParseErrorResolutionError( | ||
| fmt.Sprintf("key %q, value %q can not be converted to string", key, val), | ||
| ), | ||
| ) | ||
| } | ||
| bucketeerUser.Data[key] = valStr |
There was a problem hiding this comment.
| valStr, ok := val.(string) | |
| if !ok { | |
| return user.User{}, | |
| ToPtr(openfeature.NewParseErrorResolutionError( | |
| fmt.Sprintf("key %q, value %q can not be converted to string", key, val), | |
| ), | |
| ) | |
| } | |
| bucketeerUser.Data[key] = valStr | |
| switch v := val.(type) { | |
| case string: | |
| bucketeerUser.Data[key] = v | |
| default: | |
| jsonBytes, err := json.Marshal(v) | |
| if err != nil { | |
| return user.User{}, ToPtr(openfeature.NewParseErrorResolutionError( | |
| fmt.Sprintf("key %q, value %q cannot be converted to JSON string: %v", key, val, err), | |
| )) | |
| } | |
| bucketeerUser.Data[key] = string(jsonBytes) | |
| } |
There was a problem hiding this comment.
What do you think ?
If the val contains unsupported data types (e.g., functions, channels, circular references), json.Marshal will fail and return an error.
Otherwise, it seems good.
There was a problem hiding this comment.
Thank you!
I fixed and added the test!
fix: add other data types to toBucketeerUser
| assert.Equal(t, test.expectedReason, actual) | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Yes, please add the document on how to initiate and use the provider, too.
Uh oh!
There was an error while loading. Please reload this page.