Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Rename credential package to config
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsanford committed Feb 24, 2019
1 parent f218b3b commit ec19421
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions bittray.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package main

import (
"github.com/michaelsanford/bittray/credentials"
"github.com/michaelsanford/bittray/config"
"github.com/michaelsanford/bittray/tray"
)

func main() {
var ok bool

user, url := credentials.GetConfig()
user, url := config.GetConfig()

if user == "" || url == "" {
credentials.DestroyConfig()
ok = credentials.AskConfig()
config.DestroyConfig()
ok = config.AskConfig()
if !ok {
return
}
Expand Down
8 changes: 4 additions & 4 deletions credentials/credentials.go → config/credentials.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package credentials
package config

import (
"fmt"
Expand Down Expand Up @@ -56,7 +56,7 @@ func StoreConfig(username string, url string) {

func askUser() (user string, ok bool, err error) {
for user == "" {
user, ok, err = dlgs.Entry("Username", "Please enter your BitBucket username", "")
user, ok, err = dlgs.Entry("Username", "Your BitBucket username:", "")
if user == "" && ok {
dlgs.Error("Username missing", "Ok, so, without your username I can't log you in.\n\nTry again...")
} else {
Expand All @@ -69,7 +69,7 @@ func askUser() (user string, ok bool, err error) {
func askURL() (pURL string, ok bool, err error) {

for pURL == "" {
pURL, ok, err = dlgs.Entry("Bitbucket URL", "Enter your Bitbucket URL in exactly the format shown", "http://host.domain.com:7990")
pURL, ok, err = dlgs.Entry("Bitbucket URL", "Your Bitbucket URL:", "http://host.domain.com:7990")

_, parsingErr := url.ParseRequestURI(pURL)
if parsingErr != nil && ok {
Expand All @@ -86,7 +86,7 @@ func askURL() (pURL string, ok bool, err error) {
// AskPass interactively asks the user for their Bitbucket password
func AskPass() (pass string, ok bool, err error) {
for pass == "" {
pass, ok, err = dlgs.Password("Bitbucket Password", "Enter your Bitbucket password.")
pass, ok, err = dlgs.Password("Bitbucket Password", "Your Bitbucket password:")
if pass == "" || !ok {
return "", ok, err
}
Expand Down
2 changes: 1 addition & 1 deletion docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Storing it is arguably actively harmful.

# Conclusion

[So I just don't store it](https://github.com/michaelsanford/bittray/blob/master/credentials/credentials.go).
[So I just don't store it](https://github.com/michaelsanford/bittray/blob/master/config/config.go).
6 changes: 3 additions & 3 deletions polling/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package polling

import (
"github.com/getlantern/systray"
"github.com/michaelsanford/bittray/credentials"
"github.com/michaelsanford/bittray/config"
"github.com/tidwall/gjson"
"io/ioutil"
"net/http"
Expand All @@ -19,10 +19,10 @@ const pollIntervalSec = 10
func Poll() <-chan int8 {
items := make(chan int8)

user, url := credentials.GetConfig()
user, url := config.GetConfig()
endpoint := url + "/rest/api/1.0/dashboard/pull-requests?state=OPEN&role=REVIEWER&participantStatus=UNAPPROVED"

pass, ok, _ := credentials.AskPass()
pass, ok, _ := config.AskPass()
if !ok {
systray.Quit()
}
Expand Down

0 comments on commit ec19421

Please sign in to comment.