config

package
v0.0.0-...-3f1964b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 17 Imported by: 33

Documentation

Overview

Package config creates a client configuration from various sources.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFactotum = errors.Str("factotum not initialized: no secrets provided")

ErrNoFactotum indicates that the returned config contains no Factotum, and that the user requested this by setting secrets=none in the configuration.

Functions

func DefaultSecretsDir

func DefaultSecretsDir(u upspin.UserName) (string, error)

DefaultSecretsDir returns the default directory in which the given user's Upspin key pair should be kept ($HOME/.ssh/$USERNAME).

func FromFile

func FromFile(name string) (upspin.Config, error)

FromFile initializes a config using the given file. If the file cannot be opened but the name can be found in $HOME/upspin, that file is used.

func Home

func Home() string

Home returns the home directory of the user, or panics if it cannot find one.

func Homedir

func Homedir() (string, error)

Homedir returns the home directory of the OS' logged-in user. TODO(adg): move to osutil package?

func InitConfig

func InitConfig(r io.Reader) (upspin.Config, error)

InitConfig returns a config generated by parsing the contents of the io.Reader, typically a configuration file.

A configuration file should be of the format

# lines that begin with a hash are ignored
key = value

where key may be one of username, keyserver, dirserver, storeserver, packing, secrets, or tlscerts.

The default configuration file location is $HOME/upspin/config. If passed a non-nil io.Reader, that is used instead of the default file.

Any endpoints (keyserver, dirserver, storeserver) not set in the data for the config will be set to the "unassigned" transport and an empty network address, except keyserver which defaults to "remote,key.upspin.io:443". If an endpoint is specified without a transport it is assumed to be the address component of a remote endpoint. If a remote endpoint is specified without a port in its address component the port is assumed to be 443.

The default value for packing is "ee".

The default value for secrets is "$HOME/.ssh/$USERNAME". The special value "none" indicates there are no secrets to load; in this case, the returned config will not include a Factotum and the returned error is ErrNoFactotum.

The tlscerts key specifies a directory containing PEM certificates define the certificate pool used for verifying client TLS connections, replacing the root certificate list provided by the operating system. Files without the suffix ".pem" are ignored. The default value for tlscerts is the empty string, in which case just the system roots are used.

func IsLocal

func IsLocal(address string) bool

IsLocal returns true if the address is host local.

func LocalName

func LocalName(config upspin.Config, service string) string

LocalName constructs the host local name for a service.

func New

func New() upspin.Config

New returns a config with all fields set as defaults.

func SetCacheEndpoint

func SetCacheEndpoint(cfg upspin.Config, e upspin.Endpoint) upspin.Config

SetDirEndpoint returns a config derived from the given config with the given dir endpoint.

func SetDirEndpoint

func SetDirEndpoint(cfg upspin.Config, e upspin.Endpoint) upspin.Config

SetDirEndpoint returns a config derived from the given config with the given dir endpoint.

func SetFactotum

func SetFactotum(cfg upspin.Config, f upspin.Factotum) upspin.Config

SetFactotum returns a config derived from the given config with the given factotum.

func SetFlagValues

func SetFlagValues(cfg upspin.Config, cmd string) error

SetFlagValues updates any flag that is still at its default value. It will apply all the flags possible and return the last error seen.

func SetKeyEndpoint

func SetKeyEndpoint(cfg upspin.Config, e upspin.Endpoint) upspin.Config

SetKeyEndpoint returns a config derived from the given config with the given key endpoint.

func SetPacking

func SetPacking(cfg upspin.Config, p upspin.Packing) upspin.Config

SetPacking returns a config derived from the given config with the given packing.

func SetStoreEndpoint

func SetStoreEndpoint(cfg upspin.Config, e upspin.Endpoint) upspin.Config

SetStoreEndpoint returns a config derived from the given config with the given store endpoint.

func SetUserName

func SetUserName(cfg upspin.Config, u upspin.UserName) upspin.Config

SetUserName returns a config derived from the given config with the given user name.

func SetValue

func SetValue(cfg upspin.Config, key, val string) upspin.Config

SetValue returns a config derived from the given config that contains the given key/value pair.

func User

func User(ctx upspin.Config) *upspin.User

User returns an upspin.User record for the user in the given configuration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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