From 63fcabbc9b7d76fc2972b4cd5665667a21b1b931 Mon Sep 17 00:00:00 2001 From: upodroid Date: Fri, 6 Nov 2020 15:38:29 +0000 Subject: [PATCH 1/3] remove path from code --- backend/remote-state/gcs/backend.go | 7 ------- website/docs/backends/types/gcs.html.md | 2 -- 2 files changed, 9 deletions(-) diff --git a/backend/remote-state/gcs/backend.go b/backend/remote-state/gcs/backend.go index 1ad3078b9a54..942706f73f5b 100644 --- a/backend/remote-state/gcs/backend.go +++ b/backend/remote-state/gcs/backend.go @@ -45,13 +45,6 @@ func New() backend.Backend { Description: "The name of the Google Cloud Storage bucket", }, - "path": { - Type: schema.TypeString, - Optional: true, - Description: "Path of the default state file", - Deprecated: "Use the \"prefix\" option instead", - }, - "prefix": { Type: schema.TypeString, Optional: true, diff --git a/website/docs/backends/types/gcs.html.md b/website/docs/backends/types/gcs.html.md index b1fb6f157354..7f8baed166ae 100644 --- a/website/docs/backends/types/gcs.html.md +++ b/website/docs/backends/types/gcs.html.md @@ -70,8 +70,6 @@ The following configuration options are supported: `credentials` field. * `prefix` - (Optional) GCS prefix inside the bucket. Named states for workspaces are stored in an object called `/.tfstate`. - * `path` - (Deprecated) GCS path to the state file of the default state. For - backwards compatibility only, use `prefix` instead. * `encryption_key` / `GOOGLE_ENCRYPTION_KEY` - (Optional) A 32 byte base64 encoded 'customer supplied encryption key' used to encrypt all state. For more information see [Customer Supplied Encryption From 9de6ea017a3738a90ed54baf36a44b1796523104 Mon Sep 17 00:00:00 2001 From: upodroid Date: Fri, 6 Nov 2020 18:24:33 +0000 Subject: [PATCH 2/3] remove deadcode --- backend/remote-state/gcs/backend.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/remote-state/gcs/backend.go b/backend/remote-state/gcs/backend.go index 942706f73f5b..0c81a2dc08ca 100644 --- a/backend/remote-state/gcs/backend.go +++ b/backend/remote-state/gcs/backend.go @@ -114,8 +114,6 @@ func (b *Backend) configure(ctx context.Context) error { b.prefix = b.prefix + "/" } - b.defaultStateFile = strings.TrimLeft(data.Get("path").(string), "/") - var opts []option.ClientOption // Add credential source From 27913ebe71a3e1d1dcff53fbc9435b75405db806 Mon Sep 17 00:00:00 2001 From: upodroid Date: Fri, 6 Nov 2020 19:50:03 +0000 Subject: [PATCH 3/3] remove more dead code --- backend/remote-state/gcs/backend.go | 5 ++--- backend/remote-state/gcs/backend_state.go | 6 ------ backend/remote-state/gcs/backend_test.go | 22 +++++++++------------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/backend/remote-state/gcs/backend.go b/backend/remote-state/gcs/backend.go index 0c81a2dc08ca..df418cc83918 100644 --- a/backend/remote-state/gcs/backend.go +++ b/backend/remote-state/gcs/backend.go @@ -27,9 +27,8 @@ type Backend struct { storageClient *storage.Client storageContext context.Context - bucketName string - prefix string - defaultStateFile string + bucketName string + prefix string encryptionKey []byte } diff --git a/backend/remote-state/gcs/backend_state.go b/backend/remote-state/gcs/backend_state.go index d4916190f1d9..a7e511cd2b3a 100644 --- a/backend/remote-state/gcs/backend_state.go +++ b/backend/remote-state/gcs/backend_state.go @@ -146,15 +146,9 @@ func (b *Backend) StateMgr(name string) (statemgr.Full, error) { } func (b *Backend) stateFile(name string) string { - if name == backend.DefaultStateName && b.defaultStateFile != "" { - return b.defaultStateFile - } return path.Join(b.prefix, name+stateFileSuffix) } func (b *Backend) lockFile(name string) string { - if name == backend.DefaultStateName && b.defaultStateFile != "" { - return strings.TrimSuffix(b.defaultStateFile, stateFileSuffix) + lockFileSuffix - } return path.Join(b.prefix, name+lockFileSuffix) } diff --git a/backend/remote-state/gcs/backend_test.go b/backend/remote-state/gcs/backend_test.go index 6d71cb341f33..dd089aeb4aa0 100644 --- a/backend/remote-state/gcs/backend_test.go +++ b/backend/remote-state/gcs/backend_test.go @@ -25,23 +25,19 @@ func TestStateFile(t *testing.T) { t.Parallel() cases := []struct { - prefix string - defaultStateFile string - name string - wantStateFile string - wantLockFile string + prefix string + name string + wantStateFile string + wantLockFile string }{ - {"state", "", "default", "state/default.tfstate", "state/default.tflock"}, - {"state", "", "test", "state/test.tfstate", "state/test.tflock"}, - {"state", "legacy.tfstate", "default", "legacy.tfstate", "legacy.tflock"}, - {"state", "legacy.tfstate", "test", "state/test.tfstate", "state/test.tflock"}, - {"state", "legacy.state", "default", "legacy.state", "legacy.state.tflock"}, - {"state", "legacy.state", "test", "state/test.tfstate", "state/test.tflock"}, + {"state", "default", "state/default.tfstate", "state/default.tflock"}, + {"state", "test", "state/test.tfstate", "state/test.tflock"}, + {"state", "test", "state/test.tfstate", "state/test.tflock"}, + {"state", "test", "state/test.tfstate", "state/test.tflock"}, } for _, c := range cases { b := &Backend{ - prefix: c.prefix, - defaultStateFile: c.defaultStateFile, + prefix: c.prefix, } if got := b.stateFile(c.name); got != c.wantStateFile {