Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename remote_state plugin to backend #297

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions internal/config/parse_global.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"fmt"

"github.com/mach-composer/mach-composer-cli/internal/cli"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -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:

Expand All @@ -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"
Expand All @@ -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:

Expand All @@ -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
Expand All @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions internal/config/schemas/schema-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ definitions:
- type: object
additionalProperties: true
required:
- plugin
- backend
properties:
plugin:
backend:
type: string
enum:
- aws
Expand Down
2 changes: 1 addition & 1 deletion internal/state/schemas/aws.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"region"
],
"properties": {
"plugin": {
"backend": {
"type": "string"
},
"bucket": {
Expand Down
2 changes: 1 addition & 1 deletion internal/state/schemas/azure.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"container_name"
],
"properties": {
"plugin": {
"backend": {
"type": "string"
},
"resource_group": {
Expand Down
2 changes: 1 addition & 1 deletion internal/state/schemas/gcp.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bucket"
],
"properties": {
"plugin": {
"backend": {
"type": "string"
},
"bucket": {
Expand Down
2 changes: 1 addition & 1 deletion internal/state/schemas/local.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Local state backend configuration.",
"additionalProperties": false,
"properties": {
"plugin": {
"backend": {
"type": "string"
},
"path": {
Expand Down
2 changes: 1 addition & 1 deletion internal/state/schemas/terraform_cloud.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"organization"
],
"properties": {
"plugin": {
"backend": {
"type": "string"
},
"hostname": {
Expand Down
2 changes: 1 addition & 1 deletion internal/state/terraform_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (tcr *TerraformCloudRenderer) RemoteState() (string, error) {

template := `
data "terraform_remote_state" "{{ .Key }}" {
backend = "aws"
backend = "remote"

config = {
organization = "{{ .State.Organization }}"
Expand Down
Loading