Skip to content

Commit bda61b0

Browse files
improve wording of deprecation marks
1 parent c98606e commit bda61b0

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

internal/deprecation/schema.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func MarkDeprecatedValues(val cty.Value, schema *configschema.Block, origin stri
2323

2424
// Check if the block is deprecated
2525
if schema.Deprecated {
26-
newVal = newVal.Mark(marks.NewDeprecation("deprecated resource block used", origin))
26+
newVal = newVal.Mark(marks.NewDeprecation("Deprecated resource used as value", origin))
2727
}
2828

2929
if !newVal.IsKnown() {
@@ -38,12 +38,12 @@ func MarkDeprecatedValues(val cty.Value, schema *configschema.Block, origin stri
3838

3939
attr := schema.AttributeByPath(p)
4040
if attr != nil && attr.Deprecated {
41-
v = v.Mark(marks.NewDeprecation("deprecated resource attribute used", fmt.Sprintf("%s.%s", origin, p)))
41+
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource attribute %q used", p), fmt.Sprintf("%s.%s", origin, p)))
4242
}
4343

4444
block := schema.BlockByPath(p)
4545
if block != nil && block.Deprecated {
46-
v = v.Mark(marks.NewDeprecation("deprecated resource block used", fmt.Sprintf("%s.%s", origin, p)))
46+
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource block %q used", p), fmt.Sprintf("%s.%s", origin, p)))
4747
}
4848

4949
return v, nil

internal/terraform/context_validate_test.go

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,7 +2485,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
24852485
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
24862486
Severity: hcl.DiagWarning,
24872487
Summary: `Deprecated value used`,
2488-
Detail: `deprecated resource attribute used`,
2488+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
24892489
Subject: &hcl.Range{
24902490
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
24912491
Start: hcl.Pos{Line: 5, Column: 28, Byte: 108},
@@ -2514,7 +2514,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
25142514
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
25152515
Severity: hcl.DiagWarning,
25162516
Summary: `Deprecated value used`,
2517-
Detail: `deprecated resource attribute used`,
2517+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
25182518
Subject: &hcl.Range{
25192519
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
25202520
Start: hcl.Pos{Line: 6, Column: 23, Byte: 152},
@@ -2543,7 +2543,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
25432543
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
25442544
Severity: hcl.DiagWarning,
25452545
Summary: `Deprecated value used`,
2546-
Detail: `deprecated resource attribute used`,
2546+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
25472547
Subject: &hcl.Range{
25482548
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
25492549
Start: hcl.Pos{Line: 6, Column: 26, Byte: 164},
@@ -2570,7 +2570,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
25702570
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
25712571
Severity: hcl.DiagWarning,
25722572
Summary: `Deprecated value used`,
2573-
Detail: `deprecated resource attribute used`,
2573+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
25742574
Subject: &hcl.Range{
25752575
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
25762576
Start: hcl.Pos{Line: 5, Column: 23, Byte: 123},
@@ -2601,7 +2601,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
26012601
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
26022602
Severity: hcl.DiagWarning,
26032603
Summary: `Deprecated value used`,
2604-
Detail: `deprecated resource attribute used`,
2604+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
26052605
Subject: &hcl.Range{
26062606
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
26072607
Start: hcl.Pos{Line: 5, Column: 21, Byte: 126},
@@ -2635,7 +2635,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
26352635
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
26362636
Severity: hcl.DiagWarning,
26372637
Summary: `Deprecated value used`,
2638-
Detail: `deprecated resource attribute used`,
2638+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
26392639
Subject: &hcl.Range{
26402640
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
26412641
Start: hcl.Pos{Line: 9, Column: 31, Byte: 245},
@@ -2666,7 +2666,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
26662666
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
26672667
Severity: hcl.DiagWarning,
26682668
Summary: `Deprecated value used`,
2669-
Detail: `deprecated resource attribute used`,
2669+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
26702670
Subject: &hcl.Range{
26712671
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
26722672
Start: hcl.Pos{Line: 6, Column: 31, Byte: 160},
@@ -2713,7 +2713,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
27132713
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
27142714
Severity: hcl.DiagWarning,
27152715
Summary: `Deprecated value used`,
2716-
Detail: `deprecated resource attribute used`,
2716+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
27172717
Subject: &hcl.Range{
27182718
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
27192719
Start: hcl.Pos{Line: 5, Column: 45, Byte: 135},
@@ -2722,7 +2722,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
27222722
}).Append(&hcl.Diagnostic{
27232723
Severity: hcl.DiagWarning,
27242724
Summary: `Deprecated value used`,
2725-
Detail: `deprecated resource attribute used`,
2725+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
27262726
Subject: &hcl.Range{
27272727
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
27282728
Start: hcl.Pos{Line: 5, Column: 45, Byte: 135},
@@ -2753,7 +2753,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
27532753
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
27542754
Severity: hcl.DiagWarning,
27552755
Summary: `Deprecated value used`,
2756-
Detail: `deprecated resource attribute used`,
2756+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
27572757
Subject: &hcl.Range{
27582758
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
27592759
Start: hcl.Pos{Line: 7, Column: 29, Byte: 170},
@@ -2786,7 +2786,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
27862786
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
27872787
Severity: hcl.DiagWarning,
27882788
Summary: `Deprecated value used`,
2789-
Detail: `deprecated resource attribute used`,
2789+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
27902790
Subject: &hcl.Range{
27912791
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
27922792
Start: hcl.Pos{Line: 6, Column: 23, Byte: 144},
@@ -2819,7 +2819,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
28192819
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
28202820
Severity: hcl.DiagWarning,
28212821
Summary: `Deprecated value used`,
2822-
Detail: `deprecated resource attribute used`,
2822+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
28232823
Subject: &hcl.Range{
28242824
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
28252825
Start: hcl.Pos{Line: 6, Column: 36, Byte: 177},
@@ -2828,7 +2828,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
28282828
}).Append(&hcl.Diagnostic{
28292829
Severity: hcl.DiagWarning,
28302830
Summary: `Deprecated value used`,
2831-
Detail: `deprecated resource attribute used`,
2831+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
28322832
Subject: &hcl.Range{
28332833
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
28342834
Start: hcl.Pos{Line: 9, Column: 26, Byte: 284},
@@ -2843,7 +2843,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
28432843
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
28442844
Severity: hcl.DiagWarning,
28452845
Summary: `Deprecated value used`,
2846-
Detail: `deprecated resource attribute used`,
2846+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
28472847
Subject: &hcl.Range{
28482848
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
28492849
Start: hcl.Pos{Line: 6, Column: 36, Byte: 177},
@@ -2852,7 +2852,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
28522852
}).Append(&hcl.Diagnostic{
28532853
Severity: hcl.DiagWarning,
28542854
Summary: `Deprecated value used`,
2855-
Detail: `deprecated resource attribute used`,
2855+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
28562856
Subject: &hcl.Range{
28572857
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
28582858
Start: hcl.Pos{Line: 9, Column: 26, Byte: 284},
@@ -2881,7 +2881,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
28812881
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
28822882
Severity: hcl.DiagWarning,
28832883
Summary: `Deprecated value used`,
2884-
Detail: `deprecated resource attribute used`,
2884+
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
28852885
Subject: &hcl.Range{
28862886
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
28872887
Start: hcl.Pos{Line: 6, Column: 24, Byte: 152},
@@ -2989,22 +2989,13 @@ output "a" {
29892989
})
29902990
diags := ctx.Validate(m, &ValidateOpts{})
29912991
tfdiags.AssertDiagnosticsMatch(t, diags, tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
2992-
Severity: hcl.DiagWarning,
2993-
Summary: `Usage of deprecated resource "test_resource"`,
2994-
Detail: `The resource "test_resource" has been marked as deprecated by its provider. Please check the provider documentation for more information.`,
2995-
Subject: &hcl.Range{
2996-
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
2997-
Start: hcl.Pos{Line: 2, Column: 1, Byte: 1},
2998-
End: hcl.Pos{Line: 2, Column: 32, Byte: 32},
2999-
},
3000-
}).Append(&hcl.Diagnostic{
30012992
Severity: hcl.DiagWarning,
30022993
Summary: "Deprecated value used",
3003-
Detail: `Resource "test_resource" is deprecated`,
2994+
Detail: `Deprecated resource used as value`,
30042995
Subject: &hcl.Range{
30052996
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
3006-
Start: hcl.Pos{Line: 7, Column: 13, Byte: 92},
3007-
End: hcl.Pos{Line: 7, Column: 36, Byte: 115},
2997+
Start: hcl.Pos{Line: 6, Column: 13, Byte: 91},
2998+
End: hcl.Pos{Line: 6, Column: 36, Byte: 114},
30082999
},
30093000
}))
30103001
}

0 commit comments

Comments
 (0)