Skip to content

Commit

Permalink
dockerfile: add statuscode to lint result
Browse files Browse the repository at this point in the history
This can be used by client as indicator if command
is considered to be successful or not.

Using this, --print=lint can be made to exit program
with error code as is expected for CI-style validation.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Apr 13, 2024
1 parent 723a4d5 commit 4d61f08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontend/subrequests/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var SubrequestLintDefinition = subrequests.Request{
Metadata: []subrequests.Named{
{Name: "result.json"},
{Name: "result.txt"},
{Name: "result.statuscode"},
},
}

Expand Down Expand Up @@ -113,6 +114,12 @@ func (results *LintResults) ToResult() (*client.Result, error) {
}
res.AddMeta("result.txt", b.Bytes())

status := 0
if len(results.Warnings) > 0 {
status = 1
}
res.AddMeta("result.statuscode", []byte(fmt.Sprintf("%d", status)))

res.AddMeta("version", []byte(SubrequestLintDefinition.Version))
return res, nil
}
Expand Down

0 comments on commit 4d61f08

Please sign in to comment.