From cf757802a322612758f40e83d5b691966615a150 Mon Sep 17 00:00:00 2001 From: Mads Schou-Andreasen Date: Fri, 22 May 2020 10:03:55 +0200 Subject: [PATCH] fixed default credentials --- internal/endpoint/pubsub.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/internal/endpoint/pubsub.go b/internal/endpoint/pubsub.go index 13d29403..61a47b85 100644 --- a/internal/endpoint/pubsub.go +++ b/internal/endpoint/pubsub.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/streadway/amqp" "google.golang.org/api/option" - "os" "sync" "time" ) @@ -56,21 +55,17 @@ func (conn *PubSubConn) Send(msg string) error { if conn.svc == nil { var creds option.ClientOption + var svc *pubsub.Client + var err error credPath := conn.ep.PubSub.CredPath + if credPath != "" { - creds = option.WithCredentialsFile(credPath) + svc, err = pubsub.NewClient(ctx, conn.ep.PubSub.Project, creds) } else { - - envCredPath := os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") - creds = option.WithCredentialsFile(credPath) - - if envCredPath == "" { - fmt.Println(errMissingGoogleCredentials) - return errMissingGoogleCredentials - } + svc, err = pubsub.NewClient(ctx, conn.ep.PubSub.Project) } - svc, err := pubsub.NewClient(ctx, conn.ep.PubSub.Project, creds) + if err != nil { fmt.Println(err) return err