Skip to content

Commit

Permalink
fix: pkg/interactive/prompt remove unused named returns and make AskO…
Browse files Browse the repository at this point in the history
…ne error handling explicit
  • Loading branch information
mkcp committed Sep 9, 2024
1 parent c83386d commit 9a8cbc9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/pkg/interactive/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ func PromptSigPassword() ([]byte, error) {
prompt := &survey.Password{
Message: "Private key password (empty for no password): ",
}
return []byte(password), survey.AskOne(prompt, &password)
err := survey.AskOne(prompt, &password)
if err != nil {
return []byte{}, err
}
return []byte(password), nil
}

// PromptVariable prompts the user for a value for a variable
func PromptVariable(variable v1alpha1.InteractiveVariable) (value string, err error) {
func PromptVariable(variable v1alpha1.InteractiveVariable) (string, error) {
if variable.Description != "" {
message.Question(variable.Description)
}
Expand All @@ -33,5 +37,10 @@ func PromptVariable(variable v1alpha1.InteractiveVariable) (value string, err er
Default: variable.Default,
}

return value, survey.AskOne(prompt, &value)
var value string
err := survey.AskOne(prompt, &value)
if err != nil {
return "", err
}
return value, nil
}

0 comments on commit 9a8cbc9

Please sign in to comment.