https://github.com/devcyclehq/feature-importer
DevCycle - 3rd Party Feature Importer
https://github.com/devcyclehq/feature-importer
continuous-delivery continuous-deployment devcycle devops feature-flags feature-toggles openfeature
Last synced: about 1 month ago
JSON representation
DevCycle - 3rd Party Feature Importer
- Host: GitHub
- URL: https://github.com/devcyclehq/feature-importer
- Owner: DevCycleHQ
- License: mit
- Created: 2023-02-03T18:16:33.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-17T21:18:59.000Z (4 months ago)
- Last Synced: 2024-12-17T22:24:49.789Z (4 months ago)
- Topics: continuous-delivery, continuous-deployment, devcycle, devops, feature-flags, feature-toggles, openfeature
- Language: TypeScript
- Homepage: https://docs.devcycle.com/
- Size: 489 KB
- Stars: 13
- Watchers: 6
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DevCycle Feature Importer
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.## Table of Contents
- [Setup](#setup)
- [Configuration](#configuration)
- [Required](#required)
- [Optional](#optional)
- [Code Migration](#code-migration)## Setup
1. Run `npm install` to install dependencies
2. Setup [configuration file](#configuration)
3. Run `npm start` to start import## Configuration
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.
```### Required
- 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### Optional
- 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
- 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 supportSample config.json
```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
```bash
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'
```## Code Migration
### Migrating Code from LaunchDarkly
- In LD the primary identifier is `key`, in DVC the equivalent value should be passed as `user_id`
- DVC supports the following top-level properties on the user object: see [DVC User Object](https://docs.devcycle.com/docs/sdk/client-side-sdks/javascript#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 the `anonymous` attribute, make sure to include an `anonymous` property in the user's `customData`