mirror of
https://github.com/hashicorp/terraform.git
synced 2026-02-03 20:50:59 -05:00
refactor deprecation diag creation
This commit is contained in:
parent
3fd7a5052f
commit
5ed7d5134e
1 changed files with 16 additions and 12 deletions
|
|
@ -65,22 +65,26 @@ func (d *Deprecations) deprecationMarksToDiagnostics(deprecationMarks []marks.De
|
|||
}
|
||||
|
||||
for _, depMark := range deprecationMarks {
|
||||
diag := &hcl.Diagnostic{
|
||||
Severity: hcl.DiagWarning,
|
||||
Summary: "Deprecated value used",
|
||||
Detail: depMark.Message,
|
||||
Subject: rng,
|
||||
}
|
||||
if depMark.OriginDescription != "" {
|
||||
diag.Extra = &tfdiags.DeprecationOriginDiagnosticExtra{
|
||||
OriginDescription: depMark.OriginDescription,
|
||||
}
|
||||
}
|
||||
diags = diags.Append(diag)
|
||||
diags = diags.Append(deprecationMarkToDiagnostic(depMark, rng))
|
||||
}
|
||||
return diags
|
||||
}
|
||||
|
||||
func deprecationMarkToDiagnostic(depMark marks.DeprecationMark, subject *hcl.Range) *hcl.Diagnostic {
|
||||
diag := &hcl.Diagnostic{
|
||||
Severity: hcl.DiagWarning,
|
||||
Summary: "Deprecated value used",
|
||||
Detail: depMark.Message,
|
||||
Subject: subject,
|
||||
}
|
||||
if depMark.OriginDescription != "" {
|
||||
diag.Extra = &tfdiags.DeprecationOriginDiagnosticExtra{
|
||||
OriginDescription: depMark.OriginDescription,
|
||||
}
|
||||
}
|
||||
return diag
|
||||
}
|
||||
|
||||
// ValidateAsConfig checks the given value for deprecation marks and returns diagnostics
|
||||
// for each deprecation found, unless deprecation warnings are suppressed for the given module.
|
||||
// It checks for deeply nested deprecation marks as well.
|
||||
|
|
|
|||
Loading…
Reference in a new issue