lookupTrustInfo returns processed signature and role information about a notary repository. This information is to be pretty printed or serialized into a machine-readable format.
(ctx context.Context, cli command.Cli, remote string)
| 68 | // lookupTrustInfo returns processed signature and role information about a notary repository. |
| 69 | // This information is to be pretty printed or serialized into a machine-readable format. |
| 70 | func lookupTrustInfo(ctx context.Context, cli command.Cli, remote string) ([]trustTagRow, []client.RoleWithSignatures, []data.Role, error) { |
| 71 | imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, authResolver(cli), remote) |
| 72 | if err != nil { |
| 73 | return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, err |
| 74 | } |
| 75 | tag := imgRefAndAuth.Tag() |
| 76 | notaryRepo, err := newNotaryClient(cli, imgRefAndAuth, trust.ActionsPullOnly) |
| 77 | if err != nil { |
| 78 | return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, trust.NotaryError(imgRefAndAuth.Reference().Name(), err) |
| 79 | } |
| 80 | |
| 81 | if err = clearChangeList(notaryRepo); err != nil { |
| 82 | return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, err |
| 83 | } |
| 84 | defer clearChangeList(notaryRepo) |
| 85 | |
| 86 | // Retrieve all released signatures, match them, and pretty print them |
| 87 | allSignedTargets, err := notaryRepo.GetAllTargetMetadataByName(tag) |
| 88 | if err != nil { |
| 89 | logrus.Debug(trust.NotaryError(remote, err)) |
| 90 | // print an empty table if we don't have signed targets, but have an initialized notary repo |
| 91 | if _, ok := err.(client.ErrNoSuchTarget); !ok { |
| 92 | return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("no signatures or cannot access %s", remote) |
| 93 | } |
| 94 | } |
| 95 | signatureRows := matchReleasedSignatures(allSignedTargets) |
| 96 | |
| 97 | // get the administrative roles |
| 98 | adminRolesWithSigs, err := notaryRepo.ListRoles() |
| 99 | if err != nil { |
| 100 | return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("no signers for %s", remote) |
| 101 | } |
| 102 | |
| 103 | // get delegation roles with the canonical key IDs |
| 104 | delegationRoles, err := notaryRepo.GetDelegationRoles() |
| 105 | if err != nil { |
| 106 | logrus.Debugf("no delegation roles found, or error fetching them for %s: %v", remote, err) |
| 107 | } |
| 108 | |
| 109 | return signatureRows, adminRolesWithSigs, delegationRoles, nil |
| 110 | } |
| 111 | |
| 112 | func formatAdminRole(roleWithSigs client.RoleWithSignatures) string { |
| 113 | adminKeyList := roleWithSigs.KeyIDs |
no test coverage detected
searching dependent graphs…