flags

package
v0.0.66 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 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 openfeature.IClient, 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"
	// VulnCheckErrorTemplate enables improved evaluation details
	// messages in the vulncheck rule.
	VulnCheckErrorTemplate Experiment = "vulncheck_error_template"
)

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) AddHandler

AddHandler implements openfeature.IClient.

func (*FakeClient) AddHooks

func (_ *FakeClient) AddHooks(_ ...openfeature.Hook)

AddHooks implements openfeature.IClient.

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.

func (*FakeClient) BooleanValueDetails

BooleanValueDetails implements openfeature.IClient.

func (*FakeClient) EvaluationContext

func (_ *FakeClient) EvaluationContext() openfeature.EvaluationContext

EvaluationContext implements openfeature.IClient.

func (*FakeClient) Float

Float implements openfeature.IClient.

func (*FakeClient) FloatValue

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

FloatValue implements openfeature.IClient.

func (*FakeClient) FloatValueDetails

FloatValueDetails implements openfeature.IClient.

func (*FakeClient) Int

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

Int implements openfeature.IClient.

func (*FakeClient) IntValue

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

IntValue implements openfeature.IClient.

func (*FakeClient) IntValueDetails

IntValueDetails implements openfeature.IClient.

func (*FakeClient) Metadata

func (_ *FakeClient) Metadata() openfeature.ClientMetadata

Metadata implements openfeature.IClient.

func (*FakeClient) Object

func (f *FakeClient) Object(_ context.Context, flag string, defaultValue interface{},
	_ openfeature.EvaluationContext, _ ...openfeature.Option) interface{}

Object implements openfeature.IClient.

func (*FakeClient) ObjectValue

func (f *FakeClient) ObjectValue(_ context.Context, flag string, defaultValue interface{},
	_ openfeature.EvaluationContext, _ ...openfeature.Option) (interface{}, error)

ObjectValue implements openfeature.IClient.

func (*FakeClient) ObjectValueDetails

ObjectValueDetails implements openfeature.IClient.

func (*FakeClient) RemoveHandler

func (_ *FakeClient) RemoveHandler(_ openfeature.EventType, _ openfeature.EventCallback)

RemoveHandler implements openfeature.IClient.

func (*FakeClient) SetEvaluationContext

func (_ *FakeClient) SetEvaluationContext(_ openfeature.EvaluationContext)

SetEvaluationContext implements openfeature.IClient.

func (*FakeClient) String

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

String implements openfeature.IClient.

func (*FakeClient) StringValue

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

StringValue implements openfeature.IClient.

func (*FakeClient) StringValueDetails

StringValueDetails implements openfeature.IClient.

Jump to

Keyboard shortcuts

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