Skip to content

Commit

Permalink
fix: Use LAUNCHDARKLY_SDK_KEY instead
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-launchdarkly committed Apr 25, 2024
1 parent 0c666cc commit cc83a99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Below, you'll find the basic build procedure, but for more comprehensive instruc

This project uses [Gradle](https://gradle.org/). It requires that Java is already installed on your system (version 8 or higher). It will automatically use the latest release of the LaunchDarkly SDK with major version 7.

1. Set the value of environment variable `LAUNCHDARKLY_SERVER_KEY` to your LaunchDarkly SDK key. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, edit `src/main/java/Hello.java` and set `FEATURE_FLAG_KEY` in code to the flag key.
1. Set the value of environment variable `LAUNCHDARKLY_SDK_KEY` to your LaunchDarkly SDK key. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, edit `src/main/java/Hello.java` and set `FEATURE_FLAG_KEY` in code to the flag key.

```sh
export LAUNCHDARKLY_SERVER_KEY=1234567890abcdef
export LAUNCHDARKLY_SDK_KEY=1234567890abcdef
```

```java
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/Hello.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ private static void showBanner() {
}

public static void main(String... args) throws Exception {
// Set this environment variable to skip the loop process and evaluate the flag
// a single time.
boolean CIMode = System.getenv("CI") != null;

// Get SDK Key from env variable LAUNCHDARKLY_SERVER_KEY
String envSDKKey = System.getenv("LAUNCHDARKLY_SERVER_KEY");
String envSDKKey = System.getenv("LAUNCHDARKLY_SDK_KEY");
if(envSDKKey != null) {
SDK_KEY = envSDKKey;
}
Expand All @@ -47,7 +44,7 @@ public static void main(String... args) throws Exception {
LDConfig config = new LDConfig.Builder().build();

if (SDK_KEY == null || SDK_KEY.equals("")) {
showMessage("Please set the LAUNCHDARKLY_SERVER_KEY environment variable or edit Hello.java to set SDK_KEY to your LaunchDarkly SDK key first.");
showMessage("Please set the LAUNCHDARKLY_SDK_KEY environment variable or edit Hello.java to set SDK_KEY to your LaunchDarkly SDK key first.");
System.exit(1);
}

Expand Down

0 comments on commit cc83a99

Please sign in to comment.