MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / displayMaterialInfo

Function displayMaterialInfo

app/cli/cmd/attestation_add.go:222–274  ·  view source on GitHub ↗

displayMaterialInfo prints the material information in a table format.

(status *action.AttestationStatusMaterial, policyEvaluations []*action.PolicyEvaluation)

Source from the content-addressed store, hash-verified

220
221// displayMaterialInfo prints the material information in a table format.
222func displayMaterialInfo(status *action.AttestationStatusMaterial, policyEvaluations []*action.PolicyEvaluation) error {
223 if status == nil {
224 return nil
225 }
226
227 mt := output.NewTableWriter()
228
229 mt.AppendRow(table.Row{"Name", status.Name})
230 mt.AppendRow(table.Row{"Type", status.Type})
231 mt.AppendRow(table.Row{"Required", hBool(status.Required)})
232
233 if status.Group != "" {
234 mt.AppendRow(table.Row{"Group", status.Group})
235 mt.AppendRow(table.Row{"Rule", "at least one of the group required"})
236 }
237
238 if status.IsOutput {
239 mt.AppendRow(table.Row{"Is output", "Yes"})
240 }
241
242 if status.Value != "" {
243 v := status.Value
244 if status.Tag != "" {
245 v = fmt.Sprintf("%s:%s", v, status.Tag)
246 }
247 mt.AppendRow(table.Row{"Value", wrap.String(v, 100)})
248 }
249
250 if status.Hash != "" {
251 mt.AppendRow(table.Row{"Digest", status.Hash})
252 }
253
254 if len(status.Annotations) > 0 {
255 mt.AppendRow(table.Row{"Annotations", "------"})
256 for _, a := range status.Annotations {
257 value := a.Value
258 if value == "" {
259 value = NotSet
260 }
261 mt.AppendRow(table.Row{"", fmt.Sprintf("%s: %s", a.Name, value)})
262 }
263 }
264
265 if len(policyEvaluations) > 0 {
266 mt.AppendRow(table.Row{"Policy evaluations", "------"})
267 }
268
269 policiesTable(policyEvaluations, mt, flagDebug)
270 mt.SetStyle(table.StyleLight)
271 mt.Style().Options.SeparateRows = true
272 mt.Render()
273 return nil
274}

Callers 1

newAttestationAddCmdFunction · 0.85

Calls 5

NewTableWriterFunction · 0.92
hBoolFunction · 0.85
policiesTableFunction · 0.85
RenderMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected