-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Handle errors for unsupported dynamic block use cases #69
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
48f37d1
track unused errors
lantoli db91f27
implement error handling
lantoli bc83bc6
fix typo
lantoli 0b66033
refactor convertConfigsWithDynamicBlock
lantoli c4d2c7d
check only one block in getDynamicBlock
lantoli 5d504eb
remove unneeded comments
lantoli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
internal/convert/testdata/adv2v2/dynamic_regions_config_invalid_multiple_blocks.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
resource "mongodbatlas_advanced_cluster" "multiple_blocks" { | ||
project_id = var.project_id | ||
name = var.cluster_name | ||
cluster_type = var.cluster_type | ||
replication_specs { | ||
num_shards = var.replication_specs.num_shards | ||
dynamic "region_configs" { | ||
for_each = var.replication_specs.region_configs | ||
content { | ||
priority = region_configs.value.priority | ||
provider_name = region_configs.value.provider_name | ||
region_name = region_configs.value.region_name | ||
electable_specs { | ||
instance_size = region_configs.value.instance_size | ||
node_count = region_configs.value.electable_node_count | ||
} | ||
} | ||
} | ||
region_configs { # inline block is not allowed with dynamic blocks | ||
priority = 0 | ||
provider_name = "AWS" | ||
region_name = "US_EAST_1" | ||
read_only_specs { | ||
instance_size = var.instance_size | ||
node_count = 1 | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
internal/convert/testdata/adv2v2/dynamic_replication_specs_invalid_multiple_blocks.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
resource "mongodbatlas_advanced_cluster" "multiple_blocks" { | ||
project_id = var.project_id | ||
name = var.cluster_name | ||
cluster_type = var.cluster_type | ||
dynamic "replication_specs" { | ||
for_each = var.replication_specs | ||
content { | ||
num_shards = replication_specs.value.num_shards | ||
dynamic "region_configs" { | ||
for_each = replication_specs.value.region_configs | ||
content { | ||
priority = region_configs.value.priority | ||
provider_name = region_configs.value.provider_name | ||
region_name = region_configs.value.region_name | ||
electable_specs { | ||
instance_size = region_configs.value.instance_size | ||
node_count = region_configs.value.electable_node_count | ||
} | ||
} | ||
} | ||
} | ||
} | ||
replication_specs { # inline block is not allowed with dynamic blocks | ||
region_configs { | ||
priority = 7 | ||
provider_name = "AWS" | ||
region_name = "EU_WEST_1" | ||
electable_specs { | ||
instance_size = "M10" | ||
node_count = 3 | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...al/convert/testdata/adv2v2/dynamic_replication_specs_invalid_multiple_config_blocks.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
resource "mongodbatlas_advanced_cluster" "multiple_blocks" { | ||
project_id = var.project_id | ||
name = var.cluster_name | ||
cluster_type = var.cluster_type | ||
dynamic "replication_specs" { | ||
for_each = var.replication_specs | ||
content { | ||
num_shards = replication_specs.value.num_shards | ||
dynamic "region_configs" { | ||
for_each = replication_specs.value.region_configs | ||
content { | ||
priority = region_configs.value.priority | ||
provider_name = region_configs.value.provider_name | ||
region_name = region_configs.value.region_name | ||
electable_specs { | ||
instance_size = region_configs.value.instance_size | ||
node_count = region_configs.value.electable_node_count | ||
} | ||
} | ||
} | ||
region_configs { # inline block is not allowed with dynamic blocks | ||
priority = 0 | ||
provider_name = "AWS" | ||
region_name = "US_EAST_1" | ||
read_only_specs { | ||
instance_size = var.instance_size | ||
node_count = 1 | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
internal/convert/testdata/clu2adv/dynamic_regions_config_invalid_multiple_blocks.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
resource "mongodbatlas_cluster" "multiple_blocks" { | ||
project_id = var.project_id | ||
name = "cluster" | ||
cluster_type = "SHARDED" | ||
provider_name = "AWS" | ||
provider_instance_size_name = "M10" | ||
replication_specs { | ||
num_shards = var.replication_specs.num_shards | ||
dynamic "regions_config" { | ||
for_each = var.replication_specs.regions_config | ||
content { | ||
region_name = regions_config.value.region_name | ||
electable_nodes = regions_config.value.electable_nodes | ||
priority = regions_config.value.prio | ||
read_only_nodes = regions_config.value.read_only_nodes | ||
} | ||
} | ||
regions_config { # inline block is not allowed with dynamic blocks | ||
region_name = "US_EAST_1" | ||
read_only_nodes = 1 | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
internal/convert/testdata/clu2adv/dynamic_replication_specs_invalid_multiple_blocks.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Based on https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/examples/migrate_cluster_to_advanced_cluster/module_maintainer/v1/main.tf | ||
resource "mongodbatlas_cluster" "this" { | ||
project_id = var.project_id | ||
name = var.cluster_name | ||
auto_scaling_disk_gb_enabled = var.auto_scaling_disk_gb_enabled | ||
cluster_type = var.cluster_type | ||
disk_size_gb = var.disk_size | ||
mongo_db_major_version = var.mongo_db_major_version | ||
provider_instance_size_name = var.instance_size | ||
provider_name = var.provider_name | ||
dynamic "replication_specs" { | ||
for_each = var.replication_specs | ||
content { | ||
num_shards = replication_specs.value.num_shards | ||
zone_name = replication_specs.value.zone_name | ||
dynamic "regions_config" { | ||
for_each = replication_specs.value.regions_config | ||
content { | ||
electable_nodes = regions_config.value.electable_nodes | ||
priority = regions_config.value.priority | ||
read_only_nodes = regions_config.value.read_only_nodes | ||
region_name = regions_config.value.region_name | ||
} | ||
} | ||
} | ||
} | ||
replication_specs { # inline block is not allowed with dynamic blocks | ||
num_shards = 1 | ||
regions_config { | ||
region_name = "US_EAST_1" | ||
electable_nodes = 3 | ||
priority = 7 | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...l/convert/testdata/clu2adv/dynamic_replication_specs_invalid_multiple_config_blocks.in.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Based on https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/examples/migrate_cluster_to_advanced_cluster/module_maintainer/v1/main.tf | ||
resource "mongodbatlas_cluster" "this" { | ||
project_id = var.project_id | ||
name = var.cluster_name | ||
auto_scaling_disk_gb_enabled = var.auto_scaling_disk_gb_enabled | ||
cluster_type = var.cluster_type | ||
disk_size_gb = var.disk_size | ||
mongo_db_major_version = var.mongo_db_major_version | ||
provider_instance_size_name = var.instance_size | ||
provider_name = var.provider_name | ||
dynamic "replication_specs" { | ||
for_each = var.replication_specs | ||
content { | ||
num_shards = replication_specs.value.num_shards | ||
zone_name = replication_specs.value.zone_name | ||
dynamic "regions_config" { | ||
for_each = replication_specs.value.regions_config | ||
content { | ||
electable_nodes = regions_config.value.electable_nodes | ||
priority = regions_config.value.priority | ||
read_only_nodes = regions_config.value.read_only_nodes | ||
region_name = regions_config.value.region_name | ||
} | ||
} | ||
regions_config { # inline block is not allowed with dynamic blocks | ||
region_name = "US_EAST_1" | ||
read_only_nodes = 1 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure all items in errors.json are used