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

Function appendMaterialRows

app/cli/cmd/attestation_status.go:255–304  ·  view source on GitHub ↗

appendMaterialRows renders a single material as a block of rows. When the material belongs to a choke group, its name is indented under the group header and the per-material "Required" row is omitted (the group header carries the "at least one of" requirement instead).

(mt table.Writer, m action.AttestationStatusMaterial, status *action.AttestationStatusResult, full, grouped bool)

Source from the content-addressed store, hash-verified

253// header and the per-material "Required" row is omitted (the group header
254// carries the "at least one of" requirement instead).
255func appendMaterialRows(mt table.Writer, m action.AttestationStatusMaterial, status *action.AttestationStatusResult, full, grouped bool) {
256 name := m.Name
257 if grouped {
258 name = "↳ " + name
259 }
260 mt.AppendRow(table.Row{"Name", name})
261 mt.AppendRow(table.Row{"Type", m.Type})
262 mt.AppendRow(table.Row{"Set", hBool(m.Set)})
263 if !grouped {
264 mt.AppendRow(table.Row{"Required", hBool(m.Required)})
265 }
266 if m.IsOutput {
267 mt.AppendRow(table.Row{"Is output", "Yes"})
268 }
269 if m.SkipUpload {
270 mt.AppendRow(table.Row{"Skip upload", "Yes"})
271 }
272
273 if full {
274 if m.Value != "" {
275 v := m.Value
276 if m.Tag != "" {
277 v = fmt.Sprintf("%s:%s", v, m.Tag)
278 }
279 mt.AppendRow(table.Row{"Value", wrap.String(v, 100)})
280 }
281
282 if m.Hash != "" {
283 mt.AppendRow(table.Row{"Digest", m.Hash})
284 }
285 }
286
287 if len(m.Annotations) > 0 {
288 mt.AppendRow(table.Row{"Annotations", "------"})
289 for _, a := range m.Annotations {
290 value := a.Value
291 if value == "" {
292 value = NotSet
293 }
294
295 mt.AppendRow(table.Row{"", fmt.Sprintf("%s: %s", a.Name, value)})
296 }
297 }
298
299 evs := status.PolicyEvaluations[m.Name]
300 if len(evs) > 0 {
301 mt.AppendRow(table.Row{"Policies", "------"})
302 policiesTable(evs, mt, flagDebug)
303 }
304}
305
306func hBool(b bool) string {
307 if b {

Callers 1

materialsTableFunction · 0.85

Calls 3

hBoolFunction · 0.85
policiesTableFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected