config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

configuration management using a yaml configuration file You must have called LoadConfiguration() or otherwise set up the configuration before you can use these.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorConfigArgumentMissing = errors.New("configuration file argument missing. Please specify using -config argument. Aborting")
	ErrorConfigFile            = errors.New("failed to read or parse configuration file. Aborting")
)

Functions

func AttendeeServiceBaseUrl

func AttendeeServiceBaseUrl() string

func ConcardisDownstreamBaseUrl

func ConcardisDownstreamBaseUrl() string

func ConcardisInstanceApiSecret

func ConcardisInstanceApiSecret() string

func ConcardisInstanceName

func ConcardisInstanceName() string

func DatabaseMysqlConnectString

func DatabaseMysqlConnectString() string

func ErrorNotifyMail

func ErrorNotifyMail() string

func FailureRedirect

func FailureRedirect() string

func FixedApiToken

func FixedApiToken() string

func InvoiceDescription

func InvoiceDescription() string

func InvoicePurpose

func InvoicePurpose() string

func InvoiceTitle

func InvoiceTitle() string

func IsCorsDisabled

func IsCorsDisabled() bool

func LoadTestingConfigurationFromPathOrAbort

func LoadTestingConfigurationFromPathOrAbort(configFilenameForTests string)

LoadTestingConfigurationFromPathOrAbort is for tests to set a hardcoded yaml configuration

func LogFullRequests

func LogFullRequests() bool

func LoggingSeverity

func LoggingSeverity() string

func MailServiceBaseUrl

func MailServiceBaseUrl() string

func MigrateDatabase

func MigrateDatabase() bool

func ParseCommandLineFlags

func ParseCommandLineFlags()

ParseCommandLineFlags is exposed separately so you can skip it for tests

func PaymentServiceBaseUrl

func PaymentServiceBaseUrl() string

func ServerAddr

func ServerAddr() string

func ServerIdleTimeout

func ServerIdleTimeout() time.Duration

func ServerReadTimeout

func ServerReadTimeout() time.Duration

func ServerWriteTimeout

func ServerWriteTimeout() time.Duration

func ServicePublicURL

func ServicePublicURL() string

func StartupLoadConfiguration

func StartupLoadConfiguration() error

func SuccessRedirect

func SuccessRedirect() string

func TransactionIDPrefix

func TransactionIDPrefix() string

func UseEcsLogging

func UseEcsLogging() bool

func WebhookSecret

func WebhookSecret() string

Types

type Application

type Application struct {
	Service  ServiceConfig  `yaml:"service"`
	Server   ServerConfig   `yaml:"server"`
	Database DatabaseConfig `yaml:"database"`
	Logging  LoggingConfig  `yaml:"logging"`
	Security SecurityConfig `yaml:"security"`
	Invoice  InvoiceConfig  `yaml:"invoice"`
}

Application is the root configuration type

func Configuration

func Configuration() *Application

type CorsConfig

type CorsConfig struct {
	DisableCors bool   `yaml:"disable"`
	AllowOrigin string `yaml:"allow_origin"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Use        DatabaseType `yaml:"use"`
	Username   string       `yaml:"username"`
	Password   string       `yaml:"password"`
	Database   string       `yaml:"database"`
	Parameters []string     `yaml:"parameters"`
}

DatabaseConfig configures which db to use (mysql, inmemory) and how to connect to it (needed for mysql only)

type DatabaseType

type DatabaseType string
const (
	Inmemory DatabaseType = "inmemory"
	Mysql    DatabaseType = "mysql"
)

func DatabaseUse

func DatabaseUse() DatabaseType

type FixedTokenConfig

type FixedTokenConfig struct {
	Api     string `yaml:"api"`     // shared-secret for server-to-server backend authentication
	Webhook string `yaml:"webhook"` // shared-secret for the webhook coming in from concardis
}

type InvoiceConfig

type InvoiceConfig struct {
	Title       string `yaml:"title"`
	Description string `yaml:"description"`
	Purpose     string `yaml:"purpose"`
}

InvoiceConfig defines what the invoices should look like

type LoggingConfig

type LoggingConfig struct {
	Severity        string `yaml:"severity"`
	FullRequests    bool   `yaml:"full_requests"`
	ErrorNotifyMail string `yaml:"error_notify_mail"`
}

LoggingConfig configures logging

type SecurityConfig

type SecurityConfig struct {
	Fixed FixedTokenConfig `yaml:"fixed_token"`
	Cors  CorsConfig       `yaml:"cors"`
}

SecurityConfig configures everything related to incoming request security

type ServerConfig

type ServerConfig struct {
	Address      string `yaml:"address"`
	Port         uint16 `yaml:"port"`
	ReadTimeout  int    `yaml:"read_timeout_seconds"`
	WriteTimeout int    `yaml:"write_timeout_seconds"`
	IdleTimeout  int    `yaml:"idle_timeout_seconds"`
}

ServerConfig contains all values for http configuration

type ServiceConfig

type ServiceConfig struct {
	Name                string `yaml:"name"`
	PublicURL           string `yaml:"public_url"`           // my own public base url, without a trailing slash
	AttendeeService     string `yaml:"attendee_service"`     // base url, usually http://localhost:nnnn, will use in-memory-mock if unset
	MailService         string `yaml:"mail_service"`         // base url, usually http://localhost:nnnn, will use in-memory-mock if unset
	PaymentService      string `yaml:"payment_service"`      // base url, usually http://localhost:nnnn, will use in-memory-mock if unset
	ConcardisDownstream string `yaml:"concardis_downstream"` // base url, usually https://api.pay-link.eu, will use in-memory-mock if unset
	ConcardisInstance   string `yaml:"concardis_instance"`   // your instance name, required
	ConcardisApiSecret  string `yaml:"concardis_api_secret"` // your instance's api secret, required
	SuccessRedirect     string `yaml:"success_redirect"`
	FailureRedirect     string `yaml:"failure_redirect"`
	TransactionIDPrefix string `yaml:"transaction_id_prefix"`
}

ServiceConfig contains configuration values for service related tasks. E.g. URLs to downstream services

Jump to

Keyboard shortcuts

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