config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config handles TOML configuration parsing, environment variable overrides, and validation for Anchor LFS.

Index

Constants

View Source
const (
	StorageLocal = "local"
	StorageS3    = "s3"
)

Storage backend names.

View Source
const DefaultConfigPath = "config.toml"

DefaultConfigPath is the file path used when no override is provided.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Options   Options    `toml:"options"`
	Storage   Storage    `toml:"storage"`
	Endpoints []Endpoint `toml:"endpoints"`
}

Config is the top-level configuration structure.

func Load

func Load(path string) (*Config, error)

Load reads and validates the configuration file. The path can be overridden by the ANCHOR_LFS_CONFIG environment variable.

type Endpoint

type Endpoint struct {
	Name           string `toml:"name"`
	URL            string `toml:"url"`
	Path           string `toml:"endpoint"` // "endpoint" in TOML for user clarity; "Path" in Go to avoid stuttering with the type name.
	Visibility     string `toml:"visibility"`
	Authentication string `toml:"authentication"`
	GitHubAPIURL   string `toml:"github_api_url"`

	// Parsed from URL at load time.
	GitHubOwner   string   `toml:"-"`
	GitHubRepo    string   `toml:"-"`
	GitHubBaseURL *url.URL `toml:"-"`
}

Endpoint configures a single repository whose LFS objects will be served.

func (*Endpoint) AuthMethod

func (e *Endpoint) AuthMethod() string

AuthMethod returns the normalised authentication method name.

func (*Endpoint) IsPublic

func (e *Endpoint) IsPublic() bool

IsPublic reports whether the endpoint is publicly readable.

type Options

type Options struct {
	ListenAddress     string `toml:"listen_address"`
	DataDirectory     string `toml:"data_directory"`
	AdditionalLogging bool   `toml:"additional_logging"`
	BaseURL           string `toml:"base_url"`
	MaxUploadSize     int64  `toml:"max_upload_size"`

	// Rate limiting.
	RateLimitTokens   uint64        `toml:"rate_limit_tokens"`
	RateLimitInterval time.Duration `toml:"-"`
	RateLimitWindow   string        `toml:"rate_limit_window"`

	// Auth cache.
	AuthCacheTTL      string        `toml:"auth_cache_ttl"`
	AuthCacheDuration time.Duration `toml:"-"`

	// URL signing.
	SigningKey        string        `toml:"signing_key"`
	SigningKeyBytes   []byte        `toml:"-"`
	URLExpiry         string        `toml:"url_expiry"`
	URLExpiryDuration time.Duration `toml:"-"`
}

Options holds global server settings.

type Storage

type Storage struct {
	Backend           string `toml:"backend"`
	S3Bucket          string `toml:"s3_bucket"`
	S3Region          string `toml:"s3_region"`
	S3Endpoint        string `toml:"s3_endpoint"`
	S3AccessKeyID     string `toml:"s3_access_key_id"`
	S3SecretAccessKey string `toml:"s3_secret_access_key"`
	S3Prefix          string `toml:"s3_prefix"`
	S3PresignedURLs   *bool  `toml:"s3_presigned_urls"`
	S3ForcePathStyle  *bool  `toml:"s3_force_path_style"`
}

Storage configures the object storage backend.

func (*Storage) S3ForcePathStyleEnabled

func (s *Storage) S3ForcePathStyleEnabled() bool

S3ForcePathStyleEnabled returns whether path-style addressing is enabled, defaulting to false when unset.

func (*Storage) S3PresignedURLsEnabled

func (s *Storage) S3PresignedURLsEnabled() bool

S3PresignedURLsEnabled returns whether presigned URLs are enabled, defaulting to true when unset.

Jump to

Keyboard shortcuts

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