MCPcopy
hub / github.com/cli/cli / printVerifiedSubjects

Function printVerifiedSubjects

pkg/cmd/release/verify/verify.go:196–238  ·  view source on GitHub ↗
(io *iostreams.IOStreams, att *verification.AttestationProcessingResult)

Source from the content-addressed store, hash-verified

194}
195
196func printVerifiedSubjects(io *iostreams.IOStreams, att *verification.AttestationProcessingResult) error {
197 cs := io.ColorScheme()
198 w := io.Out
199
200 statement := att.Attestation.Bundle.GetDsseEnvelope().Payload
201 var statementData v1.Statement
202
203 err := protojson.Unmarshal([]byte(statement), &statementData)
204 if err != nil {
205 return err
206 }
207
208 // If there aren't at least two subjects, there are no assets to display
209 if len(statementData.Subject) < 2 {
210 return nil
211 }
212
213 fmt.Fprintln(w, cs.Bold("Assets"))
214 table := tableprinter.New(io, tableprinter.WithHeader("Name", "Digest"))
215
216 for _, s := range statementData.Subject {
217 name := s.Name
218 digest := s.Digest
219
220 if name != "" {
221 digestStr := ""
222 for key, value := range digest {
223 digestStr = key + ":" + value
224 }
225
226 table.AddField(name)
227 table.AddField(digestStr)
228 table.EndRow()
229 }
230 }
231 err = table.Render()
232 if err != nil {
233 return err
234 }
235 fmt.Fprintln(w)
236
237 return nil
238}

Callers 1

verifyRunFunction · 0.85

Calls 5

NewFunction · 0.92
WithHeaderFunction · 0.92
ColorSchemeMethod · 0.80
BoldMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected