fixed default credentials
This commit is contained in:
parent
846386c7ff
commit
cf757802a3
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/streadway/amqp"
|
"github.com/streadway/amqp"
|
||||||
"google.golang.org/api/option"
|
"google.golang.org/api/option"
|
||||||
"os"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -56,21 +55,17 @@ func (conn *PubSubConn) Send(msg string) error {
|
|||||||
|
|
||||||
if conn.svc == nil {
|
if conn.svc == nil {
|
||||||
var creds option.ClientOption
|
var creds option.ClientOption
|
||||||
|
var svc *pubsub.Client
|
||||||
|
var err error
|
||||||
credPath := conn.ep.PubSub.CredPath
|
credPath := conn.ep.PubSub.CredPath
|
||||||
|
|
||||||
if credPath != "" {
|
if credPath != "" {
|
||||||
|
|
||||||
creds = option.WithCredentialsFile(credPath)
|
creds = option.WithCredentialsFile(credPath)
|
||||||
|
svc, err = pubsub.NewClient(ctx, conn.ep.PubSub.Project, creds)
|
||||||
} else {
|
} else {
|
||||||
|
svc, err = pubsub.NewClient(ctx, conn.ep.PubSub.Project)
|
||||||
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, creds)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user