config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package config reads and parses configurations.

Package config reads and parses configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(key string) string

Getenv reads an environment variable and trim the space.

func ProbeURL added in v1.9.3

func ProbeURL(ctx context.Context, url string) bool

ProbeURL quickly checks whether one can send a HEAD request to the url.

func ReadAndAppendHealthchecksURL added in v1.9.3

func ReadAndAppendHealthchecksURL(ppfmt pp.PP, key string, field *[]monitor.Monitor) bool

ReadAndAppendHealthchecksURL reads the base URL of a Healthchecks endpoint.

func ReadAndAppendUptimeKumaURL added in v1.11.0

func ReadAndAppendUptimeKumaURL(ppfmt pp.PP, key string, field *[]monitor.Monitor) bool

ReadAndAppendUptimeKumaURL reads the URL of a Push Monitor of an Uptime Kuma server.

func ReadAuth

func ReadAuth(ppfmt pp.PP, field *api.Auth) bool

ReadAuth reads environment variables CF_API_TOKEN, CF_API_TOKEN_FILE, and CF_ACCOUNT_ID and creates an api.CloudflareAuth.

func ReadBool

func ReadBool(ppfmt pp.PP, key string, field *bool) bool

ReadBool reads an environment variable as a boolean value.

func ReadCron

func ReadCron(ppfmt pp.PP, key string, field *cron.Schedule) bool

ReadCron reads an environment variable and parses it as a Cron expression.

func ReadDomainMap

func ReadDomainMap(ppfmt pp.PP, field *map[ipnet.Type][]domain.Domain) bool

ReadDomainMap reads environment variables DOMAINS, IP4_DOMAINS, and IP6_DOMAINS and consolidate the domains into a map.

func ReadDomains

func ReadDomains(ppfmt pp.PP, key string, field *[]domain.Domain) bool

ReadDomains reads an environment variable as a comma-separated list of domains.

func ReadEmoji added in v1.8.0

func ReadEmoji(key string, ppfmt *pp.PP) bool

ReadEmoji reads an environment variable as emoji/no-emoji.

func ReadLinuxID added in v1.9.0

func ReadLinuxID(ppfmt pp.PP, key string, field *int) bool

ReadLinuxID reads an environment variable as a user or group ID.

func ReadNonnegDuration

func ReadNonnegDuration(ppfmt pp.PP, key string, field *time.Duration) bool

ReadNonnegDuration reads an environment variable and parses it as a time duration.

func ReadNonnegInt

func ReadNonnegInt(ppfmt pp.PP, key string, field *int) bool

ReadNonnegInt reads an environment variable as a non-negative integer.

func ReadProvider added in v1.5.0

func ReadProvider(ppfmt pp.PP, key, keyDeprecated string, field *provider.Provider) bool

ReadProvider reads an environment variable and parses it as a provider.

policyKey was the name of the deprecated parameters IP4/6_POLICY.

func ReadProviderMap added in v1.5.0

func ReadProviderMap(ppfmt pp.PP, field *map[ipnet.Type]provider.Provider) bool

ReadProviderMap reads the environment variables IP4_PROVIDER and IP6_PROVIDER, with support of deprecated environment variables IP4_POLICY and IP6_POLICY.

func ReadQuiet

func ReadQuiet(key string, ppfmt *pp.PP) bool

ReadQuiet reads an environment variable as quiet/verbose.

func ReadString added in v1.7.0

func ReadString(ppfmt pp.PP, key string, field *string) bool

ReadString reads an environment variable as a plain string.

func ReadTTL added in v1.7.2

func ReadTTL(ppfmt pp.PP, key string, field *api.TTL) bool

ReadTTL reads a valid TTL value.

According to API documentation, the valid range is 1 (auto) and [60, 86400]. According to DNS documentation, the valid range is "Auto" and [30, 86400]. We thus accept the union of both ranges---1 (auto) and [30, 86400].

Types

type Config

type Config struct {
	Auth             api.Auth
	Provider         map[ipnet.Type]provider.Provider
	Use1001          bool
	Domains          map[ipnet.Type][]domain.Domain
	UpdateCron       cron.Schedule
	UpdateOnStart    bool
	DeleteOnStop     bool
	CacheExpiration  time.Duration
	TTL              api.TTL
	ProxiedTemplate  string
	Proxied          map[domain.Domain]bool
	DetectionTimeout time.Duration
	UpdateTimeout    time.Duration
	Monitors         []monitor.Monitor
}

Config holds the configuration of the updater except for the timezone. (The timezone is handled directly by the standard library reading the TZ environment variable.)

func Default

func Default() *Config

Default gives the default configuration.

func (*Config) NormalizeConfig added in v1.9.0

func (c *Config) NormalizeConfig(ppfmt pp.PP) bool

NormalizeConfig checks and normalizes the fields [Config.Provider], [Config.Proxied], and [Config.DeleteOnStop]. When any error is reported, the original configuration remain unchanged.

func (*Config) Print

func (c *Config) Print(ppfmt pp.PP)

Print prints the Config on the screen.

func (*Config) ReadEnv

func (c *Config) ReadEnv(ppfmt pp.PP) bool

ReadEnv calls the relevant readers to read all relevant environment variables except TZ and update relevant fields. One should subsequently call Config.NormalizeConfig to maintain invariants across different fields.

func (*Config) ShouldWeUse1001 added in v1.9.3

func (c *Config) ShouldWeUse1001(ctx context.Context, ppfmt pp.PP) bool

ShouldWeUse1001 quickly checks 1.1.1.1 and 1.0.0.1 and notes whether 1.0.0.1 should be used.

Jump to

Keyboard shortcuts

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