From 85e109714d6fd2c0a06dec5c1c35f5c46f59282a Mon Sep 17 00:00:00 2001 From: Tim Leguijt Date: Mon, 18 Sep 2023 17:17:26 +0200 Subject: [PATCH 1/2] feat: rename remote_state plugin to backend --- internal/config/parse_global.go | 15 ++++++++------- internal/config/schemas/schema-1.yaml | 4 ++-- internal/state/schemas/aws.schema.json | 2 +- internal/state/schemas/azure.schema.json | 2 +- internal/state/schemas/gcp.schema.json | 2 +- internal/state/schemas/local.schema.json | 2 +- .../state/schemas/terraform_cloud.schema.json | 2 +- internal/state/terraform_cloud.go | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/internal/config/parse_global.go b/internal/config/parse_global.go index 59b2915f..f8ede278 100644 --- a/internal/config/parse_global.go +++ b/internal/config/parse_global.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "github.com/mach-composer/mach-composer-cli/internal/cli" "gopkg.in/yaml.v3" ) @@ -40,7 +41,7 @@ func parseGlobalNode(cfg *MachConfig, globalNode *yaml.Node) error { cli.DeprecationWarning(&cli.DeprecationOptions{ Message: "the usage of `aws_remote_state` is deprecated and will be removed in the next major version", Details: ` - Please move the configuration to the remote_state block and add the provider name as plugin. + Please move the configuration to the remote_state block and add the provider name as backend. For example: @@ -52,7 +53,7 @@ func parseGlobalNode(cfg *MachConfig, globalNode *yaml.Node) error { To: remote_state: - plugin: aws + backend: aws key_prefix: mach-composer region: eu-central-1 bucket: "mcc-terraform-state" @@ -70,7 +71,7 @@ func parseGlobalNode(cfg *MachConfig, globalNode *yaml.Node) error { cli.DeprecationWarning(&cli.DeprecationOptions{ Message: "the usage of `azure_remote_state` is deprecated and will be removed in the next major version", Details: ` - Please move the configuration to the remote_state block and add the provider name as plugin. + Please move the configuration to the remote_state block and add the provider name as backend. For example: @@ -82,7 +83,7 @@ func parseGlobalNode(cfg *MachConfig, globalNode *yaml.Node) error { To: remote_state: - plugin: azure + backend: azure resource_group: some-resource-group storage_account: some-account container_name: some-container @@ -102,12 +103,12 @@ func parseGlobalNode(cfg *MachConfig, globalNode *yaml.Node) error { return err } - pluginName, ok := data["plugin"].(string) + backendName, ok := data["backend"].(string) if !ok { - return fmt.Errorf("plugin needs to be defined for remote_state") + return fmt.Errorf("backend needs to be defined for remote_state") } - cfg.Global.TerraformStateProvider = pluginName + cfg.Global.TerraformStateProvider = backendName return nil } } diff --git a/internal/config/schemas/schema-1.yaml b/internal/config/schemas/schema-1.yaml index eb3c1ef7..0b8fa515 100644 --- a/internal/config/schemas/schema-1.yaml +++ b/internal/config/schemas/schema-1.yaml @@ -90,9 +90,9 @@ definitions: - type: object additionalProperties: true required: - - plugin + - backend properties: - plugin: + backend: type: string enum: - aws diff --git a/internal/state/schemas/aws.schema.json b/internal/state/schemas/aws.schema.json index 48a9b76a..aac09056 100644 --- a/internal/state/schemas/aws.schema.json +++ b/internal/state/schemas/aws.schema.json @@ -8,7 +8,7 @@ "region" ], "properties": { - "plugin": { + "backend": { "type": "string" }, "bucket": { diff --git a/internal/state/schemas/azure.schema.json b/internal/state/schemas/azure.schema.json index c40b568f..75deb460 100644 --- a/internal/state/schemas/azure.schema.json +++ b/internal/state/schemas/azure.schema.json @@ -8,7 +8,7 @@ "container_name" ], "properties": { - "plugin": { + "backend": { "type": "string" }, "resource_group": { diff --git a/internal/state/schemas/gcp.schema.json b/internal/state/schemas/gcp.schema.json index bc47e223..3efe2d95 100644 --- a/internal/state/schemas/gcp.schema.json +++ b/internal/state/schemas/gcp.schema.json @@ -6,7 +6,7 @@ "bucket" ], "properties": { - "plugin": { + "backend": { "type": "string" }, "bucket": { diff --git a/internal/state/schemas/local.schema.json b/internal/state/schemas/local.schema.json index 6a52a370..8bae4bff 100644 --- a/internal/state/schemas/local.schema.json +++ b/internal/state/schemas/local.schema.json @@ -3,7 +3,7 @@ "description": "Local state backend configuration.", "additionalProperties": false, "properties": { - "plugin": { + "backend": { "type": "string" }, "path": { diff --git a/internal/state/schemas/terraform_cloud.schema.json b/internal/state/schemas/terraform_cloud.schema.json index 39224eb1..27ebabb4 100644 --- a/internal/state/schemas/terraform_cloud.schema.json +++ b/internal/state/schemas/terraform_cloud.schema.json @@ -6,7 +6,7 @@ "organization" ], "properties": { - "plugin": { + "backend": { "type": "string" }, "hostname": { diff --git a/internal/state/terraform_cloud.go b/internal/state/terraform_cloud.go index 285dcb1a..6182bb4d 100644 --- a/internal/state/terraform_cloud.go +++ b/internal/state/terraform_cloud.go @@ -64,7 +64,7 @@ func (tcr *TerraformCloudRenderer) RemoteState() (string, error) { template := ` data "terraform_remote_state" "{{ .Key }}" { - backend = "aws" + backend = "remote" config = { organization = "{{ .State.Organization }}" From ac860e8612006a6b3289431c9f636085c3019b16 Mon Sep 17 00:00:00 2001 From: Tim Leguijt Date: Mon, 18 Sep 2023 17:26:06 +0200 Subject: [PATCH 2/2] update test --- internal/config/parse_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/parse_test.go b/internal/config/parse_test.go index ac9094a6..b2b6b7c4 100644 --- a/internal/config/parse_test.go +++ b/internal/config/parse_test.go @@ -199,7 +199,7 @@ func TestParse(t *testing.T) { TerraformStateProvider: "my-plugin", TerraformConfig: &TerraformConfig{ RemoteState: map[string]any{ - "plugin": "my-plugin", + "backend": "aws", }, Providers: map[string]string{ "aws": "3.0.0",