@@ -866,7 +866,34 @@ func printResult(f *controllerapi.PrintFunc, res map[string]string) error {
866
866
case "subrequests.describe" :
867
867
return printValue (subrequests .PrintDescribe , subrequests .SubrequestsDescribeDefinition .Version , f .Format , res )
868
868
case "lint" :
869
- return printValue (lint .PrintLintViolations , lint .SubrequestLintDefinition .Version , f .Format , res )
869
+ err := printValue (lint .PrintLintViolations , lint .SubrequestLintDefinition .Version , f .Format , res )
870
+ if err != nil {
871
+ return err
872
+ }
873
+
874
+ lintResults := lint.LintResults {}
875
+ if result , ok := res ["result.json" ]; ok {
876
+ if err := json .Unmarshal ([]byte (result ), & lintResults ); err != nil {
877
+ return err
878
+ }
879
+ }
880
+ if lintResults .Error != nil {
881
+ // Print the error message and the source
882
+ // Normally, we would use `errdefs.WithSource` to attach the source to the
883
+ // error and let the error be printed by the handling that's already in place,
884
+ // but here we want to print the error in a way that's consistent with how
885
+ // the lint warnings are printed via the `lint.PrintLintViolations` function,
886
+ // which differs from the default error printing.
887
+ fmt .Println ()
888
+ lintBuf := bytes .NewBuffer ([]byte (lintResults .Error .Message + "\n " ))
889
+ sourceInfo := lintResults .Sources [lintResults .Error .Location .SourceIndex ]
890
+ source := errdefs.Source {
891
+ Info : sourceInfo ,
892
+ Ranges : lintResults .Error .Location .Ranges ,
893
+ }
894
+ source .Print (lintBuf )
895
+ return errors .New (lintBuf .String ())
896
+ }
870
897
default :
871
898
if dt , ok := res ["result.json" ]; ok && f .Format == "json" {
872
899
fmt .Println (dt )
0 commit comments