config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("config",
	fx.Provide(
		Load,
	),
)
View Source
var TestModule = fx.Module("config_test",
	fx.Provide(
		LoadTestConfig,
	),
)

Functions

This section is empty.

Types

type Audit added in v0.8.13

type Audit struct {
	RetentionDays *int `default:"90" yaml:"auditRetentionDays"`
}

type Auth added in v0.8.13

type Auth struct {
	SuperuserGroups []string `yaml:"superuserGroups"`
	SuperuserUsers  []string `yaml:"superuserUsers"`
}

type Cache added in v0.7.0

type Cache struct {
	RefreshTime time.Duration `default:"2m" yaml:"refreshTime"`
}

type Config

type Config struct {
	LogLevel string `default:"DEBUG" yaml:"logLevel"`
	Mode     string `default:"debug" yaml:"mode"`

	Tracing Tracing `yaml:"tracing"`

	HTTP        HTTP       `yaml:"http"`
	GRPC        GRPC       `yaml:"grpc"`
	Database    Database   `yaml:"database"`
	NATS        NATS       `yaml:"nats"`
	JWT         JWT        `yaml:"jwt"`
	Storage     Storage    `yaml:"storage"`
	ImageProxy  ImageProxy `yaml:"imageProxy"`
	Cache       Cache      `yaml:"cache"`
	Audit       Audit      `yaml:"audit"`
	OAuth2      OAuth2     `yaml:"oauth2"`
	PostalsFile string     `default:".output/public/data/postals.json" yaml:"postalsFile"`

	Auth           Auth           `yaml:"auth"`
	DispatchCenter DispatchCenter `yaml:"dispatchCenter"`

	Discord Discord `yaml:"discord"`
}

func LoadTestConfig added in v0.8.21

func LoadTestConfig() (*Config, error)

type CustomDB added in v0.8.21

type CustomDB struct {
	Columns    dbutils.CustomColumns    `yaml:"columns"`
	Conditions dbutils.CustomConditions `yaml:"conditions"`
}

type Database

type Database struct {
	// refer to https://github.com/go-sql-driver/mysql#dsn-data-source-name for details
	DSN string `yaml:"dsn"`

	// Connection options
	MaxOpenConns    int           `default:"32" yaml:"maxOpenConns"`
	MaxIdleConns    int           `default:"5" yaml:"maxIdleConns"`
	ConnMaxIdleTime time.Duration `default:"15m" yaml:"connMaxIdleTime"`
	ConnMaxLifetime time.Duration `default:"60m" yaml:"connMaxLifetime"`

	Custom CustomDB `yaml:"custom"`
}

type Discord added in v0.8.0

type Discord struct {
	Enabled      bool                `default:"false" yaml:"enabled"`
	Token        string              `yaml:"token"`
	Presence     DiscordPresence     `yaml:"presence,omitempty"`
	UserInfoSync DiscordUserInfoSync `yaml:"userInfoSync"`
	GroupSync    DiscordGroupSync    `yaml:"groupSync"`
	Commands     DiscordCommands     `yaml:"commands"`
}

type DiscordCommands added in v0.8.5

type DiscordCommands struct {
	Enabled bool `default:"false" yaml:"enabled"`
}

type DiscordGroupRole added in v0.8.4

type DiscordGroupRole struct {
	RoleName    string `yaml:"roleName"`
	Permissions *int64 `yaml:"omitempty,permissions"`
	Color       string `yaml:"color"`
	NotSameJob  bool   `yaml:"notSameJob"`
}

type DiscordGroupSync added in v0.8.4

type DiscordGroupSync struct {
	Enabled bool                        `default:"false" yaml:"enabled"`
	Mapping map[string]DiscordGroupRole `yaml:"omitempty,mapping"`
}

type DiscordPresence added in v0.8.10

type DiscordPresence struct {
	GameStatus         *string `yaml:"gameStatus"`
	ListeningStatus    *string `yaml:"listeningStatus"`
	StreamingStatus    *string `yaml:"streamingStatus"`
	StreamingStatusUrl *string `yaml:"streamingStatusUrl"`
	WatchStatus        *string `yaml:"watchStatus"`
}

type DiscordUserInfoSync added in v0.8.4

type DiscordUserInfoSync struct {
	Enabled             bool     `default:"false" yaml:"enabled"`
	GradeRoleFormat     string   `default:"[%grade%] %grade_label%" yaml:"gradeRoleFormat"`
	EmployeeRoleFormat  string   `default:"%s Personal" yaml:"employeeRoleFormat"`
	NicknameRegex       string   `default:"^(?P<prefix>\\[\\S+][ ]*)?(?P<name>[^\\[]+)(?P<suffix>[ ]*\\[\\S+])?" yaml:"nicknameRegex"`
	IgnoreJobs          []string `yaml:"ignoreJobs"`
	UnemployedRoleName  string   `default:"Citizen" yaml:"unemployedRoleName"`
	JobsAbsceneRoleName string   `default:"Absent" yaml:"jobsAbsceneRoleName"`
}

type DispatchCenter added in v0.8.1

type DispatchCenter struct {
	ConvertJobs []string `yaml:"convertJobs"`
}

type FilesystemStorage added in v0.8.20

type FilesystemStorage struct {
	Path string `yaml:"path"`
}

type GRPC

type GRPC struct {
	Listen string `default:":9090" yaml:"listen"`
}

type HTTP

type HTTP struct {
	Listen      string   `default:":8080" yaml:"listen"`
	AdminListen string   `default:":7070" yaml:"adminListen"`
	Sessions    Sessions `yaml:"sessions"`
	Links       Links    `yaml:"links"`
	PublicURL   string   `yaml:"publicURL"`
}

type ImageProxy added in v0.8.20

type ImageProxy struct {
	Enabled     bool              `default:"true" yaml:"enabled"`
	URL         string            `default:"/api/image_proxy/" yaml:"url"`
	CachePrefix string            `default:"images/" yaml:"cachePrefix"`
	Options     ImageProxyOptions `yaml:"options"`
}

type ImageProxyOptions added in v0.8.20

type ImageProxyOptions struct {
	AllowHosts []string `yaml:"allowHosts"`
	DenyHosts  []string `yaml:"denyHosts"`
}

type JWT

type JWT struct {
	Secret string `yaml:"secret"`
}
type Links struct {
	PrivacyPolicy *string `json:"privacyPolicy"`
	Imprint       *string `json:"imprint"`
}

type NATS added in v0.5.1

type NATS struct {
	URL      string `default:"nats://localhost:4222" yaml:"url"`
	Replicas int    `default:"1" yaml:"replicas"`
}

type OAuth2

type OAuth2 struct {
	Providers []*OAuth2Provider
}

type OAuth2Endpoints

type OAuth2Endpoints struct {
	AuthURL     string `yaml:"authURL"`
	TokenURL    string `yaml:"tokenURL"`
	UserInfoURL string `yaml:"userInfoURL"`
}

type OAuth2Mapping

type OAuth2Mapping struct {
	ID       string `yaml:"id"`
	Username string `yaml:"username"`
	Avatar   string `yaml:"avatar"`
}

type OAuth2Provider

type OAuth2Provider struct {
	Name          string             `yaml:"name"`
	Label         string             `yaml:"label"`
	Homepage      string             `yaml:"homepage"`
	Type          OAuth2ProviderType `yaml:"type"`
	DefaultAvatar string             `yaml:"defaultAvatar"`
	RedirectURL   string             `yaml:"redirectURL"`
	ClientID      string             `yaml:"clientID"`
	ClientSecret  string             `yaml:"clientSecret"`
	Scopes        []string           `yaml:"scopes"`
	Endpoints     OAuth2Endpoints    `yaml:"endpoints"`
	Mapping       *OAuth2Mapping     `yaml:"omitempty,mapping"`
}

type OAuth2ProviderType

type OAuth2ProviderType string
const (
	OAuth2ProviderGeneric OAuth2ProviderType = "generic"
	OAuth2ProviderDiscord OAuth2ProviderType = "discord"
)

type Result added in v0.8.0

type Result struct {
	fx.Out

	Config        *Config
	DiscordConfig *Discord
}

func Load added in v0.8.0

func Load() (Result, error)

type S3Storage added in v0.8.20

type S3Storage struct {
	Endpoint        string `yaml:"endpoint"`
	Region          string `default:"us-east-1" yaml:"region"`
	AccessKeyID     string `yaml:"accessKeyID"`
	SecretAccessKey string `yaml:"secretAccessKey"`
	UseSSL          bool   `default:"true" yaml:"useSSL"`
	BucketName      string `yaml:"bucketName"`
	Prefix          string `yaml:"prefix"`
}

type Sessions

type Sessions struct {
	CookieSecret string `yaml:"cookieSecret"`
	Domain       string `default:"localhost" yaml:"domain"`
}

type Storage added in v0.8.11

type Storage struct {
	Type       string            `default:"filesystem" yaml:"type"`
	Filesystem FilesystemStorage `yaml:"filesystem"`
	S3         S3Storage         `yaml:"s3"`
}

type Tracing

type Tracing struct {
	Enabled     bool            `default:"false" yaml:"enabled"`
	Type        TracingExporter `default:"stdout" yaml:"type"`
	URL         string          `yaml:"url"`
	Insecure    bool            `yaml:"insecure"`
	Timeout     time.Duration   `default:"10s" yaml:"timeout"`
	Environment string          `default:"dev" yaml:"environment"`
	Ratio       float64         `default:"0.1" yaml:"ratio"`
	Attributes  []string        `yaml:"attributes"`
}

type TracingExporter added in v0.8.21

type TracingExporter string
const (
	TracingExporter_StdoutTrace   TracingExporter = "stdout"
	TracingExporter_OTLPTraceGRPC TracingExporter = "otlptracegrpc"
	TracingExporter_OTLPTraceHTTP TracingExporter = "otlptracehttp"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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