diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-24 17:21:24 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-24 17:21:24 +0200 |
commit | c86e7231b223d532e26ab5449715c65b6b4e3fde (patch) | |
tree | 8d863617aad2dce304b266cd1e493d7ba5c4690f /bridge/github | |
parent | 2282cbb595ff5cc603d11645ddc833d70de9ad9d (diff) | |
download | git-bug-c86e7231b223d532e26ab5449715c65b6b4e3fde.tar.gz |
bridge: validate config before use
Diffstat (limited to 'bridge/github')
-rw-r--r-- | bridge/github/config.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go index b8531dfe..79025cfb 100644 --- a/bridge/github/config.go +++ b/bridge/github/config.go @@ -93,6 +93,22 @@ func (*Github) Configure(repo repository.RepoCommon) (core.Configuration, error) return nil, nil } +func (*Github) ValidateConfig(conf core.Configuration) error { + if _, ok := conf[keyToken]; !ok { + return fmt.Errorf("missing %s key", keyToken) + } + + if _, ok := conf[keyUser]; !ok { + return fmt.Errorf("missing %s key", keyUser) + } + + if _, ok := conf[keyProject]; !ok { + return fmt.Errorf("missing %s key", keyProject) + } + + return nil +} + func requestToken(note, username, password string) (*http.Response, error) { return requestTokenWith2FA(note, username, password, "") } |