launchdarkly

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionCreateFlag         = "createFlag"
	ActionUpdateOn           = "updateOn"
	ActionUpdateOffVariation = "updateOffVariation"
	ActionUpdateFallthrough  = "updateFallthrough"
	ActionUpdateRules        = "updateRules"
	ActionUpdateTargets      = "updateTargets"
	ActionDeleteFlag         = "deleteFlag"
)

LaunchDarkly webhook actions found in the accesses array.

View Source
const BaseURL = "https://app.launchdarkly.com"
View Source
const KindFlag = "flag"

LaunchDarkly webhook "kind" value for feature flag events.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	Token   string
	BaseURL string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(http core.HTTPContext, ctx core.IntegrationContext) (*Client, error)

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(req CreateWebhookRequest) (*LDWebhook, error)

CreateWebhook creates a new signed webhook in LaunchDarkly. LaunchDarkly auto-generates the signing secret if one is not provided in the request.

func (*Client) DeleteFeatureFlag

func (c *Client) DeleteFeatureFlag(projectKey, flagKey string) error

DeleteFeatureFlag deletes a feature flag by project key and flag key.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(id string) error

DeleteWebhook deletes a webhook from LaunchDarkly by its ID.

func (*Client) GetFeatureFlag

func (c *Client) GetFeatureFlag(projectKey, flagKey string) (map[string]any, error)

GetFeatureFlag returns a feature flag by project key and flag key.

func (*Client) ListEnvironments

func (c *Client) ListEnvironments(projectKey string) ([]Environment, error)

ListEnvironments returns all environments in a LaunchDarkly project.

func (*Client) ListFeatureFlags

func (c *Client) ListFeatureFlags(projectKey string) ([]FeatureFlag, error)

ListFeatureFlags returns all feature flags in a LaunchDarkly project.

func (*Client) ListProjects

func (c *Client) ListProjects() ([]Project, error)

ListProjects returns all projects in the LaunchDarkly account.

type Configuration

type Configuration struct {
	APIKey string `json:"apiKey"`
}

type CreateWebhookRequest

type CreateWebhookRequest struct {
	URL        string             `json:"url"`
	Sign       bool               `json:"sign"`
	On         bool               `json:"on"`
	Name       string             `json:"name,omitempty"`
	Statements []WebhookStatement `json:"statements,omitempty"`
}

CreateWebhookRequest is the request body for creating a LaunchDarkly webhook.

type DeleteFeatureFlag

type DeleteFeatureFlag struct{}

func (*DeleteFeatureFlag) Actions

func (c *DeleteFeatureFlag) Actions() []core.Action

func (*DeleteFeatureFlag) Cancel

func (*DeleteFeatureFlag) Cleanup

func (c *DeleteFeatureFlag) Cleanup(ctx core.SetupContext) error

func (*DeleteFeatureFlag) Color

func (c *DeleteFeatureFlag) Color() string

func (*DeleteFeatureFlag) Configuration

func (c *DeleteFeatureFlag) Configuration() []configuration.Field

func (*DeleteFeatureFlag) Description

func (c *DeleteFeatureFlag) Description() string

func (*DeleteFeatureFlag) Documentation

func (c *DeleteFeatureFlag) Documentation() string

func (*DeleteFeatureFlag) ExampleOutput

func (c *DeleteFeatureFlag) ExampleOutput() map[string]any

func (*DeleteFeatureFlag) Execute

func (c *DeleteFeatureFlag) Execute(ctx core.ExecutionContext) error

func (*DeleteFeatureFlag) HandleAction

func (c *DeleteFeatureFlag) HandleAction(ctx core.ActionContext) error

func (*DeleteFeatureFlag) HandleWebhook

func (c *DeleteFeatureFlag) HandleWebhook(ctx core.WebhookRequestContext) (int, error)

func (*DeleteFeatureFlag) Icon

func (c *DeleteFeatureFlag) Icon() string

func (*DeleteFeatureFlag) Label

func (c *DeleteFeatureFlag) Label() string

func (*DeleteFeatureFlag) Name

func (c *DeleteFeatureFlag) Name() string

func (*DeleteFeatureFlag) OutputChannels

func (c *DeleteFeatureFlag) OutputChannels(configuration any) []core.OutputChannel

func (*DeleteFeatureFlag) ProcessQueueItem

func (c *DeleteFeatureFlag) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*DeleteFeatureFlag) Setup

func (c *DeleteFeatureFlag) Setup(ctx core.SetupContext) error

type DeleteFeatureFlagSpec

type DeleteFeatureFlagSpec struct {
	ProjectKey string `json:"projectKey" mapstructure:"projectKey"`
	FlagKey    string `json:"flagKey" mapstructure:"flagKey"`
}

type Environment

type Environment struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

Environment represents a LaunchDarkly environment within a project.

type EnvironmentListResponse

type EnvironmentListResponse struct {
	Items      []Environment `json:"items"`
	TotalCount int           `json:"totalCount"`
}

EnvironmentListResponse is the API response for listing environments.

type FeatureFlag

type FeatureFlag struct {
	Key          string `json:"key"`
	Name         string `json:"name"`
	Description  string `json:"description"`
	Kind         string `json:"kind"`
	CreationDate int64  `json:"creationDate"`
	Archived     bool   `json:"archived"`
	Temporary    bool   `json:"temporary"`
}

FeatureFlag represents a LaunchDarkly feature flag.

type FeatureFlagListResponse

type FeatureFlagListResponse struct {
	Items      []FeatureFlag `json:"items"`
	TotalCount int           `json:"totalCount"`
}

FeatureFlagListResponse is the API response for listing feature flags.

type GetFeatureFlag

type GetFeatureFlag struct{}

func (*GetFeatureFlag) Actions

func (c *GetFeatureFlag) Actions() []core.Action

func (*GetFeatureFlag) Cancel

func (c *GetFeatureFlag) Cancel(ctx core.ExecutionContext) error

func (*GetFeatureFlag) Cleanup

func (c *GetFeatureFlag) Cleanup(ctx core.SetupContext) error

func (*GetFeatureFlag) Color

func (c *GetFeatureFlag) Color() string

func (*GetFeatureFlag) Configuration

func (c *GetFeatureFlag) Configuration() []configuration.Field

func (*GetFeatureFlag) Description

func (c *GetFeatureFlag) Description() string

func (*GetFeatureFlag) Documentation

func (c *GetFeatureFlag) Documentation() string

func (*GetFeatureFlag) ExampleOutput

func (c *GetFeatureFlag) ExampleOutput() map[string]any

func (*GetFeatureFlag) Execute

func (c *GetFeatureFlag) Execute(ctx core.ExecutionContext) error

func (*GetFeatureFlag) HandleAction

func (c *GetFeatureFlag) HandleAction(ctx core.ActionContext) error

func (*GetFeatureFlag) HandleWebhook

func (c *GetFeatureFlag) HandleWebhook(ctx core.WebhookRequestContext) (int, error)

func (*GetFeatureFlag) Icon

func (c *GetFeatureFlag) Icon() string

func (*GetFeatureFlag) Label

func (c *GetFeatureFlag) Label() string

func (*GetFeatureFlag) Name

func (c *GetFeatureFlag) Name() string

func (*GetFeatureFlag) OutputChannels

func (c *GetFeatureFlag) OutputChannels(configuration any) []core.OutputChannel

func (*GetFeatureFlag) ProcessQueueItem

func (c *GetFeatureFlag) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*GetFeatureFlag) Setup

func (c *GetFeatureFlag) Setup(ctx core.SetupContext) error

type GetFeatureFlagSpec

type GetFeatureFlagSpec struct {
	ProjectKey string `json:"projectKey" mapstructure:"projectKey"`
	FlagKey    string `json:"flagKey" mapstructure:"flagKey"`
}

type LDWebhook

type LDWebhook struct {
	ID     string `json:"_id"`
	Secret string `json:"secret"`
}

LDWebhook is the response from creating a webhook. The _id field is the webhook ID needed later for deletion.

type LaunchDarkly

type LaunchDarkly struct{}

func (*LaunchDarkly) Actions

func (l *LaunchDarkly) Actions() []core.Action

func (*LaunchDarkly) Cleanup

func (*LaunchDarkly) Components

func (l *LaunchDarkly) Components() []core.Component

func (*LaunchDarkly) Configuration

func (l *LaunchDarkly) Configuration() []configuration.Field

func (*LaunchDarkly) Description

func (l *LaunchDarkly) Description() string

func (*LaunchDarkly) HandleAction

func (l *LaunchDarkly) HandleAction(ctx core.IntegrationActionContext) error

func (*LaunchDarkly) HandleRequest

func (l *LaunchDarkly) HandleRequest(ctx core.HTTPRequestContext)

func (*LaunchDarkly) Icon

func (l *LaunchDarkly) Icon() string

func (*LaunchDarkly) Instructions

func (l *LaunchDarkly) Instructions() string

func (*LaunchDarkly) Label

func (l *LaunchDarkly) Label() string

func (*LaunchDarkly) ListResources

func (l *LaunchDarkly) ListResources(resourceType string, ctx core.ListResourcesContext) ([]core.IntegrationResource, error)

func (*LaunchDarkly) Name

func (l *LaunchDarkly) Name() string

func (*LaunchDarkly) Sync

func (l *LaunchDarkly) Sync(ctx core.SyncContext) error

func (*LaunchDarkly) Triggers

func (l *LaunchDarkly) Triggers() []core.Trigger

type LaunchDarklyWebhookHandler

type LaunchDarklyWebhookHandler struct{}

func (*LaunchDarklyWebhookHandler) Cleanup

Cleanup deletes the webhook from LaunchDarkly when the trigger is removed.

func (*LaunchDarklyWebhookHandler) CompareConfig

func (h *LaunchDarklyWebhookHandler) CompareConfig(a, b any) (bool, error)

func (*LaunchDarklyWebhookHandler) Merge

func (h *LaunchDarklyWebhookHandler) Merge(current, requested any) (any, bool, error)

func (*LaunchDarklyWebhookHandler) Setup

Setup creates a signed webhook in LaunchDarkly via the API using the integration's API key. LaunchDarkly auto-generates the signing secret, which we store encrypted for later verification.

type OnFeatureFlagChange

type OnFeatureFlagChange struct{}

func (*OnFeatureFlagChange) Actions

func (t *OnFeatureFlagChange) Actions() []core.Action

func (*OnFeatureFlagChange) Cleanup

func (t *OnFeatureFlagChange) Cleanup(ctx core.TriggerContext) error

func (*OnFeatureFlagChange) Color

func (t *OnFeatureFlagChange) Color() string

func (*OnFeatureFlagChange) Configuration

func (t *OnFeatureFlagChange) Configuration() []configuration.Field

func (*OnFeatureFlagChange) Description

func (t *OnFeatureFlagChange) Description() string

func (*OnFeatureFlagChange) Documentation

func (t *OnFeatureFlagChange) Documentation() string

func (*OnFeatureFlagChange) ExampleData

func (t *OnFeatureFlagChange) ExampleData() map[string]any

func (*OnFeatureFlagChange) HandleAction

func (t *OnFeatureFlagChange) HandleAction(ctx core.TriggerActionContext) (map[string]any, error)

func (*OnFeatureFlagChange) HandleWebhook

func (t *OnFeatureFlagChange) HandleWebhook(ctx core.WebhookRequestContext) (int, error)

func (*OnFeatureFlagChange) Icon

func (t *OnFeatureFlagChange) Icon() string

func (*OnFeatureFlagChange) Label

func (t *OnFeatureFlagChange) Label() string

func (*OnFeatureFlagChange) Name

func (t *OnFeatureFlagChange) Name() string

func (*OnFeatureFlagChange) Setup

type OnFeatureFlagChangeConfiguration

type OnFeatureFlagChangeConfiguration struct {
	ProjectKey   string                    `json:"projectKey" mapstructure:"projectKey"`
	Environments []string                  `json:"environments" mapstructure:"environments"`
	Flags        []configuration.Predicate `json:"flags" mapstructure:"flags"`
	Actions      []string                  `json:"actions" mapstructure:"actions"`
}

type Project

type Project struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

Project represents a LaunchDarkly project.

type ProjectListResponse

type ProjectListResponse struct {
	Items      []Project `json:"items"`
	TotalCount int       `json:"totalCount"`
}

ProjectListResponse is the API response for listing projects.

type WebhookConfiguration

type WebhookConfiguration struct {
	ProjectKey string `json:"projectKey" mapstructure:"projectKey"`
}

WebhookConfiguration is the config stored with the webhook.

type WebhookMetadata

type WebhookMetadata struct {
	LDWebhookID string `json:"ldWebhookId"`
}

WebhookMetadata is stored after Setup. It holds the LaunchDarkly webhook ID so we can delete it when the trigger is removed.

type WebhookStatement

type WebhookStatement struct {
	Effect    string   `json:"effect"`
	Resources []string `json:"resources,omitempty"`
	Actions   []string `json:"actions,omitempty"`
}

WebhookStatement is a policy statement that filters which resource/action combinations the webhook responds to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL