@@ -31,6 +31,7 @@ import (
3131
3232 "knative.dev/func/pkg/docker"
3333 "knative.dev/func/pkg/docker/creds"
34+ "knative.dev/func/pkg/functions"
3435 . "knative.dev/func/pkg/testing"
3536)
3637
@@ -434,7 +435,7 @@ func TestNewCredentialsProvider(t *testing.T) {
434435 creds .WithPromptForCredentials (tt .args .promptUser ),
435436 creds .WithVerifyCredentials (tt .args .verifyCredentials ),
436437 creds .WithAdditionalCredentialLoaders (tt .args .additionalLoaders ... ))
437- got , err := credentialsProvider (context .Background (), tt .args .registry + "/someorg/someimage:sometag" )
438+ got , err := credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : tt .args .registry + "/someorg/someimage:sometag" }} )
438439 if err != nil {
439440 t .Errorf ("unexpected error: %v" , err )
440441 return
@@ -456,7 +457,7 @@ func TestNewCredentialsProviderEmptyCreds(t *testing.T) {
456457 t .Fatal ("unreachable" )
457458 return nil
458459 }))
459- c , err := credentialsProvider (context .Background (), "localhost:5555/someorg/someimage:sometag" )
460+ c , err := credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : "localhost:5555/someorg/someimage:sometag" }} )
460461 if err != nil {
461462 t .Error (err )
462463 }
@@ -472,9 +473,9 @@ func TestCredentialsProviderSavingFromUserInput(t *testing.T) {
472473 setUpMockHelper ("docker-credential-mock" , helper )(t )
473474
474475 var pwdCbkInvocations int
475- pwdCbk := func (r string ) (Credentials , error ) {
476+ pwdCbk := func (_ functions. Function , r string ) (Credentials , error ) {
476477 pwdCbkInvocations ++
477- return correctPwdCallback (r )
478+ return correctPwdCallback (functions. Function {}, r )
478479 }
479480
480481 chooseNoStore := func (available []string ) (string , error ) {
@@ -499,7 +500,7 @@ func TestCredentialsProviderSavingFromUserInput(t *testing.T) {
499500 creds .WithPromptForCredentials (pwdCbk ),
500501 creds .WithVerifyCredentials (correctVerifyCbk ),
501502 creds .WithPromptForCredentialStore (chooseNoStore ))
502- _ , err := credentialsProvider (context .Background (), "docker.io/someorg/someimage:sometag" )
503+ _ , err := credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : "docker.io/someorg/someimage:sometag" }} )
503504 if err != nil {
504505 t .Errorf ("unexpected error: %v" , err )
505506 return
@@ -519,7 +520,7 @@ func TestCredentialsProviderSavingFromUserInput(t *testing.T) {
519520 creds .WithPromptForCredentials (pwdCbk ),
520521 creds .WithVerifyCredentials (correctVerifyCbk ),
521522 creds .WithPromptForCredentialStore (chooseMockStore ))
522- _ , err = credentialsProvider (context .Background (), "docker.io/someorg/someimage:sometag" )
523+ _ , err = credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : "docker.io/someorg/someimage:sometag" }} )
523524 if err != nil {
524525 t .Errorf ("unexpected error: %v" , err )
525526 return
@@ -542,7 +543,7 @@ func TestCredentialsProviderSavingFromUserInput(t *testing.T) {
542543 creds .WithPromptForCredentials (pwdCbkThatShallNotBeCalled (t )),
543544 creds .WithVerifyCredentials (correctVerifyCbk ),
544545 creds .WithPromptForCredentialStore (shallNotBeInvoked ))
545- _ , err = credentialsProvider (context .Background (), "docker.io/someorg/someimage:sometag" )
546+ _ , err = credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : "docker.io/someorg/someimage:sometag" }} )
546547 if err != nil {
547548 t .Errorf ("unexpected error: %v" , err )
548549 return
@@ -606,7 +607,7 @@ func TestCredentialsWithoutHome(t *testing.T) {
606607 creds .WithVerifyCredentials (tt .args .verifyCredentials ),
607608 )
608609
609- got , err := credentialsProvider (context .Background (), tt .args .registry + "/someorg/someimage:sometag" )
610+ got , err := credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : tt .args .registry + "/someorg/someimage:sometag" }} )
610611
611612 // ASSERT
612613 if err != nil {
@@ -766,7 +767,7 @@ func TestCredentialsHomePermissions(t *testing.T) {
766767 creds .WithVerifyCredentials (tt .args .verifyCredentials ),
767768 )
768769
769- got , err := credentialsProvider (context .Background (), tt .args .registry + "/someorg/someimage:sometag" )
770+ got , err := credentialsProvider (context .Background (), functions. Function { Build : functions. BuildSpec { Image : tt .args .registry + "/someorg/someimage:sometag" }} )
770771 if err != nil {
771772 t .Errorf ("%v" , err )
772773 return
@@ -861,27 +862,27 @@ func withPopulatedFuncAuthConfig(t *testing.T) {
861862
862863func pwdCbkThatShallNotBeCalled (t * testing.T ) creds.CredentialsCallback {
863864 t .Helper ()
864- return func (registry string ) (Credentials , error ) {
865+ return func (f functions. Function , registry string ) (Credentials , error ) {
865866 return Credentials {}, errors .New ("this pwd cbk code shall not be called" )
866867 }
867868}
868869
869- func pwdCbkFirstWrongThenCorrect (t * testing.T ) func (registry string ) (Credentials , error ) {
870+ func pwdCbkFirstWrongThenCorrect (t * testing.T ) func (f functions. Function , registry string ) (Credentials , error ) {
870871 t .Helper ()
871872 var firstInvocation bool
872- return func (registry string ) (Credentials , error ) {
873+ return func (f functions. Function , registry string ) (Credentials , error ) {
873874 if registry != "index.docker.io" && registry != "quay.io" {
874875 return Credentials {}, fmt .Errorf ("unexpected registry: %s" , registry )
875876 }
876877 if firstInvocation {
877878 firstInvocation = false
878879 return Credentials {Username : dockerIoUser , Password : "badPwd" }, nil
879880 }
880- return correctPwdCallback (registry )
881+ return correctPwdCallback (functions. Function {}, registry )
881882 }
882883}
883884
884- func correctPwdCallback (registry string ) (Credentials , error ) {
885+ func correctPwdCallback (_ functions. Function , registry string ) (Credentials , error ) {
885886 if registry == "index.docker.io" {
886887 return Credentials {Username : dockerIoUser , Password : dockerIoUserPwd }, nil
887888 }
0 commit comments