Skip to main content

Launchdarkly

Our Launchdarkly integration allows you to import projects, flags, and environments from your Launchdarkly account into Port, according to your mapping and definition.

A Project in LaunchDarkly is a collection of feature flags, targeting rules, and environments that correspond to a specific application or service.

A Flag in LaunchDarkly represents a feature flag or toggle, which is a central concept in LaunchDarkly. Flags are used to control the visibility and operational state of features in your software without deploying new code.

An Environment within a LaunchDarkly project is a logical separation of feature flag states and configurations, typically corresponding to stages in your development lifecycle.

Common use cases

  • Entity Tracking - See all projects and their associated environments and feature flags.

  • Real time Synchronization of Infrastructure - Automatically synchronize projects, feature flags, and environments data from Launchdarkly into Port for centralized tracking and management.

Prerequisites

To install the integration, you need a Kubernetes cluster that the integration's container chart will be deployed to.

Please make sure that you have kubectl and helm installed on your machine, and that your kubectl CLI is connected to the Kubernetes cluster where you plan to install the integration.

Installation

Choose one of the following installation methods:

Using this installation option means that the integration will be able to update Port in real time using webhooks.

This table summarizes the available parameters for the installation. Set them as you wish in the script below, then copy it and run it in your terminal:

ParameterDescriptionRequired
port.clientIdYour Port client id
port.clientSecretYour Port client secret
port.baseUrlYour Port base url, relevant only if not using the default Port app
integration.identifierChange the identifier to describe your integration
integration.typeThe integration type
integration.eventListener.typeThe event listener type
integration.config.launchdarklyHostYour Launchdarkly host. For example https://launchdarkly.com
integration.config.launchdarklyTokenThe Launchdarkly API token
integration.config.appHostYour application's host url
scheduledResyncIntervalThe number of minutes between each resync
initializePortResourcesDefault true, When set to true the integration will create default blueprints and the port App config Mapping

To install the integration using ArgoCD, follow these steps:

  1. Create a values.yaml file in argocd/my-ocean-launchdarkly-integration in your git repository with the content:
note

Remember to replace the placeholders for LAUNCHDARKLY_HOST and LAUNCHDARKLY_TOKEN.

initializePortResources: true
scheduledResyncInterval: 120
integration:
identifier: my-ocean-launchdarkly-integration
type: launchdarkly
eventListener:
type: POLLING
secrets:
launchdarklyHost: LAUNCHDARKLY_HOST
launchdarklyToken: LAUNCHDARKLY_TOKEN

  1. Install the my-ocean-launchdarkly-integration ArgoCD Application by creating the following my-ocean-launchdarkly-integration.yaml manifest:
note

Remember to replace the placeholders for YOUR_PORT_CLIENT_ID YOUR_PORT_CLIENT_SECRET and YOUR_GIT_REPO_URL.

Multiple sources ArgoCD documentation can be found here.

ArgoCD Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-ocean-launchdarkly-integration
namespace: argocd
spec:
destination:
namespace: my-ocean-launchdarkly-integration
server: https://kubernetes.default.svc
project: default
sources:
- repoURL: 'https://port-labs.github.io/helm-charts/'
chart: port-ocean
targetRevision: 0.1.14
helm:
valueFiles:
- $values/argocd/my-ocean-launchdarkly-integration/values.yaml
parameters:
- name: port.clientId
value: YOUR_PORT_CLIENT_ID
- name: port.clientSecret
value: YOUR_PORT_CLIENT_SECRET
- repoURL: YOUR_GIT_REPO_URL
targetRevision: main
ref: values
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true

  1. Apply your application manifest with kubectl:
kubectl apply -f my-ocean-launchdarkly-integration.yaml

Event listener

The integration uses polling to pull the configuration from Port every minute and check it for changes. If there is a change, a resync will occur.

Ingesting Launchdarkly objects

The Launchdarkly integration uses a YAML configuration to describe the process of loading data into the developer portal.

Here is an example snippet from the config which demonstrates the process for getting Projects from Launchdarkly:

resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: .key
title: .name
blueprint: '"launchDarklyProject"'
properties:
tags: .tags

The integration makes use of the JQ JSON processor to select, modify, concatenate, transform and perform other operations on existing fields and values from Launchdarkly's API events.

Configuration structure

The integration configuration determines which resources will be queried from Launchdarkly, and which entities and properties will be created in Port.

Supported resources

The following resources can be used to map data from Launchdarkly, it is possible to reference any field that appears in the API responses linked below for the mapping configuration.

  • The root key of the integration configuration is the resources key:

    resources:
    - kind: project
    selector:
    ...
  • The kind key is a specifier for a Launchdarkly object:

      resources:
    - kind: project
    selector:
    ...
  • The port, entity and the mappings keys are used to map the Launchdarkly object fields to Port entities. To create multiple mappings of the same kind, you can add another item in the resources array;

resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: .key
title: .name
blueprint: '"launchDarklyProject"'
properties:
tags: .tags
Blueprint key

Note the value of the blueprint key - if you want to use a hardcoded string, you need to encapsulate it in 2 sets of quotes, for example use a pair of single-quotes (') and then another pair of double-quotes (")

Ingest data into Port

To ingest Launchdarkly objects using the integration configuration, you can follow the steps below:

  1. Go to the DevPortal Builder page.
  2. Select a blueprint you want to ingest using Launchdarkly.
  3. Choose the Ingest Data option from the menu.
  4. Select Launchdarkly under the Feature Management category.
  5. Add the contents of your integration configuration to the editor.
  6. Click Resync.

Examples

Examples of blueprints and the relevant integration configurations:

Project

Project blueprint
{
"identifier": "launchDarklyProject",
"description": "This blueprint represents a project in LaunchDarkly.",
"title": "LaunchDarkly Project",
"icon": "Launchdarkly",
"schema": {
"properties": {
"tags": {
"type": "array",
"title": "Tags",
"description": "Tags associated with the project for organizational purposes."
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}
Integration configuration
createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: .key
title: .name
blueprint: '"launchDarklyProject"'
properties:
tags: .tags

Feature Flag

Feature Flag blueprint
{
"identifier": "launchDarklyFeatureFlag",
"description": "This blueprint represents a feature flag in LaunchDarkly.",
"title": "LaunchDarkly Feature Flag",
"icon": "Launchdarkly",
"schema": {
"properties": {
"kind": {
"type": "string",
"title": "Flag Kind",
"description": "The type of the feature flag (e.g., boolean)."
},
"description": {
"type": "string",
"title": "Description",
"description": "A description of what the flag controls."
},
"creationDate": {
"type": "string",
"format": "date-time",
"title": "Creation Date",
"description": "The date and time when the flag was created."
},
"clientSideAvailability": {
"type": "object",
"title": "Client-Side Availability",
"description": "Availability of the flag for client-side applications."
},
"temporary": {
"type": "boolean",
"title": "Temporary Flag",
"description": "Indicates if the flag is temporary."
},
"tags": {
"type": "array",
"title": "Tags",
"description": "Tags associated with the feature flag."
},
"maintainer": {
"type": "string",
"title": "Maintainer",
"description": "Email address of the maintainer of the flag."
},
"customProperties": {
"type": "object",
"title": "Custom Properties",
"description": "Custom properties associated with the flag."
},
"archived": {
"type": "boolean",
"title": "Archived",
"description": "Indicates if the flag is archived."
},
"deprecated": {
"type": "boolean",
"title": "Deprecated",
"description": "Indicates if the flag is deprecated."
},
"variations": {
"type": "array",
"title": "Variations",
"description": "An array of possible variations for the flag"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"environments": {
"title": "Environments",
"target": "launchDarklyEnvironment",
"required": false,
"many": true
}
}
}
Integration configuration
createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: flag
selector:
query: "true"
port:
entity:
mappings:
identifier: .key
title: .name
blueprint: '"launchDarklyFeatureFlag"'
properties:
kind: .kind
description: .description
creationDate: .creationDate / 1000 | strftime("%Y-%m-%dT%H:%M:%SZ")
1 clientSideAvailability: .clientSideAvailability
temporary: .temporary
tags: .tags
maintainer: ._maintainer.email
deprecated: .deprecated
variations: .variations
customProperties: .customProperties
archived: .archived
relations:
environments: .environments | keys

Environment

Environment blueprint
{
"identifier": "launchDarklyEnvironment",
"description": "This blueprint represents an environment in LaunchDarkly",
"title": "LaunchDarkly Environment",
"icon": "Launchdarkly",
"schema": {
"properties": {
"defaultTtl": {
"type": "number",
"title": "Default TTL",
"description": "The default time-to-live (in minutes) for feature flag settings in this environment."
},
"secureMode": {
"type": "boolean",
"title": "Secure Mode",
"description": "Indicates whether Secure Mode is enabled for the environment, enhancing security by verifying user tokens."
},
"defaultTrackEvents": {
"type": "boolean",
"title": "Default Track Events",
"description": "Indicates whether event tracking is enabled by default for all flags in this environment."
},
"requireComments": {
"type": "boolean",
"title": "Require Comments",
"description": "Indicates whether comments are required for changes made in this environment."
},
"confirmChanges": {
"type": "boolean",
"title": "Confirm Changes",
"description": "Indicates whether changes need to be confirmed before being applied in this environment."
},
"tags": {
"type": "array",
"title": "Tags",
"description": "A list of tags associated with the environment for organizational purposes."
},
"critical": {
"type": "boolean",
"title": "Critical Environment",
"description": "Indicates whether this environment is considered critical, which may affect change management and notifications."
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"project": {
"title": "Project",
"target": "launchDarklyProject",
"required": true,
"many": false
}
}
}
Integration configuration
createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: environment
selector:
query: "true"
port:
entity:
mappings:
identifier: .key
title: .name
blueprint: '"launchDarklyEnvironment"'
properties:
defaultTtl: .defaultTtl
secureMode: .secureMode
defaultTrackEvents: .defaultTrackEvents
requireComments: .requireComments
confirmChanges: .confirmChanges
tags: .tags
critical: .critical
relations:
project: .__projectKey

Let's Test It

This section includes a sample response data from Launchdarkly. In addition, it includes the entity created from the resync event based on the Ocean configuration provided in the previous section.

Payload

Here is an example of the payload structure from Launchdarkly:

Project response data
{
"_links":{
"environments":{
"href":"/api/v2/projects/port-key-123ijk/environments",
"type":"application/json"
},
"flagDefaults":{
"href":"/api/v2/projects/port-key-123ijk/flag-defaults",
"type":"application/json"
},
"self":{
"href":"/api/v2/projects/port-key-123ijk",
"type":"application/json"
}
},
"_id":"65ac6a4c68025d0f31dff3f1",
"key":"port-key-123ijk",
"includeInSnippetByDefault":false,
"defaultClientSideAvailability":{
"usingMobileKey":true,
"usingEnvironmentId":false
},
"name":"My Project",
"tags":[

]
}
Feature Flag response data
{
"_links":{
"parent":{
"href":"/api/v2/flags/default",
"type":"application/json"
},
"self":{
"href":"/api/v2/flags/default/Test-Flag",
"type":"application/json"
}
},
"_maintainer":{
"_id":"65ac52faf4f907102dbb3771",
"_links":{
"self":{
"href":"/api/v2/members/65ac52faf4f907102dbb3771",
"type":"application/json"
}
},
"email":"example@gmail.com",
"firstName":"John",
"lastName":"Doe",
"role":"owner"
},
"_version":1,
"archived":false,
"clientSideAvailability":{
"usingEnvironmentId":true,
"usingMobileKey":true
},
"creationDate":1706601373272,
"customProperties":{

},
"defaults":{
"offVariation":1,
"onVariation":0
},
"deprecated":false,
"description":"Just a test feature flag for port integration",
"environments":{
"production":{
"_environmentName":"Production",
"_site":{
"href":"/default/production/features/Test-Flag",
"type":"text/html"
},
"_summary":{
"prerequisites":0,
"variations":{
"0":{
"contextTargets":0,
"isFallthrough":true,
"nullRules":0,
"rules":0,
"targets":0
},
"1":{
"contextTargets":0,
"isOff":true,
"nullRules":0,
"rules":0,
"targets":0
}
}
},
"archived":false,
"lastModified":1706601373293,
"on":false,
"salt":"ae374e0759e24a99adb77423ec5ca63d",
"sel":"11e557fa46f944d1a2d7cbdb3ab1e7ee",
"trackEvents":false,
"trackEventsFallthrough":false,
"version":1
},
"test":{
"_environmentName":"Test",
"_site":{
"href":"/default/test/features/Test-Flag",
"type":"text/html"
},
"_summary":{
"prerequisites":0,
"variations":{
"0":{
"contextTargets":0,
"isFallthrough":true,
"nullRules":0,
"rules":0,
"targets":0
},
"1":{
"contextTargets":0,
"isOff":true,
"nullRules":0,
"rules":0,
"targets":0
}
}
},
"archived":false,
"lastModified":1707303521285,
"on":true,
"salt":"01531d4d3bb34f8590a3fc61a75153fe",
"sel":"e18ca179630444809dbf6b1044f24b65",
"trackEvents":false,
"trackEventsFallthrough":false,
"version":4
}
},
"experiments":{
"baselineIdx":0,
"items":[

]
},
"goalIds":[

],
"includeInSnippet":true,
"key":"Test-Flag",
"kind":"boolean",
"maintainerId":"65ac52faf4f907102dbb3771",
"name":"Test-Flag",
"tags":[

],
"temporary":true,
"variationJsonSchema":"None",
"variations":[
{
"_id":"f5fe4ee4-9375-444f-81ae-ae0fd005614c",
"name":"Port-1",
"value":true
},
{
"_id":"580ffaa4-25df-4993-b19d-271acbeff35d",
"value":false
}
],
"__projectKey":"default"
}
Environment response data
{
"_links":{
"analytics":{
"href":"https://app.launchdarkly.com/snippet/events/v1/65ac65a23cf13e0f705afb2f.js",
"type":"text/html"
},
"apiKey":{
"href":"/api/v2/projects/project-key-123abc/environments/test/apiKey",
"type":"application/json"
},
"mobileKey":{
"href":"/api/v2/projects/project-key-123abc/environments/test/mobileKey",
"type":"application/json"
},
"self":{
"href":"/api/v2/projects/project-key-123abc/environments/test",
"type":"application/json"
},
"snippet":{
"href":"https://app.launchdarkly.com/snippet/features/65ac65a23cf13e0f705afb2f.js",
"type":"text/html"
}
},
"_id":"65ac65a23cf13e0f705afb2f",
"_pubnub":{
"channel":"2eba06aa9ab08f3990f8b05a36b7e7c4a4165348d8993c89572f2ea4885bc148",
"cipherKey":"2a8a255c63429ee5fc184e1be9c848fa2ced221665aa261dc66683f0227bc085"
},
"key":"test",
"name":"Test",
"apiKey":"sdk-d2e62422-4348-4302-8160-************",
"mobileKey":"mob-69006494-96b9-486b-a5cb-1d9dbbd6ae9d",
"color":"EBFF38",
"defaultTtl":0,
"secureMode":false,
"defaultTrackEvents":false,
"requireComments":false,
"confirmChanges":false,
"tags":[

],
"approvalSettings":{
"required":false,
"bypassApprovalsForPendingChanges":false,
"minNumApprovals":1,
"canReviewOwnRequest":false,
"canApplyDeclinedChanges":true,
"serviceKind":"launchdarkly",
"serviceConfig":{

},
"requiredApprovalTags":[

]
},
"critical":false,
"__projectKey":"project-key-123abc"
}

Mapping Result

The combination of the sample payload and the Ocean configuration generates the following Port entity:

Project entity in Port
{
"identifier": "port-key-123ijk",
"title": "My Project",
"team": [],
"properties": {
"tags": [],
"link": "https://app.launchdarkly.com/api/v2/projects/port-key-123ijk"
},
"relations": {},
"icon": "Launchdarkly"
}
Feature Flag entity in Port
{
"identifier": "Test-Flag",
"title": "Test-Flag",
"team": [],
"properties": {
"kind": "boolean",
"description": "Just a test feature flag for port integration",
"creationDate": "2024-01-30T07:56:13Z",
"clientSideAvailability": {
"usingEnvironmentId": true,
"usingMobileKey": true
},
"temporary": true,
"tags": [],
"maintainer": "mikeyarmah@gmail.com",
"customProperties": {},
"archived": false,
"variations": [
{
"_id": "f5fe4ee4-9375-444f-81ae-ae0fd005614c",
"name": "Port-1",
"value": true
},
{
"_id": "580ffaa4-25df-4993-b19d-271acbeff35d",
"value": false
}
],
"deprecated": false
},
"relations": {
"environments": [
"production",
"test"
]
},
"icon": "Launchdarkly"
}
Environment entity in Port
{
"identifier": "test",
"title": "Test",
"team": [],
"properties": {
"defaultTtl": 0,
"secureMode": false,
"defaultTrackEvents": false,
"requireComments": false,
"confirmChanges": false,
"tags": [],
"critical": false
},
"relations": {
"project": "default"
},
"icon": "Launchdarkly"
}