Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
Signed-off-by: David Fridrich <fridrich.david19@gmail.com>
  • Loading branch information
gauron99 committed Nov 26, 2024
1 parent f10328b commit 0c162c3
Show file tree
Hide file tree
Showing 6 changed files with 11,849 additions and 11,809 deletions.
9 changes: 4 additions & 5 deletions cmd/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ import (

"knative.dev/func/pkg/docker"
"knative.dev/func/pkg/docker/creds"
fn "knative.dev/func/pkg/functions"
)

func NewPromptForCredentials(in io.Reader, out, errOut io.Writer) func(f fn.Function, registry string) (docker.Credentials, error) {
func NewPromptForCredentials(in io.Reader, out, errOut io.Writer) func(registryWithRepo string) (docker.Credentials, error) {
firstTime := true
return func(f fn.Function, registry string) (docker.Credentials, error) {
return func(registryWithRepo string) (docker.Credentials, error) {
var result docker.Credentials
if firstTime {
firstTime = false
fmt.Fprintf(out, "Please provide credentials for image '%s'.\n", f.Build.Image)
fmt.Fprintf(out, "Please provide credentials for repository '%s'.\n", registryWithRepo)
} else {
fmt.Fprintf(out, "Incorrect credentials for image '%s'. Please make sure the image name is correct and try again.\n", f.Build.Image)
fmt.Fprintf(out, "Incorrect credentials for repository '%s'. Please make sure the image name is correct and try again.\n", registryWithRepo)
}

var qs = []*survey.Question{
Expand Down
3 changes: 1 addition & 2 deletions cmd/prompt/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hinshun/vt10x"

"knative.dev/func/pkg/docker"
fn "knative.dev/func/pkg/functions"
)

const (
Expand Down Expand Up @@ -72,7 +71,7 @@ func Test_NewPromptForCredentials(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
credPrompt := NewPromptForCredentials(tt.in, tt.out, tt.errOut)
cred, err := credPrompt(fn.Function{}, "example.com")
cred, err := credPrompt("example.com")
if err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit 0c162c3

Please sign in to comment.