Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package config resolves the drive server's settings. Flags win over env, and env wins over <ConfigDir>/drive-server.yaml.

Index

Constants

View Source
const (
	DefaultListen          = ":8080"
	DefaultDataDir         = "/data"
	DefaultConfigDir       = "/config"
	DefaultMaxDocumentSize = 5 << 20

	ConfigFileName = "drive-server.yaml"
)

Variables

This section is empty.

Functions

func IsLoopback

func IsLoopback(host string) bool

IsLoopback reports whether host is localhost or a loopback address.

Types

type Config

type Config struct {
	BaseURL         string
	Listen          string
	DataDir         string
	ConfigDir       string
	MaxDocumentSize Size
	SMTP            SMTP
	DevLogMail      bool
	TrustedProxies  []string
	UserPolicies    []Policy
}

func Load

func Load(getenv func(string) string, flags Flags) (Config, error)

Load resolves the config: defaults, then drive-server.yaml, then HIVE_DRIVE_SERVER_* env, then flags. It does not validate; call Validate on the result.

func (Config) Validate

func (c Config) Validate() (warnings []string, err error)

Validate checks the whole config and reports every problem at once. Warnings do not stop the server.

type Flags

type Flags struct {
	BaseURL         string
	Listen          string
	DataDir         string
	ConfigDir       string
	MaxDocumentSize string
	TrustedProxies  string
	DevLogMail      bool
}

Flags holds the command-line values. An empty string or false means the flag was not set.

type Policy

type Policy struct {
	Name    string   `yaml:"name"`
	Matches []string `yaml:"matches"`
	// SignUp defaults to true when nil.
	SignUp *bool  `yaml:"sign_up"`
	Quotas Quotas `yaml:"quotas"`
}

Policy admits the emails its Matches globs match. The first policy that matches an email applies.

func (Policy) SignUpAllowed

func (p Policy) SignUpAllowed() bool

SignUpAllowed reports whether an email that matches the policy may create its account by signing in.

type Quotas

type Quotas struct {
	Limit Size `yaml:"limit"`
}

type SMTP

type SMTP struct {
	URL  string `yaml:"url"`
	From string `yaml:"from"`
	// Password is a secret reference (env:, file:, op://), never the password.
	Password string `yaml:"password"`
}

type Size

type Size struct {
	Bytes     int64
	Unlimited bool
}

Size is a byte count, or no limit at all. The zero value is "unset": it is what a missing key decodes to, so Validate can tell it from a real limit.

func (Size) IsSet

func (s Size) IsSet() bool

func (*Size) UnmarshalText

func (s *Size) UnmarshalText(text []byte) error

UnmarshalText accepts "unlimited" or a positive number with an optional unit: decimal (KB, MB, GB, TB) or binary (KiB, MiB, GiB, TiB). Zero and negative values are errors so that no limit is ever implied.

Jump to

Keyboard shortcuts

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