1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Clean up the Gerrit module's API credentials loading

This commit is contained in:
Chris Cummer 2018-07-31 15:02:27 -07:00
parent ebad879e0a
commit 8fdaf52610
4 changed files with 17 additions and 14 deletions

View File

@ -4,8 +4,6 @@ date: 2018-06-27T15:55:42-07:00
draft: false
---
<img src="/imgs/modules/gerrit.png" width="640" height="384" alt="gerrit screenshot" />
Displays information about your projects hosted on Gerrit:
#### Open Incoming Reviews
@ -16,17 +14,14 @@ All open reviews that are requesting your approval.
All open reviews created by you.
<img src="/imgs/modules/gerrit.png" width="640" height="167" alt="gerrit screenshot" />
## Source Code
```bash
wtf/gerrit/
```
## Required ENV Variables
<span class="caption">Key:</span> `WTF_GERRIT_PASSWORD` <br />
<span class="caption">Action:</span> Your <a href="https://gerrit-review.googlesource.com/Documentation/user-upload.html#http">Gerrit HTTP Password</a>.
## Keyboard Commands
<span class="caption">Key:</span> `/` <br />
@ -59,6 +54,7 @@ gerrit:
projects:
- org/test-project"
- dotfiles
password: "mypassword"
username: "myname"
verifyServerCertificate: false
```
@ -83,8 +79,11 @@ Values: A valid URI.
`projects` <br />
A list of Gerrit project names to fetch data for. <br />
`password` <br />
Value: Your <a href="https://gerrit-review.googlesource.com/Documentation/user-upload.html#http">Gerrit HTTP Password</a>.
`username` <br />
Your Gerrit username. <br />
Your Gerrit username.
`verifyServerCertificate` <br />
_Optional_ <br />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -19,8 +19,6 @@ type Client struct {
func NewClient(url string) *Client {
client := Client{
apiBase: url,
//apiKey: os.Getenv("WTF_BAMBOO_HR_TOKEN"),
//subdomain: os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN"),
}
client.loadAPICredentials()

View File

@ -3,13 +3,14 @@ package gerrit
import (
"crypto/tls"
"fmt"
"net/http"
"os"
"regexp"
glb "github.com/andygrunwald/go-gerrit"
"github.com/gdamore/tcell"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
"net/http"
"os"
"regexp"
)
const HelpText = `
@ -43,7 +44,12 @@ var (
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
baseURL := wtf.Config.UString("wtf.mods.gerrit.domain")
username := wtf.Config.UString("wtf.mods.gerrit.username")
password := os.Getenv("WTF_GERRIT_PASSWORD")
password := wtf.Config.UString(
"wtf.mods.gerrit.password",
os.Getenv("WTF_GERRIT_PASSWORD"),
)
verifyServerCertificate := wtf.Config.UBool("wtf.mods.gerrit.verifyServerCertificate", true)
httpClient := &http.Client{Transport: &http.Transport{