flags

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package flags containts utilities for managing feature flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(ctx context.Context, client Interface, feature Experiment) bool

Bool provides a simple wrapper around client.Boolean to normalize usage for Minder.

func OpenFeatureProviderFromFlags

func OpenFeatureProviderFromFlags(ctx context.Context, cfg config.FlagsConfig)

OpenFeatureProviderFromFlags installs an OpenFeature Provider based on the flags config. This curently only supports the GoFeatureFlag file-based provider.

Types

type Experiment

type Experiment string

Experiment is a type alias for a feature flag experiment, to ensure that all feature flags are registered in constants.go, not littered all over the codebase.

const (
	// UserManagement enables user management, i.e. invitations, role assignments, etc.
	UserManagement Experiment = "user_management"
	// DockerHubProvider enables the DockerHub provider.
	DockerHubProvider Experiment = "dockerhub_provider"
	// GitLabProvider enables the GitLab provider.
	GitLabProvider Experiment = "gitlab_provider"
	// MachineAccounts enables machine accounts (in particular, GitHub Actions) for authorization
	MachineAccounts Experiment = "machine_accounts"
	// AlternateMessageDriver enables an an alternate message driver.
	AlternateMessageDriver Experiment = "alternate_message_driver"
	// GitPRDiffs enables the git ingester for pull requests.
	GitPRDiffs Experiment = "git_pr_diffs"
	// DependencyExtract enables functions to perform dependency extraction.
	DependencyExtract Experiment = "dependency_extract"
	// ProjectCreateDelete enables creating top-level projects and deleting them.
	ProjectCreateDelete Experiment = "project_create_delete"
	// AuthenticatedDataSources enables provider authentication for data sources.
	AuthenticatedDataSources Experiment = "authenticated_datasources"
)

type FakeClient

type FakeClient struct {
	Data map[string]any
}

FakeClient implements a simple in-memory client for testing.

see https://github.com/open-feature/go-sdk/issues/266 for the proper support.

func (*FakeClient) Boolean

func (f *FakeClient) Boolean(_ context.Context, flag string, defaultValue bool,
	_ openfeature.EvaluationContext, _ ...openfeature.Option) bool

Boolean implements openfeature.IClient.

func (*FakeClient) BooleanValue

func (f *FakeClient) BooleanValue(_ context.Context, flag string, defaultValue bool,
	_ openfeature.EvaluationContext, _ ...openfeature.Option) (bool, error)

BooleanValue implements openfeature.IClient.

type Interface

type Interface interface {
	Boolean(ctx context.Context, key string, defaultValue bool, ec openfeature.EvaluationContext, options ...openfeature.Option) bool
}

Interface is a limited slice of openfeature.IClient, using only the methods we need. This prevents breakage when the openfeature.IClient interface changes.

Jump to

Keyboard shortcuts

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