mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-05 23:28:42 +00:00
56a854fe14
* update github.com/docker/cli * update github.com/docker/distribution * update github.com/docker/docker * update github.com/gin-gonic/gin * update github.com/golang-jwt/jwt/v4 * update github.com/golangci/golangci-lint * update github.com/gorilla/securecookie * update github.com/mattn/go-sqlite3 * update github.com/moby/moby * update github.com/prometheus/client_golang * update github.com/xanzy/go-gitlab
39 lines
609 B
Go
39 lines
609 B
Go
package printers
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"io"
|
|
|
|
"github.com/golangci/golangci-lint/pkg/report"
|
|
"github.com/golangci/golangci-lint/pkg/result"
|
|
)
|
|
|
|
type JSON struct {
|
|
rd *report.Data
|
|
w io.Writer
|
|
}
|
|
|
|
func NewJSON(rd *report.Data, w io.Writer) *JSON {
|
|
return &JSON{
|
|
rd: rd,
|
|
w: w,
|
|
}
|
|
}
|
|
|
|
type JSONResult struct {
|
|
Issues []result.Issue
|
|
Report *report.Data
|
|
}
|
|
|
|
func (p JSON) Print(ctx context.Context, issues []result.Issue) error {
|
|
res := JSONResult{
|
|
Issues: issues,
|
|
Report: p.rd,
|
|
}
|
|
if res.Issues == nil {
|
|
res.Issues = []result.Issue{}
|
|
}
|
|
|
|
return json.NewEncoder(p.w).Encode(res)
|
|
}
|