Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira password from STDIN #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmd/jiraworklog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package main

import (
"errors"
"fmt"
"strconv"
"syscall"

"github.com/mkobaly/jiraworklog/job"
"golang.org/x/crypto/ssh/terminal"

//"github.com/mkobaly/jiraworklog/test"
"net/http"
Expand Down Expand Up @@ -81,6 +84,22 @@ func main() {
}
}

if cmdline.IsOptionSet("ask") {
fmt.Println("Please enter Jira username:")
userBytes, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
logger.WithError(err).Fatal("Reading Jira Username from the STDIN failed")
}
cfg.Jira.Username = string(userBytes)
fmt.Println("Please enter Jira password:")
passBytes, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
logger.WithError(err).Fatal("Reading Jira Password from the STDIN failed")
}
cfg.Jira.Password = string(passBytes)
fmt.Println("Thanks!")
}

//Repo Settings
repoType := "BOLTDB"
if cmdline.IsOptionSet("r") {
Expand Down
16 changes: 16 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,25 @@ OPTIONS
-h, --help print help and exit
-p, --port <8180> default port to serve rest API from (default: 8180)
-r, --repo <BOLTDB> specific repo to use (MSSQL, BOLTDB) (default: BOLTDB)
-a, --ask Ask for Jira username and password from the STDIN
-v, --verbose verbose logging
```

## Environment values

You can override values from the configuration file using the ENV.

### Example

JWL_JIRA_URL=> Config.Jira.URL
Only JWL_JIRA_* are currently supported

### Usage

```
JWL_JIRA_USERNAME="urho" JWL_JIRA_PASSWORD="kekkonen" ./jiraworklog
```

## Running for the first time

### Linux or Windows
Expand Down