Skip to content

Commit ed8d66c

Browse files
authored
feat: add deprecation messages for attributes and blocks in configschema (#1276)
* feat: add deprecation messages for attributes and blocks in configschema * add changie entry
1 parent 60c74cf commit ed8d66c

15 files changed

+102
-72
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: FEATURES
2+
body: 'framework: Add support for deprecation messages on attributes and blocks in the configuration schema'
3+
time: 2026-02-16T14:40:29.58453+01:00
4+
custom:
5+
Issue: "1276"

internal/toproto5/block.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import (
1818
func Block(ctx context.Context, name string, path *tftypes.AttributePath, b fwschema.Block) (*tfprotov5.SchemaNestedBlock, error) {
1919
schemaNestedBlock := &tfprotov5.SchemaNestedBlock{
2020
Block: &tfprotov5.SchemaBlock{
21-
Deprecated: b.GetDeprecationMessage() != "",
21+
Deprecated: b.GetDeprecationMessage() != "",
22+
DeprecationMessage: b.GetDeprecationMessage(),
2223
},
2324
TypeName: name,
2425
}

internal/toproto5/block_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ func TestBlock(t *testing.T) {
448448
Type: tftypes.String,
449449
},
450450
},
451-
Deprecated: true,
451+
Deprecated: true,
452+
DeprecationMessage: "deprecated, use something else instead",
452453
},
453454
Nesting: tfprotov5.SchemaNestedBlockNestingModeList,
454455
TypeName: "test",

internal/toproto5/getproviderschema_test.go

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ func TestGetProviderSchemaResponse(t *testing.T) {
8282
Block: &tfprotov5.SchemaBlock{
8383
Attributes: []*tfprotov5.SchemaAttribute{
8484
{
85-
Name: "test_attribute",
86-
Type: tftypes.String,
87-
Optional: true,
88-
Deprecated: true,
85+
Name: "test_attribute",
86+
Type: tftypes.String,
87+
Optional: true,
88+
Deprecated: true,
89+
DeprecationMessage: "deprecated",
8990
},
9091
},
9192
},
@@ -238,10 +239,11 @@ func TestGetProviderSchemaResponse(t *testing.T) {
238239
Block: &tfprotov5.SchemaBlock{
239240
Attributes: []*tfprotov5.SchemaAttribute{
240241
{
241-
Deprecated: true,
242-
Name: "test_attribute",
243-
Optional: true,
244-
Type: tftypes.Bool,
242+
Deprecated: true,
243+
DeprecationMessage: "deprecated",
244+
Name: "test_attribute",
245+
Optional: true,
246+
Type: tftypes.Bool,
245247
},
246248
},
247249
},
@@ -1393,10 +1395,11 @@ func TestGetProviderSchemaResponse(t *testing.T) {
13931395
Block: &tfprotov5.SchemaBlock{
13941396
Attributes: []*tfprotov5.SchemaAttribute{
13951397
{
1396-
Deprecated: true,
1397-
Name: "test_attribute",
1398-
Optional: true,
1399-
Type: tftypes.Bool,
1398+
Deprecated: true,
1399+
DeprecationMessage: "deprecated",
1400+
Name: "test_attribute",
1401+
Optional: true,
1402+
Type: tftypes.Bool,
14001403
},
14011404
},
14021405
},
@@ -2718,10 +2721,11 @@ func TestGetProviderSchemaResponse(t *testing.T) {
27182721
Block: &tfprotov5.SchemaBlock{
27192722
Attributes: []*tfprotov5.SchemaAttribute{
27202723
{
2721-
Deprecated: true,
2722-
Name: "test_attribute",
2723-
Optional: true,
2724-
Type: tftypes.String,
2724+
Deprecated: true,
2725+
DeprecationMessage: "deprecated",
2726+
Name: "test_attribute",
2727+
Optional: true,
2728+
Type: tftypes.String,
27252729
},
27262730
},
27272731
},
@@ -2850,10 +2854,11 @@ func TestGetProviderSchemaResponse(t *testing.T) {
28502854
Block: &tfprotov5.SchemaBlock{
28512855
Attributes: []*tfprotov5.SchemaAttribute{
28522856
{
2853-
Deprecated: true,
2854-
Name: "test_attribute",
2855-
Optional: true,
2856-
Type: tftypes.Bool,
2857+
Deprecated: true,
2858+
DeprecationMessage: "deprecated",
2859+
Name: "test_attribute",
2860+
Optional: true,
2861+
Type: tftypes.Bool,
28572862
},
28582863
},
28592864
},
@@ -4516,10 +4521,11 @@ func TestGetProviderSchemaResponse(t *testing.T) {
45164521
Block: &tfprotov5.SchemaBlock{
45174522
Attributes: []*tfprotov5.SchemaAttribute{
45184523
{
4519-
Deprecated: true,
4520-
Name: "test_attribute",
4521-
Optional: true,
4522-
Type: tftypes.Bool,
4524+
Deprecated: true,
4525+
DeprecationMessage: "deprecated",
4526+
Name: "test_attribute",
4527+
Optional: true,
4528+
Type: tftypes.Bool,
45234529
},
45244530
},
45254531
},

internal/toproto5/schema.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ func Schema(ctx context.Context, s fwschema.Schema) (*tfprotov5.Schema, error) {
7272
result.Block = &tfprotov5.SchemaBlock{
7373
// core doesn't do anything with version, as far as I can tell,
7474
// so let's not set it.
75-
Attributes: attrs,
76-
BlockTypes: blocks,
77-
Deprecated: s.GetDeprecationMessage() != "",
75+
Attributes: attrs,
76+
BlockTypes: blocks,
77+
Deprecated: s.GetDeprecationMessage() != "",
78+
DeprecationMessage: s.GetDeprecationMessage(),
7879
}
7980

8081
if s.GetDescription() != "" {

internal/toproto5/schema_attribute.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func SchemaAttribute(ctx context.Context, name string, path *tftypes.AttributePa
4040

4141
if a.GetDeprecationMessage() != "" {
4242
schemaAttribute.Deprecated = true
43+
schemaAttribute.DeprecationMessage = a.GetDeprecationMessage()
4344
}
4445

4546
if a.GetDescription() != "" {

internal/toproto5/schema_attribute_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ func TestSchemaAttribute(t *testing.T) {
3838
},
3939
path: tftypes.NewAttributePath(),
4040
expected: &tfprotov5.SchemaAttribute{
41-
Name: "string",
42-
Type: tftypes.String,
43-
Optional: true,
44-
Deprecated: true,
41+
Name: "string",
42+
Type: tftypes.String,
43+
Optional: true,
44+
Deprecated: true,
45+
DeprecationMessage: "deprecated, use new_string instead",
4546
},
4647
},
4748
"description-plain": {

internal/toproto5/schema_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ func TestSchema(t *testing.T) {
516516
Required: true,
517517
},
518518
},
519-
Deprecated: true,
519+
Deprecated: true,
520+
DeprecationMessage: "deprecated, use other_resource instead",
520521
},
521522
},
522523
},

internal/toproto6/block.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import (
1818
func Block(ctx context.Context, name string, path *tftypes.AttributePath, b fwschema.Block) (*tfprotov6.SchemaNestedBlock, error) {
1919
schemaNestedBlock := &tfprotov6.SchemaNestedBlock{
2020
Block: &tfprotov6.SchemaBlock{
21-
Deprecated: b.GetDeprecationMessage() != "",
21+
Deprecated: b.GetDeprecationMessage() != "",
22+
DeprecationMessage: b.GetDeprecationMessage(),
2223
},
2324
TypeName: name,
2425
}

internal/toproto6/block_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ func TestBlock(t *testing.T) {
448448
Type: tftypes.String,
449449
},
450450
},
451-
Deprecated: true,
451+
Deprecated: true,
452+
DeprecationMessage: "deprecated, use something else instead",
452453
},
453454
Nesting: tfprotov6.SchemaNestedBlockNestingModeList,
454455
TypeName: "test",

0 commit comments

Comments
 (0)