Skip to content

Commit

Permalink
Include LintMetadata in the LintResult (#729)
Browse files Browse the repository at this point in the history
* Include LintMetadata in the LintResult

* Don't include LintMetadata in LintResult's JSON output
  • Loading branch information
aaomidi committed Aug 1, 2023
1 parent 38b7484 commit 624744d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions v3/lint/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ var (
// LintResult contains a LintStatus, and an optional human-readable description.
// The output of a lint is a LintResult.
type LintResult struct {
Status LintStatus `json:"result"`
Details string `json:"details,omitempty"`
Status LintStatus `json:"result"`
Details string `json:"details,omitempty"`
LintMetadata LintMetadata `json:"-"`
}

// MarshalJSON implements the json.Marshaler interface.
Expand Down
2 changes: 2 additions & 0 deletions v3/resultset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (z *ResultSet) executeCertificate(o *x509.Certificate, registry lint.Regist
// Run each lint from the registry.
for _, lint := range registry.CertificateLints().Lints() {
res := lint.Execute(o, registry.GetConfiguration())
res.LintMetadata = lint.LintMetadata
z.Results[lint.Name] = res
z.updateErrorStatePresent(res)
}
Expand All @@ -52,6 +53,7 @@ func (z *ResultSet) executeRevocationList(o *x509.RevocationList, registry lint.
// Run each lints from the registry.
for _, lint := range registry.RevocationListLints().Lints() {
res := lint.Execute(o, registry.GetConfiguration())
res.LintMetadata = lint.LintMetadata
z.Results[lint.Name] = res
z.updateErrorStatePresent(res)
}
Expand Down
3 changes: 3 additions & 0 deletions v3/zlint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,7 @@ anything = "at all"
if result.Status != lint.Pass {
t.Fatalf("expected lint to pass, got %v (%s)", result.Status, result.Details)
}
if result.LintMetadata.Name == "" {
t.Fatal("expected lint metadata to have a name, got empty")
}
}

0 comments on commit 624744d

Please sign in to comment.