flags

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 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 (
	// DockerHubProvider enables the DockerHub provider.
	DockerHubProvider Experiment = "dockerhub_provider"
	// GitLabProvider enables the GitLab provider.
	GitLabProvider Experiment = "gitlab_provider"
	// AlternateMessageDriver enables an an alternate message driver.
	AlternateMessageDriver Experiment = "alternate_message_driver"
	// 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"
	// RegoV1DualParse enables dual-parse version detection (try V1, fall back
	// to V0) when creating or updating rule types. When disabled, all rule
	// types are treated as Rego V0.
	RegoV1DualParse Experiment = "rego_v1_dual_parse"
	// RegoV1WarnV0 adds a non-fatal warning to rule type create and update
	// responses when the accepted policy is evaluated as Rego V0.
	RegoV1WarnV0 Experiment = "rego_v1_warn_v0"
)

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