-
Notifications
You must be signed in to change notification settings - Fork 34
/
warning_diagnostic.go
46 lines (36 loc) · 1.08 KB
/
warning_diagnostic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package diag
var _ Diagnostic = WarningDiagnostic{}
// WarningDiagnostic is a generic diagnostic with warning severity.
type WarningDiagnostic struct {
detail string
summary string
}
// NewWarningDiagnostic returns a new warning severity diagnostic with the given summary and detail.
func NewWarningDiagnostic(summary string, detail string) WarningDiagnostic {
return WarningDiagnostic{
detail: detail,
summary: summary,
}
}
// Severity returns the diagnostic severity.
func (d WarningDiagnostic) Severity() Severity {
return SeverityWarning
}
// Summary returns the diagnostic summary.
func (d WarningDiagnostic) Summary() string {
return d.summary
}
// Detail returns the diagnostic detail.
func (d WarningDiagnostic) Detail() string {
return d.detail
}
// Equal returns true if the other diagnostic is wholly equivalent.
func (d WarningDiagnostic) Equal(other Diagnostic) bool {
wd, ok := other.(WarningDiagnostic)
if !ok {
return false
}
return wd.Summary() == d.Summary() && wd.Detail() == d.Detail()
}