DevCycle's Feature Importer is designed to import resources from other feature flag providers. The importer is intended to be run on a single project and will create or update a project with the same key containing Environments, Features, and Variables.
- Run
npm install
to install dependencies - Setup configuration file
- Run
npm start
to start import
The feature importer can be configured using environment variables or a JSON config file.
By default the config is read from config.json
in the project root, this can be overwritten using CONFIG_FILE_PATH
.
Note: This feature importer only supports LaunchDarkly API Version `20220603`. Please select this version when creating an API access token in LaunchDarkly.
- ldAccessToken: string
- LaunchDarkly access token, used for pulling feature flags
- Equivalent env var: LD_ACCESS_TOKEN
- dvcClientId: string
- DevCycle client ID, used for fetching API credentials
- Equivalent env var: DVC_CLIENT_ID
- dvcClientSecret: string
- DevCycle client secret, used for fetching API credentials
- Equivalent env var: DVC_CLIENT_SECRET
- sourceProjectKey: string
- LaunchDarkly's project key, resources will be pulled from this project
- Equivalent env var: SOURCE_PROJECT_KEY
- targetProjectKey: string
- A DevCycle project key, resources will be created within this project. A project will be created with this key if it does not already exist.
- If not specified, the target project key will be used
- Equivalent env var: TARGET_PROJECT_KEY
- includeFeatures: string[]
- An array of LD feature flag keys to be imported. By default, the importer will attempt to migrate all features.
- Equivalent env var: INCLUDE_FEATURES
- excludeFeatures: string[]
- An array of LD feature flag keys to be skipped when importing.
- Equivalent env var: EXCLUDE_FEATURES
- overwriteDuplicates: boolean
- If true, when the importer encounters a duplicate resource it will be overwritten. By default, duplicates will be skipped.
- Equivalent env var: OVERWRITE_DUPLICATES
- operationMap: Map<string, string>
- A map of LD operations to map to DevCycle operations
- DevCycle operations:
=
,!=
,>
,<
,>=
,<=
,contain
,!contain
,exist
,!exist
,startWith
,!startWith
,endWith
,!endWith
- Equivalent env var: OPERATION_MAP
- provider: string
- The provider to import the feature flags from.
- currently only
launchdarkly
is supported but this will extend with support
Sample config.json
{
"ldAccessToken": "api-key",
"dvcClientId": "clientId",
"dvcClientSecret": "clientSecret",
"sourceProjectKey": "project-key",
"includeFeatures": ["feat-1", "feat-2"],
"excludeFeatures": [],
"overwriteDuplicates": false,
"operationMap": {
"startsWith": "contain",
"endsWith": "contain"
},
"provider":"launchdarkly"
}
Sample .env file
LD_ACCESS_TOKEN="api-key"
DVC_CLIENT_ID="clientId"
DVC_CLIENT_SECRET="clientSecret"
SOURCE_PROJECT_KEY="project-key"
INCLUDE_FEATURES=[feat-1,feat-2]
EXCLUDE_FEATURES=[]
OVERWRITE_DUPLICATES=false
OPERATION_MAP='{"endsWith":"contain","startsWith":"contain"}'
PROVIDER='launchdarkly'
- In LD the primary identifier is
key
, in DVC the equivalent value should be passed asuser_id
- DVC supports the following top-level properties on the user object: see DVC User Object.
Any other properties used for targeting should be passed within the
customData
map. - If you are passing a date to be used with LD's before/after operators, the value should to be converted to a long when passed to DVC. The importer will convert
before
&after
operators to<
&>
in DVC. - DVC doesn't support targeting by the top-level
isAnonymous
property. If you are using LD's targeting with theanonymous
attribute, make sure to include ananonymous
property in the user'scustomData