config

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateJsonSchemaForConfig added in v0.8.4

func CreateJsonSchemaForConfig() ([]byte, error)

func DurationViperHookFunc added in v0.8.4

func DurationViperHookFunc() mapstructure.DecodeHookFuncType

func InitConfig

func InitConfig() error

func WriteToml added in v0.8.0

func WriteToml(w io.Writer, j interface{}) error

Types

type ApiConfig

type ApiConfig struct {
	// Address (interface) to listen to
	Address      string `cfg:"address" default:"0.0.0.0" help:"Address (interface) to listen to)" jsonschema:"default=0.0.0.0"`
	RedirectPort int    `` /* 135-byte string literal not displayed */
	Port         int    `cfg:"port" default:"80" help:"Port to listen to"`
	CertFile     string `cfg:"cert-file" default:"" help:"Number of request to make total"`
	CertKey      string `cfg:"cert-key" default:"" help:"Number of request to make total"`
	DBLocation   string `cfg:"db-path" default:"./storage/db.bbolt" help:"Filepath to where to store the database"`
	// Timeout used for reads
	ReadTimeout Duration
	// Timeout used for writes
	WriteTimeout Duration
	// Timeout used for idles
	IdleTimeout Duration
	// Timeout used for shutdown
	ShutdownTimeout Duration
	// If set, will register debug-handlers at
	// - /debug/vars
	// - /debug/vars/
	// - /debug/pprof/
	// - /debug/pprof/cmdline
	// - /debug/pprof/profile
	// - /debug/pprof/symbol
	// - /debug/pprof/trace
	Debug bool
}

type AuthConfig

type AuthConfig struct {
	// Defines how long a Session should be valid for.
	SessionLifeTime Duration `jsonschema="title=Defines how long a session should be valid for"`
}

type BackupConfig added in v0.8.4

type BackupConfig struct {
	S3 *S3BaseConfig `json:"s3" help:"Use s3 for backup"`
	// If no database is available at startup, this source can be used to fetch the database.
	// Skiver will then use that as a database.
	// This can be useful in environments where there is no readily available persistant storage.
	FetchOnStartup bool
	// The database can be backed up as often as every write, but can be relaxed with this value.
	// Defaults to 10 minutes
	MaxInterval Duration `` /* 140-byte string literal not displayed */
	// Can be used to set a custom objectkey.
	// defaults to "skiver.bbolt"
	FileName string
}

type Config

type Config struct {
	// Level for logging
	// Enum: [trace debug info warn warning error panic]
	LogLevel string `` /* 211-byte string literal not displayed */
	// Enum: [human json]
	LogFormat string    `cfg:"log-format" default:"human" help:"Format of the logs. Can be human or json" jsonschema:"enum=human,enum=json"`
	Api       ApiConfig `cfg:"api" help:"Used with the api-server"`

	// If set, will enable a self-check that monitors the applications resource-usage. Used for debugging, and monitoring outside of any orcestrator like kubernetes
	SelfCheck bool `cfg:"selv-check" default:"true" help:"Enables a self check to check resources."`

	// Global translator-services that should be available
	TranslatorServices []TranslatorService
	// Options for Authentication
	Authentication AuthConfig
	// Set to enable gzip-module for all content served
	Gzip bool

	// Enable Metrics (prometheus-compatible)
	Metrics Metrics

	// Used to upload files to external targets when creating snapshots.
	UploadSnapShots map[string]Uploader

	// Used to upload backups of the database.
	// Can optionally also be used as a source to retreve a backup from on startup, if there is no database.
	DatabaseBackups map[string]BackupConfig `help:"Optional backupendpoints for databases" json:"databaseBackups"`
}

func CreateSampleComfig added in v0.8.0

func CreateSampleComfig() Config

func GetConfig

func GetConfig() *Config

type Duration added in v0.8.4

type Duration time.Duration

Duration that marshals and unmarshal yaml, toml and json.

func ParseDuration added in v0.8.4

func ParseDuration(data interface{}) (d Duration, err error)

func (Duration) Duration added in v0.8.4

func (d Duration) Duration() time.Duration

func (Duration) JSONSchema added in v0.8.4

func (Duration) JSONSchema() *jsonschema.Schema

func (Duration) MarshalText added in v0.8.4

func (d Duration) MarshalText() (text []byte, err error)

func (Duration) String added in v0.8.4

func (d Duration) String() string

func (*Duration) UnmarshalJSON added in v0.8.4

func (duration *Duration) UnmarshalJSON(b []byte) error

func (*Duration) UnmarshalText added in v0.8.4

func (d *Duration) UnmarshalText(b []byte) error

type Metrics added in v0.8.0

type Metrics struct {
	Enabled bool

	// If set, will be exposed on a different port. if not set, it will be exposed on the same port.
	// This can be useful to not expose the metrics publicly.
	Port int
}

type S3BaseConfig added in v0.8.4

type S3BaseConfig struct {
	// Endpoint for the s3-compatible service
	Endpoint string `json:"endpoint" help:"Endpoint for the s3-compatible service"`
	// The region for the service.
	Region string `json:"region" help:"The region for the service"`

	// Bucket to upload into
	BucketID string `json:"bucketID" help:"Bucket to upload into"`

	// AccessKeyID for the bucket / application
	AccessKey string `json:"accessKey" help:"Accesskey for the bucket / application"`
	// Private key or Secret access key for the bucket / application
	PrivateKey string

	// Name for provider, used for display-puroposes
	ProviderName string `json:"providerName" help:"Pretty name, displayed in logs etc."`
	// If set, will add headers for use with Browser-TTL, CDN-TTL and CloudFlare-TTL
	ForcePathStyle bool `json:"forcePathStyle" help:"If set will add headers for use with Browser-TTL, CDN-TTL and CloudFlare-TTL"`
}

type S3UploaderConfig added in v0.8.0

type S3UploaderConfig struct {
	// S3-compatible target
	S3BaseConfig `mapstructure:",squash"`
	// Can be used to override the url that is produced.
	// Golang-templating is available
	// Variables:
	// `.Object`:        The current Object-id (fileName)
	// `.Bucket`:        The current Object-id (fileName)
	// `.EndpointURL`:   net.Url version of the Endpoint
	// `.Endpoint`:      Endpoint as string
	// `.Region`:        Region.
	UrlFormat    string `` /* 345-byte string literal not displayed */
	CacheControl string
}

type TranslatorService

type TranslatorService struct {
	// Enum: [bind libre]
	Kind     string
	ApiToken string
	Endpoint string
}

TDB

type Uploader added in v0.8.0

type Uploader struct {
	// S3-compatible target
	S3 *S3UploaderConfig
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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