Fix tests and make URLs optional in config
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
9748aa47af
commit
3992f97d8c
7 changed files with 80 additions and 93 deletions
|
|
@ -121,7 +121,7 @@ garm-cli init --name=dev --url=https://runner.example.com --username=admin --pas
|
|||
|
||||
func ensureDefaultEndpoints(loginURL string) (err error) {
|
||||
if metadataURL == "" {
|
||||
metadataURL, err = url.JoinPath(loginURL, "api/v1/callbacks")
|
||||
metadataURL, err = url.JoinPath(loginURL, "api/v1/metadata")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -160,10 +160,16 @@ func promptUnsetInitVariables() error {
|
|||
}
|
||||
|
||||
if loginPassword == "" {
|
||||
loginPassword, err = common.PromptPassword("Password")
|
||||
passwd, err := common.PromptPassword("Password", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = common.PromptPassword("Confirm password", passwd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
loginPassword = passwd
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ func promptUnsetLoginVariables() error {
|
|||
}
|
||||
|
||||
if loginPassword == "" {
|
||||
loginPassword, err = common.PromptPassword("Password")
|
||||
loginPassword, err = common.PromptPassword("Password", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/nbutton23/zxcvbn-go"
|
||||
)
|
||||
|
||||
func PromptPassword(label string) (string, error) {
|
||||
func PromptPassword(label string, compareTo string) (string, error) {
|
||||
if label == "" {
|
||||
label = "Password"
|
||||
}
|
||||
|
|
@ -31,6 +31,9 @@ func PromptPassword(label string) (string, error) {
|
|||
if passwordStenght.Score < 4 {
|
||||
return errors.New("password is too weak")
|
||||
}
|
||||
if compareTo != "" && compareTo != input {
|
||||
return errors.New("passwords do not match")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue