From 46650ec1163aebe3dbf2aa92e5b761f3fd0eb0a0 Mon Sep 17 00:00:00 2001 From: ademariag Date: Tue, 27 Oct 2020 20:22:20 +0000 Subject: [PATCH 1/2] Fix scopes that were not being passed on to the Google provider --- cmd/drone-autoscaler/main.go | 1 + drivers/google/create.go | 1 + provider.go | 3 ++- server/writer_test.go | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/drone-autoscaler/main.go b/cmd/drone-autoscaler/main.go index e990844e..4a7706de 100644 --- a/cmd/drone-autoscaler/main.go +++ b/cmd/drone-autoscaler/main.go @@ -235,6 +235,7 @@ func setupProvider(c config.Config) (autoscaler.Provider, error) { google.WithServiceAccountEmail(c.Google.ServiceAccountEmail), google.WithProject(c.Google.Project), google.WithTags(c.Google.Tags...), + google.WithScopes(c.Google.Scopes...), google.WithUserData(c.Google.UserData), google.WithUserDataFile(c.Google.UserDataFile), google.WithZone(c.Google.Zone), diff --git a/drivers/google/create.go b/drivers/google/create.go index 1bfbeb5a..99fbfcc9 100644 --- a/drivers/google/create.go +++ b/drivers/google/create.go @@ -142,6 +142,7 @@ func (p *provider) Create(ctx context.Context, opts autoscaler.InstanceCreateOpt Size: p.size, Address: address, ServiceAccountEmail: p.serviceAccountEmail, + Scopes: p.scopes, } logger. diff --git a/provider.go b/provider.go index 7a6ba770..369b6f8a 100644 --- a/provider.go +++ b/provider.go @@ -48,7 +48,7 @@ type Provider interface { // An Instance represents a server instance // (e.g Digital Ocean Droplet). type Instance struct { - Provider ProviderType + Provider ProviderType ID string Name string Address string @@ -56,6 +56,7 @@ type Instance struct { Image string Size string ServiceAccountEmail string + Scopes []string } // InstanceCreateOpts define soptional instructions for diff --git a/server/writer_test.go b/server/writer_test.go index 53b77a19..4c561667 100644 --- a/server/writer_test.go +++ b/server/writer_test.go @@ -122,7 +122,7 @@ func TestWriteJSON(t *testing.T) { if got, want := w.Body.String(), "{\"hello\":\"world\"}\n"; got != want { t.Errorf("Want JSON body %q, got %q", want, got) } - if got, want := w.HeaderMap.Get("Content-Type"), "application/json"; got != want { + if got, want := w.HeaderMap.Get("Content-Type"), "application/json; charset=utf-8"; got != want { t.Errorf("Want Content-Type %q, got %q", want, got) } if got, want := w.Code, http.StatusTeapot; got != want { From 0b0d424e5dc4970d22095760cec2003fce848172 Mon Sep 17 00:00:00 2001 From: Alessandro De Maria Date: Tue, 27 Oct 2020 20:26:45 +0000 Subject: [PATCH 2/2] go fmt --- drivers/google/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/google/create.go b/drivers/google/create.go index 99fbfcc9..c17fd33d 100644 --- a/drivers/google/create.go +++ b/drivers/google/create.go @@ -142,7 +142,7 @@ func (p *provider) Create(ctx context.Context, opts autoscaler.InstanceCreateOpt Size: p.size, Address: address, ServiceAccountEmail: p.serviceAccountEmail, - Scopes: p.scopes, + Scopes: p.scopes, } logger.