Skip to content

Commit

Permalink
pass launchdarkly api environment variable to orchestrator (#22428)
Browse files Browse the repository at this point in the history
* pass launchdarkly api environment variable to orchestrator

* Put env vars in alphabetical order
  • Loading branch information
mfsiega-airbyte authored Feb 7, 2023
1 parent da924a4 commit 8fee0c4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class OrchestratorConstants {
private static final String S3_PATH_STYLE_ACCESS = "S3_PATH_STYLE_ACCESS";
private static final String FEATURE_FLAG_CLIENT = "FEATURE_FLAG_CLIENT";
private static final String FEATURE_FLAG_PATH = "FEATURE_FLAG_PATH";
private static final String LAUNCHDARKLY_KEY = "LAUNCHDARKLY_KEY";

// set of env vars necessary for the container orchestrator app to run
public static final Set<String> ENV_VARS_TO_TRANSFER = new ImmutableSet.Builder<String>()
Expand Down Expand Up @@ -76,7 +75,7 @@ public class OrchestratorConstants {
EnvVariableFeatureFlags.FIELD_SELECTION_WORKSPACES,
FEATURE_FLAG_CLIENT,
FEATURE_FLAG_PATH,
LAUNCHDARKLY_KEY,
EnvConfigs.LAUNCHDARKLY_KEY,
EnvConfigs.SOCAT_KUBE_CPU_LIMIT,
EnvConfigs.SOCAT_KUBE_CPU_REQUEST))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ private Map<String, String> getWorkerMetadata() {
EnvVariableFeatureFlags.APPLY_FIELD_SELECTION, String.valueOf(featureFlags.applyFieldSelection()),
EnvVariableFeatureFlags.FIELD_SELECTION_WORKSPACES, featureFlags.fieldSelectionWorkspaces(),
EnvConfigs.SOCAT_KUBE_CPU_LIMIT, configs.getSocatSidecarKubeCpuLimit(),
EnvConfigs.SOCAT_KUBE_CPU_REQUEST, configs.getSocatSidecarKubeCpuRequest());
EnvConfigs.SOCAT_KUBE_CPU_REQUEST, configs.getSocatSidecarKubeCpuRequest(),
EnvConfigs.LAUNCHDARKLY_KEY, configs.getLaunchDarklyKey());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class AirbyteIntegrationLauncherTest {
EnvVariableFeatureFlags.APPLY_FIELD_SELECTION, String.valueOf(FEATURE_FLAGS.applyFieldSelection()),
EnvVariableFeatureFlags.FIELD_SELECTION_WORKSPACES, FEATURE_FLAGS.fieldSelectionWorkspaces(),
EnvConfigs.SOCAT_KUBE_CPU_REQUEST, CONFIGS.getSocatSidecarKubeCpuRequest(),
EnvConfigs.SOCAT_KUBE_CPU_LIMIT, CONFIGS.getSocatSidecarKubeCpuLimit());
EnvConfigs.SOCAT_KUBE_CPU_LIMIT, CONFIGS.getSocatSidecarKubeCpuLimit(),
EnvConfigs.LAUNCHDARKLY_KEY, CONFIGS.getLaunchDarklyKey());

private WorkerConfigs workerConfigs;
@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ public interface Configs {
*/
String getOtelCollectorEndpoint();

/**
* If using a LaunchDarkly feature flag client, this API key will be used.
*
* @return LaunchDarkly API key as a string.
*/
String getLaunchDarklyKey();

/**
* Defines a default map of environment variables to use for any launched job containers. The
* expected format is a JSON encoded String -> String map. Make sure to escape properly. Defaults to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public class EnvConfigs implements Configs {

public static final int DEFAULT_FAILED_JOBS_IN_A_ROW_BEFORE_CONNECTION_DISABLE = 100;
public static final int DEFAULT_DAYS_OF_ONLY_FAILED_JOBS_BEFORE_CONNECTION_DISABLE = 14;
public static final String LAUNCHDARKLY_KEY = "LAUNCHDARKLY_KEY";

private final Function<String, String> getEnv;
private final Supplier<Set<String>> getAllEnvKeys;
Expand Down Expand Up @@ -848,6 +849,11 @@ public String getOtelCollectorEndpoint() {
return getEnvOrDefault(OTEL_COLLECTOR_ENDPOINT, "");
}

@Override
public String getLaunchDarklyKey() {
return getEnvOrDefault(LAUNCHDARKLY_KEY, "");
}

/**
* There are two types of environment variables available to the job container:
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public ContainerOrchestratorConfig kubernetesContainerOrchestratorConfig(
environmentVariables.put(DATA_PLANE_SERVICE_ACCOUNT_EMAIL_ENV_VAR, dataPlaneServiceAccountEmail);

final Configs configs = new EnvConfigs();
environmentVariables.put(EnvConfigs.LAUNCHDARKLY_KEY, configs.getLaunchDarklyKey());
environmentVariables.put(EnvConfigs.SOCAT_KUBE_CPU_LIMIT, configs.getSocatSidecarKubeCpuLimit());
environmentVariables.put(EnvConfigs.SOCAT_KUBE_CPU_REQUEST, configs.getSocatSidecarKubeCpuRequest());

Expand Down

0 comments on commit 8fee0c4

Please sign in to comment.