config

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultExporter = struct {
	Format                  string
	LogFormat               string
	FileName                string
	CsvFormat               string
	FlushInterval           time.Duration
	MaxEventInMemory        int64
	ParquetCompressionCodec string
}{
	Format:    "JSON",
	LogFormat: "[{{ .FormattedDate}}] user=\"{{ .UserKey}}\", flag=\"{{ .Key}}\", value=\"{{ .Value}}\"",
	FileName:  "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
	CsvFormat: "{{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};" +
		"{{ .Value}};{{ .Default}};{{ .Source}}\n",
	FlushInterval:           60000 * time.Millisecond,
	MaxEventInMemory:        100000,
	ParquetCompressionCodec: parquet.CompressionCodec_SNAPPY.String(),
}
View Source
var DefaultRetriever = struct {
	Timeout    time.Duration
	HTTPMethod string
	GitBranch  string
}{
	Timeout:    10 * time.Second,
	HTTPMethod: http.MethodGet,
	GitBranch:  "main",
}

Functions

This section is empty.

Types

type Config

type Config struct {
	// ListenPort (optional) is the port we are using to start the proxy
	ListenPort int `mapstructure:"listen" koanf:"listen"`

	// HideBanner (optional) if true, we don't display the go-feature-flag relay proxy banner
	HideBanner bool `mapstructure:"hideBanner" koanf:"hidebanner"`

	// EnableSwagger (optional) to have access to the swagger
	EnableSwagger bool `mapstructure:"enableSwagger" koanf:"enableswagger"`

	// Host should be set if you are using swagger (default is localhost)
	Host string `mapstructure:"host" koanf:"host"`

	// Debug (optional) if true, go-feature-flag relay proxy will run on debug mode, with more logs and custom responses
	Debug bool `mapstructure:"debug" koanf:"debug"`

	// PollingInterval (optional) Poll every X time
	// The minimum possible is 1 second
	// Default: 60 seconds
	PollingInterval int `mapstructure:"pollingInterval" koanf:"pollinginterval"`

	// EnablePollingJitter (optional) set to true if you want to avoid having true periodicity when
	// retrieving your flags. It is useful to avoid having spike on your flag configuration storage
	// in case your application is starting multiple instance at the same time.
	// We ensure a deviation that is maximum + or - 10% of your polling interval.
	// Default: false
	EnablePollingJitter bool `mapstructure:"enablePollingJitter" koanf:"enablepollingjitter"`

	// FileFormat (optional) is the format of the file to retrieve (available YAML, TOML and JSON)
	// Default: YAML
	FileFormat string `mapstructure:"fileFormat" koanf:"fileformat"`

	// StartWithRetrieverError (optional) If true, the relay proxy will start even if we did not get any flags from
	// the retriever. It will serve only default values until the retriever returns the flags.
	// The init method will not return any error if the flag file is unreachable.
	// Default: false
	StartWithRetrieverError bool `mapstructure:"startWithRetrieverError" koanf:"startwithretrievererror"`

	// Retriever is the configuration on how to retrieve the file
	Retriever *RetrieverConf `mapstructure:"retriever" koanf:"retriever"`

	// Retrievers is the exact same things than Retriever but allows to give more than 1 retriever at the time.
	// We are dealing with config files in order, if you have the same flag name in multiple files it will be override
	// based of the order of the retrievers in the slice.
	//
	// Note: If both Retriever and Retrievers are set, we will start by calling the Retriever and,
	// after we will use the order of Retrievers.
	Retrievers *[]RetrieverConf `mapstructure:"retrievers" koanf:"retrievers"`

	// Exporter is the configuration on how to export data
	Exporter *ExporterConf `mapstructure:"exporter" koanf:"exporter"`

	// Notifiers is the configuration on where to notify a flag change
	Notifiers []NotifierConf `mapstructure:"notifier" koanf:"notifier"`

	// RestAPITimeout is the timeout on the API.
	RestAPITimeout int `mapstructure:"restApiTimeout" koanf:"restapitimeout"`

	// Version is the version of the relay-proxy
	Version string `mapstructure:"version" koanf:"version"`

	// APIKeys list of API keys that authorized to use endpoints
	APIKeys []string `mapstructure:"apiKeys" koanf:"apikeys"`

	// StartAsAwsLambda (optional) if true the relay proxy will start ready to be launch as AWS Lambda
	StartAsAwsLambda bool `mapstructure:"startAsAwsLambda" koanf:"startasawslambda"`
	// contains filtered or unexported fields
}

func New added in v1.8.1

func New(flagSet *pflag.FlagSet, log *zap.Logger, version string) (*Config, error)

New is reading the configuration file

func (*Config) APIKeyExists added in v1.7.0

func (c *Config) APIKeyExists(apiKey string) bool

APIKeyExists is checking if an API Key exist in the relay proxy configuration

func (*Config) IsValid

func (c *Config) IsValid() error

IsValid contains all the validation of the configuration.

type ExporterConf

type ExporterConf struct {
	Kind                    ExporterKind        `mapstructure:"kind" koanf:"kind"`
	OutputDir               string              `mapstructure:"outputDir" koanf:"outputdir"`
	Format                  string              `mapstructure:"format" koanf:"format"`
	Filename                string              `mapstructure:"filename" koanf:"filename"`
	CsvTemplate             string              `mapstructure:"csvTemplate" koanf:"csvtemplate"`
	Bucket                  string              `mapstructure:"bucket" koanf:"bucket"`
	Path                    string              `mapstructure:"path" koanf:"path"`
	EndpointURL             string              `mapstructure:"endpointUrl" koanf:"endpointurl"`
	Secret                  string              `mapstructure:"secret" koanf:"secret"`
	Meta                    map[string]string   `mapstructure:"meta" koanf:"meta"`
	LogFormat               string              `mapstructure:"logFormat" koanf:"logformat"`
	FlushInterval           int64               `mapstructure:"flushInterval" koanf:"flushinterval"`
	MaxEventInMemory        int64               `mapstructure:"maxEventInMemory" koanf:"maxeventinmemory"`
	ParquetCompressionCodec string              `mapstructure:"parquetCompressionCodec" koanf:"parquetcompressioncodec"`
	Headers                 map[string][]string `mapstructure:"headers" koanf:"headers"`
	QueueURL                string              `mapstructure:"queueUrl" koanf:"queueurl"`
}

ExporterConf contains all the field to configure an exporter

func (*ExporterConf) IsValid

func (c *ExporterConf) IsValid() error

type ExporterKind

type ExporterKind string
const (
	FileExporter          ExporterKind = "file"
	WebhookExporter       ExporterKind = "webhook"
	LogExporter           ExporterKind = "log"
	S3Exporter            ExporterKind = "s3"
	GoogleStorageExporter ExporterKind = "googleStorage"
	SQSExporter           ExporterKind = "sqs"
)

func (ExporterKind) IsValid

func (r ExporterKind) IsValid() error

IsValid is checking if the value is part of the enum

type NotifierConf

type NotifierConf struct {
	Kind            NotifierKind        `mapstructure:"kind" koanf:"kind"`
	SlackWebhookURL string              `mapstructure:"slackWebhookUrl" koanf:"slackWebhookUrl"`
	EndpointURL     string              `mapstructure:"endpointUrl" koanf:"endpointUrl"`
	Secret          string              `mapstructure:"secret" koanf:"secret"`
	Meta            map[string]string   `mapstructure:"meta" koanf:"meta"`
	Headers         map[string][]string `mapstructure:"headers" koanf:"headers"`
}

func (*NotifierConf) IsValid

func (c *NotifierConf) IsValid() error

type NotifierKind

type NotifierKind string
const (
	SlackNotifier   NotifierKind = "slack"
	WebhookNotifier NotifierKind = "webhook"
)

func (NotifierKind) IsValid

func (r NotifierKind) IsValid() error

IsValid is checking if the value is part of the enum

type RetrieverConf

type RetrieverConf struct {
	Kind           RetrieverKind `mapstructure:"kind" koanf:"kind"`
	RepositorySlug string        `mapstructure:"repositorySlug" koanf:"repositoryslug"`
	Branch         string        `mapstructure:"branch" koanf:"branch"`
	Path           string        `mapstructure:"path" koanf:"path"`
	// Deprecated: Please use AuthToken instead
	GithubToken string              `mapstructure:"githubToken" koanf:"githubtoken"`
	URL         string              `mapstructure:"url" koanf:"url"`
	Timeout     int64               `mapstructure:"timeout" koanf:"timeout"`
	HTTPMethod  string              `mapstructure:"method" koanf:"method"`
	HTTPBody    string              `mapstructure:"body" koanf:"body"`
	HTTPHeaders map[string][]string `mapstructure:"headers" koanf:"headers"`
	Bucket      string              `mapstructure:"bucket" koanf:"bucket"`
	Object      string              `mapstructure:"bucket" koanf:"bucket"`
	Item        string              `mapstructure:"item" koanf:"item"`
	Namespace   string              `mapstructure:"namespace" koanf:"namespace"`
	ConfigMap   string              `mapstructure:"configmap" koanf:"configmap"`
	Key         string              `mapstructure:"key" koanf:"key"`
	BaseURL     string              `mapstructure:"baseUrl" koanf:"baseurl"`
	AuthToken   string              `mapstructure:"token" koanf:"token"`
}

RetrieverConf contains all the field to configure a retriever

func (*RetrieverConf) IsValid

func (c *RetrieverConf) IsValid() error

IsValid validate the configuration of the retriever nolint:gocognit

type RetrieverKind

type RetrieverKind string

RetrieverKind is an enum containing all accepted Retriever kind

const (
	HTTPRetriever          RetrieverKind = "http"
	GitHubRetriever        RetrieverKind = "github"
	GitlabRetriever        RetrieverKind = "gitlab"
	S3Retriever            RetrieverKind = "s3"
	FileRetriever          RetrieverKind = "file"
	GoogleStorageRetriever RetrieverKind = "googleStorage"
	KubernetesRetriever    RetrieverKind = "configmap"
)

func (RetrieverKind) IsValid

func (r RetrieverKind) IsValid() error

IsValid is checking if the value is part of the enum

Jump to

Keyboard shortcuts

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