config

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MinBucketTokenLength = 32

MinBucketTokenLength is the minimum accepted length of a bucket-scoped token secret. Bucket tokens are machine-generated credentials, so there is no reason for a short one and a weak entry would silently widen the write surface.

Variables

This section is empty.

Functions

func BucketTokenCount added in v1.8.0

func BucketTokenCount() int

BucketTokenCount returns the number of loaded bucket-scoped tokens.

func BucketTokenMatches added in v1.8.0

func BucketTokenMatches(bucketName, secret string) bool

BucketTokenMatches reports whether secret is the configured token for bucketName, compared in constant time.

An unknown bucket still runs a full comparison against a zero digest so that "no token configured for this bucket" and "wrong secret" cost the same.

func GetEnvAsBoolOrDefault

func GetEnvAsBoolOrDefault(key string, defaultValue bool) bool

func GetEnvAsIntOrDefault

func GetEnvAsIntOrDefault(key string, defaultValue int) int

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultValue string) string

func LoadBucketTokens added in v1.8.0

func LoadBucketTokens(path string) (int, error)

LoadBucketTokens reads bucket-scoped tokens from path and returns how many were loaded.

A missing file is not an error: it is the normal state of a deployment that uses only the general TOKEN, and boot must succeed unchanged in that case. A file that exists but cannot be parsed or fails validation IS an error, because silently serving with zero bucket tokens after an operator wrote the file is the worse failure: callers would fall back to "invalid token" with no clue why.

Types

type AWSConfig

type AWSConfig struct {
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
	Region          string
	Bucket          string
}

type AppConfig

type AppConfig struct {
	Name  string
	Port  int
	URL   string
	Token string
}

type BucketToken added in v1.8.0

type BucketToken struct {
	Bucket string `json:"bucket"`
	Token  string `json:"token"`
	// Label is an optional free-text note (who or what uses this token). It is
	// never used for authorization.
	Label string `json:"label,omitempty"`
}

BucketToken is one entry of the token file.

type Config

type Config struct {
	App      AppConfig
	Minio    MinioConfig
	AWS      AWSConfig
	Redis    RedisConfig
	Worker   WorkerConfig
	Features FeatureConfig
}

func Load

func Load() (*Config, error)

Load loads configuration from environment variables

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type FeatureConfig

type FeatureConfig struct {
	DisableDelete bool
	DisableUpload bool
	DisableGet    bool
}

type MinioConfig

type MinioConfig struct {
	Endpoint string
	User     string
	Password string
	UseSSL   bool
}

type RedisConfig

type RedisConfig struct {
	URL string
}

type TokenConfig added in v1.8.0

type TokenConfig struct {
	Buckets []BucketToken `json:"buckets"`
}

TokenConfig is the on-disk shape of the token file.

type WorkerConfig

type WorkerConfig struct {
	PoolSize      int
	QueueSize     int
	MaxRetries    int
	RetryDelay    time.Duration
	BatchSize     int
	FlushTimeout  time.Duration
	MaxConcurrent int
}

Jump to

Keyboard shortcuts

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