config

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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"`

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

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

	// Host should be set if you are using swagger (default is localhost)
	Host string `mapstructure:"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"`

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

	// FileFormat (optional) is the format of the file to retrieve (available YAML, TOML and JSON)
	// Default: YAML
	FileFormat string `mapstructure:"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"`

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

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

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

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

	// Version is the version of the relay-proxy
	Version string
}

func ParseConfig

func ParseConfig(log *zap.Logger, version string) (*Config, error)

ParseConfig is reading the configuration file

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"`
	OutputDir        string            `mapstructure:"outputDir"`
	Format           string            `mapstructure:"format"`
	Filename         string            `mapstructure:"filename"`
	CsvTemplate      string            `mapstructure:"csvTemplate"`
	Bucket           string            `mapstructure:"bucket"`
	Path             string            `mapstructure:"path"`
	EndpointURL      string            `mapstructure:"endpointUrl"`
	Secret           string            `mapstructure:"secret"`
	Meta             map[string]string `mapstructure:"meta"`
	LogFormat        string            `mapstructure:"logFormat"`
	FlushInterval    int64             `mapstructure:"flushInterval"`
	MaxEventInMemory int64             `mapstructure:"maxEventInMemory"`
}

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

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      `mapstruct:"notifier"`
	SlackWebhookURL string            `mapstruct:"slackWebhookUrl"`
	EndpointURL     string            `mapstruct:"endpointUrl"`
	Secret          string            `mapstruct:"secret"`
	Meta            map[string]string `mapstruct:"meta"`
}

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"`
	RepositorySlug string              `mapstructure:"repositorySlug"`
	Branch         string              `mapstructure:"branch"`
	Path           string              `mapstructure:"path"`
	GithubToken    string              `mapstructure:"githubToken"`
	URL            string              `mapstructure:"url"`
	Timeout        int64               `mapstructure:"timeout"`
	HTTPMethod     string              `mapstructure:"method"`
	HTTPBody       string              `mapstructure:"body"`
	HTTPHeaders    map[string][]string `mapstructure:"headers"`
	Bucket         string              `mapstructure:"bucket"`
	Object         string              `mapstructure:"object"`
	Item           string              `mapstructure:"item"`
	Namespace      string              `mapstructure:"namespace"`
	ConfigMap      string              `mapstructure:"configmap"`
	Key            string              `mapstructure:"key"`
}

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"
	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