mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
update the lint subrequest call to error when a build error was encountered during linting
Signed-off-by: Talon Bowler <talon.bowler@docker.com> (cherry picked from commit 927fb6731c2c53da85627a5c9acd93d5439fdb5e)
This commit is contained in:
parent
2375e88b06
commit
fe728e7780
@ -866,7 +866,28 @@ func printResult(f *controllerapi.PrintFunc, res map[string]string) error {
|
|||||||
case "subrequests.describe":
|
case "subrequests.describe":
|
||||||
return printValue(subrequests.PrintDescribe, subrequests.SubrequestsDescribeDefinition.Version, f.Format, res)
|
return printValue(subrequests.PrintDescribe, subrequests.SubrequestsDescribeDefinition.Version, f.Format, res)
|
||||||
case "lint":
|
case "lint":
|
||||||
return printValue(lint.PrintLintViolations, lint.SubrequestLintDefinition.Version, f.Format, res)
|
err := printValue(lint.PrintLintViolations, lint.SubrequestLintDefinition.Version, f.Format, res)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
lintResults := lint.LintResults{}
|
||||||
|
if result, ok := res["result.json"]; ok {
|
||||||
|
if err := json.Unmarshal([]byte(result), &lintResults); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if lintResults.Error != nil {
|
||||||
|
fmt.Println()
|
||||||
|
lintBuf := bytes.NewBuffer([]byte(lintResults.Error.Message + "\n"))
|
||||||
|
sourceInfo := lintResults.Sources[lintResults.Error.Location.SourceIndex]
|
||||||
|
source := errdefs.Source{
|
||||||
|
Info: sourceInfo,
|
||||||
|
Ranges: lintResults.Error.Location.Ranges,
|
||||||
|
}
|
||||||
|
source.Print(lintBuf)
|
||||||
|
return errors.New(lintBuf.String())
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if dt, ok := res["result.json"]; ok && f.Format == "json" {
|
if dt, ok := res["result.json"]; ok && f.Format == "json" {
|
||||||
fmt.Println(dt)
|
fmt.Println(dt)
|
||||||
|
@ -821,7 +821,7 @@ COPy --from=base \
|
|||||||
stderr := bytes.Buffer{}
|
stderr := bytes.Buffer{}
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
require.NoError(t, cmd.Run(), stdout.String(), stderr.String())
|
require.Error(t, cmd.Run(), stdout.String(), stderr.String())
|
||||||
|
|
||||||
var res lint.LintResults
|
var res lint.LintResults
|
||||||
require.NoError(t, json.Unmarshal(stdout.Bytes(), &res))
|
require.NoError(t, json.Unmarshal(stdout.Bytes(), &res))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user