From 2db49493ff5969fa5f3c8149d209d0f508777799 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Fri, 7 Dec 2018 17:00:38 +0100 Subject: [PATCH] backend/remote: fix symlink issues and Windows support The issues with uploading configurations are fixed in our dependencies, but we need these changes to make things work again with those updated dependencies. --- backend/atlas/state_client.go | 5 +++-- backend/atlas/state_client_test.go | 5 +++-- backend/remote/backend_mock.go | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/atlas/state_client.go b/backend/atlas/state_client.go index e49cb71924..77d2d485c2 100644 --- a/backend/atlas/state_client.go +++ b/backend/atlas/state_client.go @@ -2,6 +2,7 @@ package atlas import ( "bytes" + "context" "crypto/md5" "crypto/tls" "crypto/x509" @@ -231,7 +232,7 @@ func (c *stateClient) http() (*retryablehttp.Client, error) { } rc := retryablehttp.NewClient() - rc.CheckRetry = func(resp *http.Response, err error) (bool, error) { + rc.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) { if err != nil { // don't bother retrying if the certs don't match if err, ok := err.(*url.Error); ok { @@ -242,7 +243,7 @@ func (c *stateClient) http() (*retryablehttp.Client, error) { // continue retrying return true, nil } - return retryablehttp.DefaultRetryPolicy(resp, err) + return retryablehttp.DefaultRetryPolicy(ctx, resp, err) } t := cleanhttp.DefaultTransport() diff --git a/backend/atlas/state_client_test.go b/backend/atlas/state_client_test.go index 5135bfd7d7..8a1925111e 100644 --- a/backend/atlas/state_client_test.go +++ b/backend/atlas/state_client_test.go @@ -2,6 +2,7 @@ package atlas import ( "bytes" + "context" "crypto/md5" "crypto/tls" "crypto/x509" @@ -74,12 +75,12 @@ func TestStateClient_noRetryOnBadCerts(t *testing.T) { // Instrument CheckRetry to make sure we didn't retry retries := 0 oldCheck := httpClient.CheckRetry - httpClient.CheckRetry = func(resp *http.Response, err error) (bool, error) { + httpClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) { if retries > 0 { t.Fatal("retried after certificate error") } retries++ - return oldCheck(resp, err) + return oldCheck(ctx, resp, err) } _, err = client.Get() diff --git a/backend/remote/backend_mock.go b/backend/remote/backend_mock.go index eac6b68392..413daab78f 100644 --- a/backend/remote/backend_mock.go +++ b/backend/remote/backend_mock.go @@ -322,6 +322,10 @@ func (m *mockOrganizations) Capacity(ctx context.Context, name string) (*tfe.Cap return &tfe.Capacity{Pending: pending, Running: running}, nil } +func (m *mockOrganizations) Entitlements(ctx context.Context, name string) (*tfe.Entitlements, error) { + panic("not implemented") +} + func (m *mockOrganizations) RunQueue(ctx context.Context, name string, options tfe.RunQueueOptions) (*tfe.RunQueue, error) { rq := &tfe.RunQueue{} @@ -979,6 +983,10 @@ func (m *mockWorkspaces) Unlock(ctx context.Context, workspaceID string) (*tfe.W return w, nil } +func (m *mockWorkspaces) ForceUnlock(ctx context.Context, workspaceID string) (*tfe.Workspace, error) { + panic("not implemented") +} + func (m *mockWorkspaces) AssignSSHKey(ctx context.Context, workspaceID string, options tfe.WorkspaceAssignSSHKeyOptions) (*tfe.Workspace, error) { panic("not implemented") }