## What This PR removes or updates references in the docs to Heroku. Most of the code samples have been replaced with a more generic `unleash.example.com` url, while other references have been removed or updated. Also removes old OpenAPI files that are out of date and redundant with the new generation. ## Background Come November and Heroku will no longer offer free deployments of Unleash, so it's about time we remove that claim. Links to the heroku instance are also outdated because we don't have that instance running anymore. Finally, the OpenAPI files we do have there are old and static, so they don't match the current reality. ## Commits * Meta: update ignore file to ignore autogenerated docs I must've missed the ignore file when looking for patterns. * docs: delete old openapi file. This seems to have been a holdover from 2020 and is probably hand-written. It has been superseded by the new autogenerated OpenAPI docs. * docs: add notes for heroku changes to the frontend readme and pkg * docs: remove old openapi article and add redirects to new openapi * docs: fix link in overview doc: point to GitHub instead of heroku * docs: update quickstart docs with new heroku details * docs: remove reference to crashing heroku instance * docs: remove references to herokuapp in code samples * docs: add a placeholder comment * docs: update references for heroku updates * docs: keep using unleash4 for enterprise * docs: remove start:heroku script in favor of start:sandbox * docs: remove 'deploy on heroku button' Now that it's not free anymore (or won't be very shortly), let's remove it. * docs: remove extra newline
5.8 KiB
id | title |
---|---|
import_export | Import & Export |
since v3.3.0
Unleash supports import and export of feature toggles and strategies at startup and during runtime. The import mechanism guarantees that:
- all imported features will be non-archived
- existing updates to strategies and features are included in the event history
All import mechanisms support a drop
parameter which will clean the database before import (all strategies and features will be removed).
:::caution Dropping in production
Be careful when using the drop
parameter in production environments: cleaning the database could lead to unintended loss of data.
:::
Runtime import & export
State Service
Unleash returns a StateService when started, you can use this to import and export data at any time.
const unleash = require('unleash-server');
const { services } = await unleash.start({...});
const { stateService } = services;
const exportedData = await stateService.export({includeStrategies: false, includeFeatureToggles: true, includeTags: true, includeProjects: true});
await stateService.import({data: exportedData, userName: 'import', dropBeforeImport: false});
await stateService.importFile({file: 'exported-data.yml', userName: 'import', dropBeforeImport: true})
If you want the database to be cleaned before import (all strategies and features will be removed), set the dropBeforeImport
parameter.
It is also possible to not override existing feature toggles (and strategies) by using the keepExisting
parameter.
API Export
The api endpoint /api/admin/state/export
will export feature-toggles and strategies as json by default.
You can customize the export with query parameters:
Parameter | Default | Description |
---|---|---|
format | json |
Export format, either json or yaml |
download | false |
If the exported data should be downloaded as a file |
featureToggles | true |
Include feature-toggles in the exported data |
strategies | true |
Include strategies in the exported data |
tags | true |
Include tagtypes, tags and feature_tags in the exported data |
projects | true |
Include projects in the exported data |
For example if you want to download just feature-toggles as yaml:
/api/admin/state/export?format=yaml&featureToggles=1&strategies=0&tags=0&projects=0&download=1
Example with curl:
curl -X GET -H "Content-Type: application/json" \
-H "Authorization: Basic YWRtaW46" \
https://unleash.example.com/api/admin/state/export?&featureToggles=1&strategies=0 > export.json
API Import
You can import feature-toggles and strategies by POSTing to the /api/admin/state/import
endpoint (keep in mind this will require authentication).
You can either send the data as JSON in the POST-body or send a file
parameter with multipart/form-data
(YAML files are also accepted here).
You can customize the import with query parameters:
Parameter | Default | Description |
---|---|---|
drop | false |
If the database should be cleaned before import (see comment below) |
keep | true |
If true, the existing feature toggles and strategies will not be override |
If you want the database to be cleaned before import (all strategies and features will be removed), specify a drop
query parameter.
You should never use this in production environments.
Example usage:
POST /api/admin/state/import
{
"features": [
{
"name": "a-feature-toggle",
"enabled": true,
"description": "#1 feature-toggle"
}
]
}
Example with curl:
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Basic YWRtaW46" -d @export.json \
http://localhost:4242/api/admin/state/import
*) Remember to set correct token for Authorization.
Startup import
You can import toggles and strategies on startup by using an import file in JSON or YAML format. As with other forms of imports, you can also choose to remove the current toggle and strategy configuration in the database before importing.
Unleash lets you do this both via configuration parameters and environment variables. The relevant parameters/variables are:
config parameter | environment variable | default | value |
---|---|---|---|
importFile |
IMPORT_FILE |
none | path to the configuration file |
dropBeforeImport |
IMPORT_DROP_BEFORE_IMPORT |
false |
whether to clean the database before importing the file |
Importing files
To import strategies and toggles from a file (called configuration.yml
in the examples below), either
-
use the
importFile
parameter to point to the file (you can also passed this into theunleash.start()
entry point)unleash-server --databaseUrl [...] \ --importFile configuration.yml
-
set the
IMPORT_FILE
environment variable to the path of the file before starting UnleashIMPORT_FILE=configuration.yml
Drop before import
:::caution You should never use this in production environments. :::
To remove pre-existing feature toggles and strategies in the database before importing the new ones, either:
-
add the
dropBeforeImport
flag to theunleash-server
command (or tounleash.start()
)unleash-server --databaseUrl [...] \ --importFile configuration.yml \ --dropBeforeImport
-
set the
IMPORT_DROP_BEFORE_IMPORT
environment variable (note the leadingIMPORT_
) totrue
,t
, or1
. The variable is case-sensitive.IMPORT_DROP_BEFORE_IMPORT=true