Documentation
¶
Overview ¶
Package setup is the first run every surface shares: where the configuration file goes, Jira's address and token checked against Jira before they are kept, the OS keychain offered for the token, a messaging webhook, and the file written. The command line's `config init` asks its questions at a prompt; the terminal and the web ask the same ones in a form.
Index ¶
- Variables
- func Beneath(layers config.Files) (config.Config, config.Revision, error)
- func Check(ctx context.Context, doer jira.Doer, settings config.Jira) (string, error)
- func Create(path string, layers config.Files, cfg config.Config, over config.Revision) error
- func Identify(user jira.User) string
- func Keep(ctx context.Context, ...) (config.Jira, error)
- func Keepable(err error) bool
- func NotIgnored(ctx context.Context, path string) bool
- func RefuseExisting(path string) error
- type Answers
- type Destination
- type Guide
- type Offer
- type Place
- type Request
- type Where
- type Written
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExists reports a file setup would have written over: it holds // credentials that are not recoverable once overwritten. ErrExists = errors.New("configuration file already exists") // ErrNoKeychain reports the token asked to be kept in a keychain where // none is wired, or under a dry run. ErrNoKeychain = errors.New("there is no keychain here to keep the token in") // ErrNoHome reports a file asked for in a home directory where none is // known. ErrNoHome = errors.New("there is no home directory here to keep the file in") // ErrNoToken reports a token asked to be kept in the keychain that is // empty: storing it would replace whatever the keychain kept before. ErrNoToken = errors.New("there is no token to keep in the keychain") )
Errors a setup reports. Callers tell them apart with errors.Is.
Functions ¶
func Beneath ¶
Beneath is the configuration a new file starts from — the home file's, when it lies over one, or the defaults — at the revision of the pair, which the save must still find them at.
func Create ¶
Create writes cfg to path as Save does, but only as a new file: anything already there, a link included, is refused with ErrExists and nothing is written, so a file made between RefuseExisting and the write is never replaced and a link is never followed.
func Identify ¶
Identify names a user, falling back to the login when an instance is configured to withhold display names.
func Keep ¶
func Keep( ctx context.Context, store func(ctx context.Context, service, secret string) error, settings config.Jira, ) (config.Jira, error)
Keep moves the token in settings into the OS keychain through store, under the item for its address and under ctx, so the file reads it from there rather than holding the secret. An empty token is refused with ErrNoToken before store is asked: kept, it would replace whatever the keychain held for the address.
func Keepable ¶
Keepable reports whether a check that failed with err may be kept anyway: a Jira that is unreachable or refuses the token now may answer later, but an address that is not one never will, and one carrying a username and password must never reach the file.
func NotIgnored ¶
NotIgnored reports a file inside a repository that git does not ignore, which, holding credentials, could be committed. Outside a repository there is nothing to commit it to.
func RefuseExisting ¶
RefuseExisting refuses anything already at path: a file, or a link, even one to nothing, which a write would follow to wherever it points.
Types ¶
type Answers ¶
Answers are what setup asks: Jira's address and token, and a Slack incoming webhook. A blank address or webhook skips that question.
type Destination ¶
Destination is a place a file may go, the file it would be, and whether the keychain can keep the token for that file: wherever one is wired, since any file may read the item kept for its Jira address.
type Guide ¶
type Guide struct {
Where Where
Doer jira.Doer
StoreSecret func(ctx context.Context, service, secret string) error
}
Guide is setup as a form asks for it, all answers at once: where it runs, the transport Jira is checked over, and the OS keychain, keeping a secret under the item named, under the context it is asked under, nil where none is wired.
func (Guide) Offer ¶
Offer is where the file may go here, and whether the keychain can keep the token for each.
func (Guide) Write ¶
Write writes the file request asks for, unless one is already there: the answers over the home file it lies over, the token in the keychain item for its address when asked. It checks nothing; a form checks the token first and says how that went. Everything that can refuse the write does before the keychain is touched, and the file is made before the keychain keeps the token, so a write that fails leaves the keychain as it was. The keychain keeps the token under ctx.
type Offer ¶
type Offer struct {
Places []Destination
}
Offer is what a form offers: where the file may go, the repository first.
type Request ¶
Request is a setup a form asks for: where, the answers, and whether the token goes to the keychain.
type Where ¶
Where is where setup runs: the working directory and the home directory.
func (Where) IsHomeFile ¶ added in v0.9.0
IsHomeFile reports whether the file for place is the home directory's: the home place, or the repository's where the repository's root is the home directory.
func (Where) Layers ¶
Layers are the home file the file for place lies over, and that file; empty when it stands alone: written to the home directory, where the repository's root is the home directory, with no home directory known, or with no home file to lie over.
func (Where) Places ¶
Places are where the file may go here: the repository, and the home directory where one is known.
func (Where) RefuseLinked ¶ added in v0.9.0
RefuseLinked refuses the file for place when it is a link, to a file or to none yet, with config.ErrLinkedFile: replacing it would write wherever it points. Only the home file may be one, as a dotfiles checkout makes it.
func (Where) Save ¶ added in v0.9.0
Save writes cfg to the file for place, replacing whatever is there: over a home file, the layer that differs from it, while the pair is at the revision over, and otherwise a file of its own. A file other than the home file that is a link is refused, as RefuseLinked refuses it, and nothing is written.