Skip to content
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
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"fmt"
"html/template"
"os"
"syscall"

"github.com/mlabouardy/nexus-cli/registry"
"github.com/urfave/cli"
"golang.org/x/crypto/ssh/terminal"
)

const (
Expand Down Expand Up @@ -111,7 +113,11 @@ func setNexusCredentials(c *cli.Context) error {
fmt.Print("Enter Nexus Username: ")
fmt.Scan(&username)
fmt.Print("Enter Nexus Password: ")
fmt.Scan(&password)
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
return fmt.Errorf("Could not read password from terminal: %v", err)
}
password = string(bytePassword)

data := struct {
Host string
Expand Down
5 changes: 4 additions & 1 deletion registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/BurntSushi/toml"
"html"
"net/http"
"os"

"github.com/BurntSushi/toml"
)

const ACCEPT_HEADER = "application/vnd.docker.distribution.manifest.v2+json"
Expand Down Expand Up @@ -51,6 +53,7 @@ func NewRegistry() (Registry, error) {
if _, err := toml.DecodeFile(CREDENTIALS_FILE, &r); err != nil {
return r, err
}
r.Password = html.UnescapeString(r.Password)
return r, nil
}

Expand Down