config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CamundaApiKeyConst      = "camunda_api"
	CamundaApiVersionConst  = "v2"
	OperateApiKeyConst      = "operate_api"
	OperateApiVersionConst  = "" // v1 by default from client side
	TasklistApiKeyConst     = "tasklist_api"
	TasklistApiVersionConst = "" // v1 by default from client side
)

Variables

View Source
var (
	ErrNoBaseURL      = errors.New("no base_url provided in api configuration")
	ErrNoTokenURL     = errors.New("no token_url provided in auth configuration")
	ErrNoClientID     = errors.New("no client_id provided in auth configuration")
	ErrNoClientSecret = errors.New("no client_secret provided in auth configuration")

	ErrNoConfigInContext       = errors.New("no config in context")
	ErrInvalidServiceInContext = errors.New("invalid config in context")

	ErrInvalidLogLevel  = errors.New("invalid log.level")
	ErrInvalidLogFormat = errors.New("invalid log.format")
)

Functions

func BindAllEnvVars added in v1.2.0

func BindAllEnvVars(v *viper.Viper, prefix string, t reflect.Type, path []string)

BindAllEnvVars recursively binds all config fields to their environment variables using mapstructure tags

func BindConfigEnvVars added in v1.2.0

func BindConfigEnvVars(v *viper.Viper)

BindConfigEnvVars binds all config fields to their environment variables using mapstructure tags

func BindConfigEnvVarsForProfile added in v1.2.0

func BindConfigEnvVarsForProfile(v *viper.Viper, cfg *Config)

Types

type API

type API struct {
	Key          string `mapstructure:"key" json:"key" yaml:"key"`
	BaseURL      string `mapstructure:"base_url" json:"base_url" yaml:"base_url"`
	RequireScope bool   `mapstructure:"require_scope" json:"require_scope" yaml:"require_scope"`
	Version      string `mapstructure:"version" json:"version" yaml:"version"`
}

type APIs

type APIs struct {
	Camunda           API  `mapstructure:"camunda_api" json:"camunda_api" yaml:"camunda_api"`
	Operate           API  `mapstructure:"operate_api" json:"operate_api" yaml:"operate_api"`
	Tasklist          API  `mapstructure:"tasklist_api" json:"tasklist_api" yaml:"tasklist_api"`
	VersioningDisable bool `mapstructure:"versioning_disable" json:"versioning_disable" yaml:"versioning_disable"`
}

func (*APIs) Normalize

func (a *APIs) Normalize() error

func (*APIs) Validate

func (a *APIs) Validate(scopes Scopes) error

type App

type App struct {
	CamundaVersion toolx.CamundaVersion `mapstructure:"camunda_version" json:"camunda_version" yaml:"camunda_version"`
	Tenant         string               `mapstructure:"tenant" json:"tenant" yaml:"tenant"`
	Backoff        BackoffConfig        `mapstructure:"backoff" json:"backoff" yaml:"backoff"`
	NoErrCodes     bool                 `mapstructure:"no_err_codes" json:"-" yaml:"-"`
}

func (*App) Normalize added in v0.1.63

func (a *App) Normalize() error

func (*App) ViewTenant

func (a *App) ViewTenant() string

type Auth

type Auth struct {
	Mode   AuthMode                    `mapstructure:"mode" json:"mode" yaml:"mode"`
	OAuth2 AuthOAuth2ClientCredentials `mapstructure:"oauth2" json:"oauth2" yaml:"oauth2"`
	Cookie AuthCookieSession           `mapstructure:"cookie" json:"cookie" yaml:"cookie"`
}

func (*Auth) Normalize added in v1.1.1

func (c *Auth) Normalize() error

func (*Auth) Validate

func (c *Auth) Validate() error

type AuthCookieSession

type AuthCookieSession struct {
	BaseURL  string `mapstructure:"base_url" json:"base_url" yaml:"base_url"`
	Username string `mapstructure:"username" json:"username" yaml:"username"`
	Password string `mapstructure:"password" json:"password" yaml:"password"`
}

func (*AuthCookieSession) Validate

func (c *AuthCookieSession) Validate() error

type AuthMode

type AuthMode string
const (
	ModeNone   AuthMode = "none"
	ModeOAuth2 AuthMode = "oauth2"
	ModeCookie AuthMode = "cookie"
)

func (AuthMode) IsValid

func (m AuthMode) IsValid() bool

type AuthOAuth2ClientCredentials

type AuthOAuth2ClientCredentials struct {
	TokenURL     string `mapstructure:"token_url" json:"token_url" yaml:"token_url"`
	ClientID     string `mapstructure:"client_id" json:"client_id" yaml:"client_id"`
	ClientSecret string `mapstructure:"client_secret" json:"client_secret" yaml:"client_secret"`
	Scopes       Scopes `mapstructure:"scopes" json:"scopes,omitempty" yaml:"scopes,omitempty"`
}

func (*AuthOAuth2ClientCredentials) Scope

func (*AuthOAuth2ClientCredentials) Validate

func (a *AuthOAuth2ClientCredentials) Validate() error

type BackoffConfig added in v1.2.0

type BackoffConfig struct {
	Strategy     BackoffStrategy `mapstructure:"strategy" json:"strategy" yaml:"strategy"`
	InitialDelay time.Duration   `mapstructure:"initial_delay" json:"initial_delay" yaml:"initial_delay"`
	MaxDelay     time.Duration   `mapstructure:"max_delay" json:"max_delay" yaml:"max_delay"`
	MaxRetries   int             `mapstructure:"max_retries" json:"max_retries" yaml:"max_retries"`
	Multiplier   float64         `mapstructure:"multiplier" json:"multiplier" yaml:"multiplier"` // Used for exponential backoff strategy
	Timeout      time.Duration   `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
}

func (*BackoffConfig) NextDelay added in v1.2.0

func (c *BackoffConfig) NextDelay(prev time.Duration) time.Duration

func (*BackoffConfig) Normalize added in v1.2.0

func (c *BackoffConfig) Normalize() error

func (*BackoffConfig) Validate added in v1.2.0

func (c *BackoffConfig) Validate() error

type BackoffStrategy added in v1.2.0

type BackoffStrategy string
const (
	BackoffFixed       BackoffStrategy = "fixed"
	BackoffExponential BackoffStrategy = "exponential"
)

type Config

type Config struct {
	Config string `mapstructure:"config" json:"-" yaml:"-"`

	App  App  `mapstructure:"app" json:"app" yaml:"app"`
	Auth Auth `mapstructure:"auth" json:"auth" yaml:"auth"`
	APIs APIs `mapstructure:"apis" json:"apis" yaml:"apis"`
	HTTP HTTP `mapstructure:"http" json:"http" yaml:"http"`
	Log  Log  `mapstructure:"log" json:"log" yaml:"log"`

	ActiveProfile string             `mapstructure:"active_profile" json:"active_profile,omitempty" yaml:"active_profile,omitempty"`
	Profiles      map[string]Profile `mapstructure:"profiles" json:"-" yaml:"-"`
}

func FromContext

func FromContext(ctx context.Context) (*Config, error)

func New added in v1.1.3

func New() *Config

func (*Config) Normalize

func (c *Config) Normalize() error

func (*Config) ToContext

func (c *Config) ToContext(ctx context.Context) context.Context

func (*Config) ToSanitizedYAML

func (c *Config) ToSanitizedYAML() (string, error)

func (*Config) ToTemplateYAML

func (c *Config) ToTemplateYAML() (string, error)

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) WithProfile added in v1.1.3

func (c *Config) WithProfile() (*Config, error)

WithProfile returns an effective config for the selected profile.

type HTTP

type HTTP struct {
	Timeout string `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
}

func (*HTTP) Normalize added in v1.1.3

func (h *HTTP) Normalize() error

func (*HTTP) Validate

func (h *HTTP) Validate() error

type Log added in v0.1.61

type Log struct {
	Level           string `mapstructure:"level" json:"level" yaml:"level"`
	Format          string `mapstructure:"format" json:"format" yaml:"format"` // "text", "json" or "plain"
	WithSource      bool   `mapstructure:"with_source" json:"with_source" yaml:"with_source"`
	WithRequestBody bool   `mapstructure:"with_request_body" json:"with_request_body" yaml:"with_request_body"`
}

func (*Log) NewLogger added in v0.1.61

func (l *Log) NewLogger() *slog.Logger

func (*Log) Normalize added in v0.1.61

func (l *Log) Normalize()

func (*Log) Validate added in v0.1.61

func (l *Log) Validate() error

type Profile added in v1.1.3

type Profile struct {
	App  App  `mapstructure:"app" json:"app" yaml:"app"`
	Auth Auth `mapstructure:"auth" json:"auth" yaml:"auth"`
	APIs APIs `mapstructure:"apis" json:"apis" yaml:"apis"`
	HTTP HTTP `mapstructure:"http" json:"http" yaml:"http"`
}

type Scopes

type Scopes map[string]string

Jump to

Keyboard shortcuts

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