Documentation
¶
Overview ¶
Package cli provides the connection settings a takt client resolves from flags, the environment and the config file, in that order.
The file is the human path: `takt auth login` writes the token it minted here, because a child process cannot set an environment variable in its parent shell. The environment is the machine path: CI injects TAKT_TOKEN in one line. Flags are the most specific and win over both. Exported so that anyone writing their own takt client can honour the same settings.
Index ¶
Constants ¶
const DefaultAddress = "http://localhost:7373"
DefaultAddress is where a client connects when nothing names a server.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// The address of the takt server, as a URL.
Address string `toml:"address"`
// The token presented as a bearer credential. Empty sends no credential.
Token string `toml:"token"`
// The path of a PEM certificate authority file to check the server's
// certificate against instead of the system roots.
CACert string `toml:"ca_cert"`
}
The Config type contains the settings a client connects with.
There is no flag for the token, deliberately: a token passed as a flag lands in shell history and process listings for no benefit the other sources lack.
func Load ¶
Load reads the config file at the given path, reporting an absent file as the zero Config: a client that never logged in simply has no file yet.
func Resolve ¶
Resolve returns the settings a client should connect with, taking each field from the most specific source that supplies it: the given flag values, then the TAKT_ADDRESS, TAKT_TOKEN and TAKT_CA_CERT environment variables, then the config file at the given path. An empty flag value means the flag was not given.
The address falls back to DefaultAddress when nothing supplies one, so a client on the same host as its server needs no configuration at all.