From 3bc14620c0771017883ebb7226517d093e6eebf4 Mon Sep 17 00:00:00 2001 From: Daniel Mangum <31777345+hasheddan@users.noreply.github.com> Date: Tue, 18 Jun 2019 16:18:05 -0500 Subject: [PATCH] backend/remote-state: remove dead code This remote-state adapter is no longer used, because the old remote state mechanism was removed in Terraform v0.12. --- backend/remote-state/backend.go | 72 ---------------------------- backend/remote-state/backend_test.go | 11 ----- backend/remote-state/testing.go | 17 ------- 3 files changed, 100 deletions(-) delete mode 100644 backend/remote-state/backend.go delete mode 100644 backend/remote-state/backend_test.go delete mode 100644 backend/remote-state/testing.go diff --git a/backend/remote-state/backend.go b/backend/remote-state/backend.go deleted file mode 100644 index ef32356d1..000000000 --- a/backend/remote-state/backend.go +++ /dev/null @@ -1,72 +0,0 @@ -// Package remotestate implements a Backend for remote state implementations -// from the state/remote package that also implement a backend schema for -// configuration. -package remotestate - -import ( - "context" - - "github.com/zclconf/go-cty/cty" - - "github.com/hashicorp/terraform/backend" - "github.com/hashicorp/terraform/helper/schema" - "github.com/hashicorp/terraform/state/remote" - "github.com/hashicorp/terraform/states/statemgr" - "github.com/hashicorp/terraform/tfdiags" -) - -// Backend implements backend.Backend for remote state backends. -// -// All exported fields should be set. This struct should only be used -// by implementers of backends, not by consumers. If you're consuming, please -// use a higher level package such as Consul backends. -type Backend struct { - // Backend should be set to the configuration schema. ConfigureFunc - // should not be set on the schema. - *schema.Backend - - // ConfigureFunc takes the ctx from a schema.Backend and returns a - // fully configured remote client to use for state operations. - ConfigureFunc func(ctx context.Context) (remote.Client, error) - - client remote.Client -} - -func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics { - - // Set our configureFunc manually - b.Backend.ConfigureFunc = func(ctx context.Context) error { - c, err := b.ConfigureFunc(ctx) - if err != nil { - return err - } - - // Set the client for later - b.client = c - return nil - } - - return b.Backend.Configure(obj) -} - -func (b *Backend) Workspaces() ([]string, error) { - return nil, backend.ErrWorkspacesNotSupported -} - -func (b *Backend) DeleteWorkspace(name string) error { - return backend.ErrWorkspacesNotSupported -} - -func (b *Backend) StateMgr(name string) (statemgr.Full, error) { - // This shouldn't happen - if b.client == nil { - panic("nil remote client") - } - - if name != backend.DefaultStateName { - return nil, backend.ErrWorkspacesNotSupported - } - - s := &remote.State{Client: b.client} - return s, nil -} diff --git a/backend/remote-state/backend_test.go b/backend/remote-state/backend_test.go deleted file mode 100644 index d1f7adcc1..000000000 --- a/backend/remote-state/backend_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package remotestate - -import ( - "testing" - - "github.com/hashicorp/terraform/backend" -) - -func TestBackend_impl(t *testing.T) { - var _ backend.Backend = new(Backend) -} diff --git a/backend/remote-state/testing.go b/backend/remote-state/testing.go deleted file mode 100644 index 17d9b80f5..000000000 --- a/backend/remote-state/testing.go +++ /dev/null @@ -1,17 +0,0 @@ -package remotestate - -import ( - "testing" - - "github.com/hashicorp/terraform/backend" - "github.com/hashicorp/terraform/state/remote" -) - -func TestClient(t *testing.T, raw backend.Backend) { - b, ok := raw.(*Backend) - if !ok { - t.Fatalf("not Backend: %T", raw) - } - - remote.TestClient(t, b.client) -}