From 3b9c5e5bbb26e63833142869531fcdfc68e9cb01 Mon Sep 17 00:00:00 2001 From: Upo Date: Fri, 6 Nov 2020 21:35:40 +0000 Subject: [PATCH] backend/gcs: remove deprecated "path" config argument (#26841) --- backend/remote-state/gcs/backend.go | 14 ++------------ backend/remote-state/gcs/backend_state.go | 6 ------ backend/remote-state/gcs/backend_test.go | 22 +++++++++------------- website/docs/backends/types/gcs.html.md | 2 -- 4 files changed, 11 insertions(+), 33 deletions(-) diff --git a/backend/remote-state/gcs/backend.go b/backend/remote-state/gcs/backend.go index dd714a98e..9e943d5e3 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 } @@ -45,13 +44,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, @@ -137,8 +129,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 diff --git a/backend/remote-state/gcs/backend_state.go b/backend/remote-state/gcs/backend_state.go index d4916190f..a7e511cd2 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 6d71cb341..dd089aeb4 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 { diff --git a/website/docs/backends/types/gcs.html.md b/website/docs/backends/types/gcs.html.md index 589f23d51..fc8cd9d3d 100644 --- a/website/docs/backends/types/gcs.html.md +++ b/website/docs/backends/types/gcs.html.md @@ -101,8 +101,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