WriteReport returns a new instance of Report representing the state of the filepaths provided.
(inputs []Input, policy policy.Policy, policyInput [][]byte, showSuccesses bool, showWarnings bool, showPolicyDocsLink bool)
| 99 | // WriteReport returns a new instance of Report representing the state of |
| 100 | // the filepaths provided. |
| 101 | func NewReport(inputs []Input, policy policy.Policy, policyInput [][]byte, showSuccesses bool, showWarnings bool, showPolicyDocsLink bool) (Report, error) { |
| 102 | success := true |
| 103 | |
| 104 | // Set the report success, remains true if all the files were successfully validated |
| 105 | for _, fpath := range inputs { |
| 106 | if !fpath.Success { |
| 107 | success = false |
| 108 | break |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | info, _ := version.ComputeInfo() |
| 113 | |
| 114 | return Report{ |
| 115 | Success: success, |
| 116 | created: time.Now().UTC(), |
| 117 | FilePaths: inputs, |
| 118 | Policy: policy.Spec(), |
| 119 | EcVersion: info.Version, |
| 120 | EffectiveTime: policy.EffectiveTime().UTC(), |
| 121 | PolicyInput: policyInput, |
| 122 | ShowSuccesses: showSuccesses, |
| 123 | ShowWarnings: showWarnings, |
| 124 | ShowPolicyDocsLink: showPolicyDocsLink, |
| 125 | }, nil |
| 126 | } |
| 127 | |
| 128 | // WriteAll writes the report to all the given targets. |
| 129 | func (r Report) WriteAll(targets []string, p format.TargetParser) (allErrors error) { |