Skip to content

Commit 90f13e6

Browse files
authored
chore: Deprecate id in plural data sources (#3476)
* deprecate id in plural data sources * changelog * fix changelog * remove projects from changelog * update changelog text
1 parent a4b1d2c commit 90f13e6

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

.changelog/3476.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:note
2+
data-source/mongodbatlas_stream_connections: Deprecates the `id` attribute as it is a random assigned value which should not be used
3+
```
4+
5+
```release-note:note
6+
data-source/mongodbatlas_stream_instances: Deprecates the `id` attribute as it is a random assigned value which should not be used
7+
```

docs/data-sources/projects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ data "mongodbatlas_projects" "test" {
4141
* `items_per_page` - (Optional) Number of items to return per page, up to a maximum of 500. Defaults to `100`.
4242

4343

44-
* `id` - Autogenerated Unique ID for this data source.
44+
* `id` - (Deprecated) Autogenerated Unique ID for this data source.
4545
* `total_count` - Represents the total of the projects
4646

4747
* `results` - A list where each represents a Projects.

internal/common/conversion/schema_generation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
dsschema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
99
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
10+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
1011
)
1112

1213
type DataSourceSchemaRequest struct {
@@ -54,7 +55,7 @@ func PluralDataSourceSchemaFromResource(rs schema.Schema, req *PluralDataSourceS
5455
MarkdownDescription: resultsDoc,
5556
}
5657
if req.HasLegacyFields {
57-
rootAttrs["id"] = dsschema.StringAttribute{Computed: true}
58+
rootAttrs["id"] = dsschema.StringAttribute{Computed: true, DeprecationMessage: constant.DeprecationParam}
5859
rootAttrs["total_count"] = dsschema.Int64Attribute{Computed: true}
5960
rootAttrs["page_num"] = dsschema.Int64Attribute{Optional: true}
6061
rootAttrs["items_per_page"] = dsschema.Int64Attribute{Optional: true}

internal/common/conversion/schema_generation_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1111
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1212
"github.com/hashicorp/terraform-plugin-framework/types"
13+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
1314
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
1415
"github.com/stretchr/testify/assert"
1516
)
@@ -568,7 +569,8 @@ func TestPluralDataSourceSchemaFromResource_legacyFields(t *testing.T) {
568569
Description: "desc requiredAttrString",
569570
},
570571
"id": dsschema.StringAttribute{
571-
Computed: true,
572+
Computed: true,
573+
DeprecationMessage: constant.DeprecationParam,
572574
},
573575
"page_num": dsschema.Int64Attribute{
574576
Optional: true,

0 commit comments

Comments
 (0)