sysconf

package
v0.2024.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package sysconf provides system level configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(dst *Config) error

Load loads into dst any user supplied config from json files and CLI arguments. CLI arguments take precedence.

func LoadAllFromJSON

func LoadAllFromJSON(dst *Config) error

LoadAllFromJSON populates dst with json formatted config from all dst.ConfigDirs x dst.ConfigFiles. If any file path doesn't exist then it will be skipped.

func LoadFromArgs

func LoadFromArgs(dst *Config, args ...string) ([]string, error)

LoadFromArgs populates fields in dst from the given command line arguments. Args should not include the program name, just like flag.FlagSet.Parse. Returns an error if the flags failed to parse or unknown flags exist.

func LoadFromConfigFilesJSON

func LoadFromConfigFilesJSON(dst *Config) error

LoadFromConfigFilesJSON populates dst with json formatted config from all dst.ConfigFiles (based on current working directory).

func LoadFromJSON

func LoadFromJSON(dst *Config, jsonData []byte) error

LoadFromJSON populates dst with the given json formatted bytes.

func LoadFromJSONFile

func LoadFromJSONFile(dst *Config, filePath string) error

LoadFromJSONFile reads filePath and calls LoadFromJSON.

Types

type Certs

type Certs struct {
	KeyFile   string `json:"keyFile,omitempty"`
	CertFile  string `json:"certFile,omitempty"`
	RootsFile string `json:"rootsFile,omitempty"`

	HTTPCert     bool   `json:"httpCert,omitempty"` // have the https stack (grpc-web and hosting) use different pki.Source from the grpc stack
	HTTPKeyFile  string `json:"httpKeyFile,omitempty"`
	HTTPCertFile string `json:"httpCertFile,omitempty"`
}

Certs encapsulates different settings used for loading and present certificates to clients and servers.

func (*Certs) FillDefaults

func (c *Certs) FillDefaults() *Certs

type Config

type Config struct {
	ConfigDirs  []string `json:"-"` // Dirs to look in for system config files. Defaults to [".conf"]
	ConfigFiles []string `json:"-"` // Filenames we load in ConfigDirs for system config. Defaults to ["system.conf.json", "system.json"]

	// The smart core name of the controller.
	// Can be overridden by app config.
	Name string `json:"name,omitempty"`

	Logger      *zap.Config `json:"logger,omitempty"`
	ListenGRPC  string      `json:"listenGrpc,omitempty"`
	ListenHTTPS string      `json:"listenHttps,omitempty"`
	// FooAddr are preferred IP/host others use to connect to us.
	// Defaults to netutil.PublicAddress
	GRPCAddr string `json:"grpcAddr,omitempty"`
	HTTPAddr string `json:"httpAddr,omitempty"`

	AppConfig []string `json:"appConfig,omitempty"` // defaults to [".conf/app.conf.json"]
	DataDir   string   `json:"dataDir,omitempty"`   // defaults to .data/

	StaticHosting []http.StaticHostingConfig `json:"staticHosting"`
	CertConfig    *Certs                     `json:"certs,omitempty"`
	Cors          http.CorsConfig            `json:"cors,omitempty"`

	Systems map[string]system.RawConfig `json:"systems,omitempty"`

	Policy     policy.Policy `json:"-"` // Override the policy used for RPC calls. Defaults to policy.Default
	PolicyMode PolicyMode    `json:"-"` // How to apply the policy. Unsafe and can disable security checks. Defaults to PolicyOn.

	DriverFactories map[string]driver.Factory `json:"-"` // keyed by driver name
	AutoFactories   map[string]auto.Factory   `json:"-"` // keyed by automation type
	SystemFactories map[string]system.Factory `json:"-"` // keyed by system type
	ZoneFactories   map[string]zone.Factory   `json:"-"` // keyed by zone type
}

Config configures how the controller should run.

func Default

func Default() Config

type PolicyMode

type PolicyMode string
const (
	PolicyOn    PolicyMode = "on"    // Always check requests against the policy.
	PolicyOff   PolicyMode = "off"   // Never check requests against the policy, allow all requests.
	PolicyCheck PolicyMode = "check" // Check requests against the policy if the request has a token or client cert.
)

func (*PolicyMode) Set

func (pm *PolicyMode) Set(s string) error

func (*PolicyMode) String

func (pm *PolicyMode) String() string

Jump to

Keyboard shortcuts

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