Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Unleash Provider #338

Merged
merged 3 commits into from
Oct 10, 2023
Merged

Conversation

liran2000
Copy link
Member

Add Unleash Provider.

See readme for details.

@sighphyre @gastonfournier @ivarconr you are welcome to review from Unleash perspective.

@Kavindu-Dodan @toddbaert you are welcome to review from OpenFeature perspective.

@liran2000 liran2000 requested a review from a team as a code owner September 28, 2023 06:04
@liran2000 liran2000 changed the title Add Unleash Provider feat: Add Unleash Provider Sep 28, 2023
@ivarconr
Copy link

nice 👍🏼

Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overl looks good from OF point of view. Please consider the review commits and related implementations.

@toddbaert hope you can have a look as well

resolution := provider.BooleanEvaluation(ctx, "variant-flag", false, nil)
enabled := resolution.Value

resolution := provider.StringEvaluation(ctx, "variant-flag", "", nil)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resolution := provider.StringEvaluation(ctx, "variant-flag", "", nil)
resolution := provider.StringEvaluation(ctx, "variant-flag", "", nil)


func NewProviderWithContext(ctx context.Context, providerConfig ProviderConfig) (*Provider, error) {
if providerConfig.Options != nil {
unleash.Initialize(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the lint is correct here. Initialize can fail, some of these are hard error cases like a broken URL, so we probably need to handle this somehow

}
}

feature := unleash.GetVariant(flag)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a purely Unleash perspective, this is a variant, not a feature. If it makes more sense within this context to use feature, that's totally fine, but renaming this variable to variant makes a lot more sense to my eyes

}
}

feature := unleash.GetVariant(flag)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're passing the Unleash context here, which is definitely needed for some toggles to successfully evaluate

}
}

res := unleash.IsEnabled(flag, unleash.WithFallback(defaultValue))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as below, I think this needs to be passed the evalCtx parameter

@@ -0,0 +1,99 @@
package unleash_test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to see some tests that check that the context passed in is respected. In the test data you have a "users-flag", which would need a context with userid on it to successfully return true. That might be a nice flag to build some tests off of for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: liran2000 <liran2000@gmail.com>
@liran2000 liran2000 reopened this Oct 4, 2023
Signed-off-by: liran2000 <liran2000@gmail.com>
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I will await approval from one Unleashed contributor before merge!

Signed-off-by: liran2000 <liran2000@gmail.com>
@liran2000
Copy link
Member Author

liran2000 commented Oct 4, 2023

@sighphyre @Kavindu-Dodan @toddbaert thank you for the valuable feedback, I addressed your comments.

* had to rebase due to missing sign-off in some commits from a different IDE.

Copy link

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice one!

@toddbaert toddbaert merged commit a9c51cf into open-feature:main Oct 10, 2023
5 checks passed
@@ -8,5 +8,6 @@
"providers/go-feature-flag": "0.1.29",
"providers/flagsmith": "0.1.4",
"providers/launchdarkly": "0.1.3",
"tests/flagd": "1.3.1"
"tests/flagd": "1.3.1",
"tests/unleash": "0.0.1-alpha"
Copy link
Member

@toddbaert toddbaert Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liran2000 I guess this was a copy paste error, and you meant to do providers/unleash. I will force a quick fix for this, right now this is causing a 1.0 release which I don't think you want.

Sorry I missed this! 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and release looks good now: #346

@liran2000 liran2000 deleted the feature/unleash branch November 4, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants