improve wording of deprecation marks
Some checks failed
Quick Checks / Unit Tests (push) Has been cancelled
Quick Checks / Race Tests (push) Has been cancelled
Quick Checks / End-to-end Tests (push) Has been cancelled
Quick Checks / Code Consistency Checks (push) Has been cancelled

This commit is contained in:
Daniel Schmidt 2026-01-21 17:20:58 +01:00
parent 7e6b3dc2b7
commit 1ae68b1008
No known key found for this signature in database
GPG key ID: 377C3A4D62FBBBE2
2 changed files with 22 additions and 31 deletions

View file

@ -23,7 +23,7 @@ func MarkDeprecatedValues(val cty.Value, schema *configschema.Block, origin stri
// Check if the block is deprecated
if schema.Deprecated {
newVal = newVal.Mark(marks.NewDeprecation("deprecated resource block used", origin))
newVal = newVal.Mark(marks.NewDeprecation("Deprecated resource used as value", origin))
}
if !newVal.IsKnown() {
@ -38,12 +38,12 @@ func MarkDeprecatedValues(val cty.Value, schema *configschema.Block, origin stri
attr := schema.AttributeByPath(p)
if attr != nil && attr.Deprecated {
v = v.Mark(marks.NewDeprecation("deprecated resource attribute used", fmt.Sprintf("%s.%s", origin, p)))
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource attribute %q used", p), fmt.Sprintf("%s.%s", origin, p)))
}
block := schema.BlockByPath(p)
if block != nil && block.Deprecated {
v = v.Mark(marks.NewDeprecation("deprecated resource block used", fmt.Sprintf("%s.%s", origin, p)))
v = v.Mark(marks.NewDeprecation(fmt.Sprintf("Deprecated resource block %q used", p), fmt.Sprintf("%s.%s", origin, p)))
}
return v, nil

View file

@ -2485,7 +2485,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 5, Column: 28, Byte: 108},
@ -2514,7 +2514,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 23, Byte: 152},
@ -2543,7 +2543,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 26, Byte: 164},
@ -2570,7 +2570,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 5, Column: 23, Byte: 123},
@ -2601,7 +2601,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 5, Column: 21, Byte: 126},
@ -2635,7 +2635,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 9, Column: 31, Byte: 245},
@ -2666,7 +2666,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 31, Byte: 160},
@ -2713,7 +2713,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 5, Column: 45, Byte: 135},
@ -2722,7 +2722,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
}).Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 5, Column: 45, Byte: 135},
@ -2753,7 +2753,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 7, Column: 29, Byte: 170},
@ -2786,7 +2786,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 23, Byte: 144},
@ -2819,7 +2819,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 36, Byte: 177},
@ -2828,7 +2828,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
}).Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 9, Column: 26, Byte: 284},
@ -2843,7 +2843,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 36, Byte: 177},
@ -2852,7 +2852,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
}).Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 9, Column: 26, Byte: 284},
@ -2881,7 +2881,7 @@ func TestContext2Validate_deprecatedAttr(t *testing.T) {
return tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Deprecated value used`,
Detail: `deprecated resource attribute used`,
Detail: `Deprecated resource attribute [{{} "foo"}] used`,
Subject: &hcl.Range{
Filename: filepath.Join(c.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 6, Column: 24, Byte: 152},
@ -2989,22 +2989,13 @@ output "a" {
})
diags := ctx.Validate(m, &ValidateOpts{})
tfdiags.AssertDiagnosticsMatch(t, diags, tfdiags.Diagnostics{}.Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: `Usage of deprecated resource "test_resource"`,
Detail: `The resource "test_resource" has been marked as deprecated by its provider. Please check the provider documentation for more information.`,
Subject: &hcl.Range{
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 2, Column: 1, Byte: 1},
End: hcl.Pos{Line: 2, Column: 32, Byte: 32},
},
}).Append(&hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: "Deprecated value used",
Detail: `Resource "test_resource" is deprecated`,
Detail: `Deprecated resource used as value`,
Subject: &hcl.Range{
Filename: filepath.Join(m.Module.SourceDir, "main.tf"),
Start: hcl.Pos{Line: 7, Column: 13, Byte: 92},
End: hcl.Pos{Line: 7, Column: 36, Byte: 115},
Start: hcl.Pos{Line: 6, Column: 13, Byte: 91},
End: hcl.Pos{Line: 6, Column: 36, Byte: 114},
},
}))
}