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: 16 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

View Source
const (
	Inmemory DatabaseType = "inmemory"
	Mysql    DatabaseType = "mysql"

	Plain LogStyle = "plain"
	ECS   LogStyle = "ecs" // default
)
View Source
const HumanDateFormat = "02.01.2006"
View Source
const IsoDateFormat = "2006-01-02"
View Source
const StartTimeFormat = "2006-01-02T15:04:05-07:00"

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 AdditionalGeneratorCommandLineFlags added in v0.1.1

func AdditionalGeneratorCommandLineFlags()

func AdditionalInfoFieldNames

func AdditionalInfoFieldNames() []string

func AllowedCountries

func AllowedCountries() []string

func AllowedFlagsAdminOnly

func AllowedFlagsAdminOnly() []string

func AllowedFlagsNoAdmin

func AllowedFlagsNoAdmin() []string

func AllowedOptions

func AllowedOptions() []string

func AllowedPackages

func AllowedPackages() []string

func AllowedPermissions

func AllowedPermissions() []string

AllowedPermissions returns a sorted unique map of all permissions referenced in additional info configurations.

func AllowedRegistrationLanguages

func AllowedRegistrationLanguages() []string

func AllowedSpokenLanguages

func AllowedSpokenLanguages() []string

func AllowedStatusValues

func AllowedStatusValues() []status.Status

func AllowedTshirtSizes

func AllowedTshirtSizes() []string

func AnonymizeIdentity added in v0.1.1

func AnonymizeIdentity() bool

func AuthServiceBaseUrl

func AuthServiceBaseUrl() string

func CorsAllowOrigin

func CorsAllowOrigin() string

func Currency

func Currency() string

func DatabaseMysqlConnectString

func DatabaseMysqlConnectString() string

func DefaultFlags

func DefaultFlags() string

func DefaultOptions

func DefaultOptions() string

func DefaultPackages

func DefaultPackages() string

func DefaultRegistrationLanguage

func DefaultRegistrationLanguage() string

func DueDays

func DueDays() time.Duration

func EarliestBirthday

func EarliestBirthday() string

func EarliestDueDate

func EarliestDueDate() string

func EarlyRegistrationStartTime

func EarlyRegistrationStartTime() time.Time

func EnableTestingMigrateDatabase

func EnableTestingMigrateDatabase()

EnableTestingMigrateDatabase is for tests

func FixedApiToken

func FixedApiToken() string

func FlagsConfigAdminOnly

func FlagsConfigAdminOnly() map[string]ChoiceConfig

func FlagsConfigNoAdmin

func FlagsConfigNoAdmin() map[string]ChoiceConfig

func GeneratorAccessToken added in v0.1.1

func GeneratorAccessToken() string

func GeneratorBaseUrl added in v0.1.1

func GeneratorBaseUrl() string

func GeneratorCookieDomain added in v0.1.1

func GeneratorCookieDomain() string

func GeneratorGenerateCount added in v0.1.1

func GeneratorGenerateCount() uint

func GeneratorIdToken added in v0.1.1

func GeneratorIdToken() string

func GeneratorParallel added in v0.1.1

func GeneratorParallel() uint

func IsCorsDisabled

func IsCorsDisabled() bool

func LatestBirthday

func LatestBirthday() string

func LatestDueDate

func LatestDueDate() string

func LoadTestingConfigurationFromPathOrAbort

func LoadTestingConfigurationFromPathOrAbort(configFilenameForTests string)

LoadTestingConfigurationFromPathOrAbort is for tests to set a hardcoded yaml configuration

func LoggingSeverity

func LoggingSeverity() string

func MailServiceBaseUrl

func MailServiceBaseUrl() string

func MigrateDatabase

func MigrateDatabase() bool

func OidcAccessTokenCookieName

func OidcAccessTokenCookieName() string

func OidcAdminGroup

func OidcAdminGroup() string

func OidcAllowedAudience

func OidcAllowedAudience() string

func OidcAllowedIssuer

func OidcAllowedIssuer() string

func OidcEarlyRegGroup

func OidcEarlyRegGroup() string

func OidcIdTokenCookieName

func OidcIdTokenCookieName() string

func OidcKeySet

func OidcKeySet() []*rsa.PublicKey

func OptionsConfig

func OptionsConfig() map[string]ChoiceConfig

func PackagesConfig

func PackagesConfig() map[string]ChoiceConfig

func ParseCommandLineFlags

func ParseCommandLineFlags()

ParseCommandLineFlags is exposed separately so you can skip it for tests

func PaymentServiceBaseUrl

func PaymentServiceBaseUrl() string

func RegistrationStartTime

func RegistrationStartTime() time.Time

func RegsysPublicUrl

func RegsysPublicUrl() string

func RequireLoginForReg

func RequireLoginForReg() bool

func ServerAddr

func ServerAddr() string

func ServerIdleTimeout

func ServerIdleTimeout() time.Duration

func ServerReadTimeout

func ServerReadTimeout() time.Duration

func ServerWriteTimeout

func ServerWriteTimeout() time.Duration

func StartupLoadConfiguration

func StartupLoadConfiguration() error

func UseEcsLogging

func UseEcsLogging() bool

func VatPercent

func VatPercent() float64

Types

type AddInfoConfig

type AddInfoConfig struct {
	SelfRead    bool     `yaml:"self_read"`
	SelfWrite   bool     `yaml:"self_write"`
	Permissions []string `yaml:"permissions"` // name of permission (in admin info) to grant access

}

AddInfoConfig configures access permissions to an additional info field

func AdditionalInfoConfiguration

func AdditionalInfoConfiguration(fieldName string) AddInfoConfig

type Application

type Application struct {
	Service               ServiceConfig            `yaml:"service"`
	Server                ServerConfig             `yaml:"server"`
	Database              DatabaseConfig           `yaml:"database"`
	Security              SecurityConfig           `yaml:"security"`
	Logging               LoggingConfig            `yaml:"logging"`
	Choices               FlagsPkgOptConfig        `yaml:"choices"`
	AdditionalInfo        map[string]AddInfoConfig `yaml:"additional_info_areas"` // field name -> config
	TShirtSizes           []string                 `yaml:"tshirtsizes"`
	Birthday              BirthdayConfig           `yaml:"birthday"`
	GoLive                GoLiveConfig             `yaml:"go_live"`
	Dues                  DuesConfig               `yaml:"dues"`
	Countries             []string                 `yaml:"countries"`
	SpokenLanguages       []string                 `yaml:"spoken_languages"`
	RegistrationLanguages []string                 `yaml:"registration_languages"`
	Currency              string                   `yaml:"currency"`
	VatPercent            float64                  `yaml:"vat_percent"` // used for manual dues
}

Application is the root configuration type

func Configuration

func Configuration() *Application

type BirthdayConfig

type BirthdayConfig struct {
	Earliest string `yaml:"earliest"`
	Latest   string `yaml:"latest"`
}

BirthdayConfig is used for validation of attendee supplied birthday

use it to exclude nonsensical values, or to exclude participants under a minimum age

type ChoiceConfig

type ChoiceConfig struct {
	Description   string   `yaml:"description"`
	Price         int64    `yaml:"price"`
	VatPercent    float64  `yaml:"vat_percent"`
	Default       bool     `yaml:"default"`                // if set to true, is added to flags by default. Not available for admin only flags!
	AdminOnly     bool     `yaml:"admin_only"`             // this flag is kept under the adminInfo structure, so it is not visible to users
	ReadOnly      bool     `yaml:"read_only"`              // this flag is kept under the normal flags, thus visible to end user, but only admin can change it
	VisibleFor    []string `yaml:"visible_for"`            // list of permissions which allow seeing the flag/option/package. Admin can always see everything, "self" can always see non-admin_only, but you can add it for admin_only fields. This field also controls who else can see the info based on their permissions admin field. Example: "self,sponsordesk"
	Group         string   `yaml:"group"`                  // set if attendee has this group during initial registration
	Mandatory     bool     `yaml:"at-least-one-mandatory"` // one of these MUST be chosen (no constraint if not set on any choices)
	Constraint    string   `yaml:"constraint"`
	ConstraintMsg string   `yaml:"constraint_msg"`
}

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

func DatabaseUse

func DatabaseUse() DatabaseType

type DuesConfig

type DuesConfig struct {
	EarliestDueDate string `yaml:"earliest_due_date"`
	LatestDueDate   string `yaml:"latest_due_date"` // inclusive
	DueDays         int    `yaml:"due_days"`
}

DuesConfig configures the due date calculations

type FixedTokenConfig

type FixedTokenConfig struct {
	Api string `yaml:"api"` // shared-secret for server-to-server backend authentication
}

type FlagsPkgOptConfig

type FlagsPkgOptConfig struct {
	Flags    map[string]ChoiceConfig `yaml:"flags"`
	Packages map[string]ChoiceConfig `yaml:"packages"`
	Options  map[string]ChoiceConfig `yaml:"options"`
}

FlagsPkgOptConfig configures the choices available to the attendees

flags are choices that have some impact on how the registration is treated (guest, e.V. membership, staff, ...)

packages are stuff that costs money, such as sponsorship or housing options

options are personal preferences (interested in music, fursuiter, ...) that do not affect how the registration is treated.

type GoLiveConfig

type GoLiveConfig struct {
	StartIsoDatetime         string `yaml:"start_iso_datetime"`
	EarlyRegStartIsoDatetime string `yaml:"early_reg_start_iso_datetime"` // optional, only useful if you also set early_reg_role
}

GoLiveConfig configures the time at which registration becomes available

type LogStyle

type LogStyle string

type LoggingConfig

type LoggingConfig struct {
	Style    LogStyle `yaml:"style"`
	Severity string   `yaml:"severity"`
}

LoggingConfig configures logging

type OpenIdConnectConfig

type OpenIdConnectConfig struct {
	IdTokenCookieName     string   `yaml:"id_token_cookie_name"`     // optional, but must both be set, then tokens are read from cookies
	AccessTokenCookieName string   `yaml:"access_token_cookie_name"` // optional, but must both be set, then tokens are read from cookies
	TokenPublicKeysPEM    []string `yaml:"token_public_keys_PEM"`    // a list of public RSA keys in PEM format, see https://github.com/Jumpy-Squirrel/jwks2pem for obtaining PEM from openid keyset endpoint
	AdminGroup            string   `yaml:"admin_group"`              // the group claim that supplies regsys admin rights
	EarlyRegGroup         string   `yaml:"early_reg_group"`          // optional, the group claim that turns on early registration
	Audience              string   `yaml:"audience"`
	Issuer                string   `yaml:"issuer"`
}

type SecurityConfig

type SecurityConfig struct {
	Fixed             FixedTokenConfig    `yaml:"fixed_token"`
	Oidc              OpenIdConnectConfig `yaml:"oidc"`
	Cors              CorsConfig          `yaml:"cors"`
	RequireLogin      bool                `yaml:"require_login_for_reg"`
	AnonymizeIdentity bool                `yaml:"anonymize_identity"`
}

SecurityConfig configures everything related to security

type ServerConfig

type ServerConfig struct {
	Address      string `yaml:"address"`
	Port         string `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"`
	RegsysPublicUrl string `yaml:"regsys_public_url"` // used in emails
	PaymentService  string `yaml:"payment_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
	AuthService     string `yaml:"auth_service"`      // base url, usually http://localhost:nnnn, will skip userinfo checks if unset
}

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