From b5da2bb86be7f2f0b348f688d30429a3a52cadf3 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Wed, 20 Feb 2019 14:11:58 +0000 Subject: [PATCH] tweak: Switch to anonymous authentication for GCS --- function_test.go | 5 ----- go.mod | 2 +- internal/pkg/loaders/gcs.go | 3 ++- internal/pkg/loaders/gcs_test.go | 6 ------ 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/function_test.go b/function_test.go index 57c27cc9..7918d5dd 100644 --- a/function_test.go +++ b/function_test.go @@ -5,7 +5,6 @@ import ( "fmt" "net/http" "net/http/httptest" - "os" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -15,10 +14,6 @@ import ( ) var _ = Describe("Function as a Service", func() { - if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" { - Skip("Google Cloud credentials are not available") - } - ts := httptest.NewServer(http.HandlerFunc(Bender)) defer ts.Close() diff --git a/go.mod b/go.mod index e0e4be4d..273e9ea6 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/sirupsen/logrus v1.2.0 github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect github.com/urfave/cli v1.20.0 - google.golang.org/api v0.1.0 // indirect + google.golang.org/api v0.1.0 google.golang.org/genproto v0.0.0-20190111180523-db91494dd46c // indirect google.golang.org/grpc v1.18.0 // indirect ) diff --git a/internal/pkg/loaders/gcs.go b/internal/pkg/loaders/gcs.go index 508b4b85..ef8cd9f7 100644 --- a/internal/pkg/loaders/gcs.go +++ b/internal/pkg/loaders/gcs.go @@ -5,6 +5,7 @@ import ( "encoding/json" "cloud.google.com/go/storage" + "google.golang.org/api/option" "github.com/SierraSoftworks/bender/pkg/models" sentry "github.com/SierraSoftworks/sentry-go" "github.com/pkg/errors" @@ -32,7 +33,7 @@ func (l *gcsLoader) Load() ([]*models.Quote, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - client, err := storage.NewClient(ctx) + client, err := storage.NewClient(ctx, option.WithoutAuthentication()) if err != nil { return nil, errors.Wrap(err, "failed to access cloud storage account") } diff --git a/internal/pkg/loaders/gcs_test.go b/internal/pkg/loaders/gcs_test.go index a3ba405e..ae372249 100644 --- a/internal/pkg/loaders/gcs_test.go +++ b/internal/pkg/loaders/gcs_test.go @@ -5,15 +5,9 @@ import ( . "github.com/onsi/gomega" . "github.com/SierraSoftworks/bender/internal/pkg/loaders" - - "os" ) var _ = Describe("GCS", func() { - if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" { - Skip("Google Cloud credentials are not available") - } - Describe("NewGCSLoader", func() { loader := NewGCSLoader("cdn.sierrasoftworks.com", "bender/quotes.json") It("should return a loader", func() {