openrewrite / rewrite-feature-flags

OpenRewrite recipes for LaunchDarkly.
Apache License 2.0
2 stars 2 forks source link

Change the default value for a feature flag #13

Closed timtebeek closed 9 months ago

timtebeek commented 10 months ago

What problem are you trying to solve?

When gradually promoting a feature, at some point you might want to flip the fallback default value, in the real value can not be retrieved.

A recipe should find usages of the specified key, and change the default value.

What precondition(s) should be checked before applying this recipe?

Configure feature flag used.

Describe the situation before applying the recipe

import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Foo {
    void bar(LDClient client, LDContext context) {
        if (client.boolVariation("flag-key-123abc", context, false)) {
            System.out.println("Feature is on");
        }
    }
}

Describe the situation after applying the recipe

import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Foo {
    void bar(LDClient client, LDContext context) {
        if (client.boolVariation("flag-key-123abc", context, true)) {
            System.out.println("Feature is on");
        }
    }
}