configfile

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package configfile handles all the base configuration-file routines. This package also holds the conifiguration for the webserver and notifiarr packages. In here you will find config file parsing, validation, and creation. The application can re-write its own config file from a built-in template, complete with comments. In some circumstances the application writes a brand new empty config on startup.

Index

Constants

View Source
const (
	MsgNoConfigFile = "Using env variables only. Config file not found."
	MsgConfigFailed = "Using env variables only. Could not create config file: "
	MsgConfigCreate = "Created new config file: "
	MsgConfigFound  = "Using Config File: "
)

Return prefixes from FindAndReturn.

Variables

View Source
var ForceAllTmpl = false // nolint:gochecknoglobals

ForceAllTmpl allows you to force some specific settings. Used to build a default template.

View Source
var Template = template.Must(template.New("config").Funcs(Funcs()).Parse(tmpl))

Template is the config file template. nolint: gochecknoglobals

Functions

func Funcs

func Funcs() template.FuncMap

Funcs returns our template functions.

Types

type AllowedIPs

type AllowedIPs []*net.IPNet

AllowedIPs determines who can set x-forwarded-for.

func MakeIPs added in v0.1.15

func MakeIPs(upstreams []string) (a AllowedIPs)

MakeIPs turns a list of CIDR strings (or plain IPs) into a list of net.IPNet. This "allowed" list is later used to check incoming IPs from web requests.

func (AllowedIPs) Contains

func (n AllowedIPs) Contains(ip string) bool

Contains returns true if an IP is allowed.

func (AllowedIPs) String

func (n AllowedIPs) String() (s string)

String turns a list of allowedIPs into a printable masterpiece.

type Config

type Config struct {
	BindAddr   string              `json:"bindAddr" toml:"bind_addr" xml:"bind_addr" yaml:"bindAddr"`
	SSLCrtFile string              `json:"sslCertFile" toml:"ssl_cert_file" xml:"ssl_cert_file" yaml:"sslCertFile"`
	SSLKeyFile string              `json:"sslKeyFile" toml:"ssl_key_file" xml:"ssl_key_file" yaml:"sslKeyFile"`
	AutoUpdate string              `json:"autoUpdate" toml:"auto_update" xml:"auto_update" yaml:"autoUpdate"`
	SendDash   cnfg.Duration       `json:"sendDash" toml:"send_dash" xml:"send_dash" yaml:"sendDash"`
	Mode       string              `json:"mode" toml:"mode" xml:"mode" yaml:"mode"`
	Upstreams  []string            `json:"upstreams" toml:"upstreams" xml:"upstreams" yaml:"upstreams"`
	Timeout    cnfg.Duration       `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"`
	Plex       *plex.Server        `json:"plex" toml:"plex" xml:"plex" yaml:"plex"`
	Snapshot   *snapshot.Config    `json:"snapshot" toml:"snapshot" xml:"snapshot" yaml:"snapshot"`
	Services   *services.Config    `json:"services" toml:"services" xml:"services" yaml:"services"`
	Service    []*services.Service `json:"service" toml:"service" xml:"service" yaml:"service"`
	*logs.LogConfig
	*apps.Apps
	Allow AllowedIPs `json:"-" toml:"-" xml:"-" yaml:"-"`
}

Config represents the data in our config file.

func (*Config) FindAndReturn

func (c *Config) FindAndReturn(configFile string, write bool) (string, bool, string)

FindAndReturn return a config file. Write one if requested.

func (*Config) Get

func (c *Config) Get(configFile, envPrefix string, logger *logs.Logger) (*notifiarr.Config, error)

Get parses a config file and environment variables. Sometimes the app runs without a config file entirely.

func (*Config) Write

func (c *Config) Write(file string) (string, error)

Write config to a file.

type Flags added in v0.1.14

type Flags struct {
	*flag.FlagSet
	VerReq     bool
	Restart    bool
	Updated    bool
	PSlist     bool
	Write      string
	Curl       string
	ConfigFile string
	EnvPrefix  string
	Headers    []string
}

Flags are our CLI input flags.

func (*Flags) ParseArgs added in v0.1.14

func (f *Flags) ParseArgs(args []string)

ParseArgs stores the cli flag data into the Flags pointer.

Jump to

Keyboard shortcuts

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