MCPcopy Create free account
hub / github.com/docker/cli / lookupTrustInfo

Function lookupTrustInfo

cmd/docker-trust/trust/common.go:70–110  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
70func 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
112func formatAdminRole(roleWithSigs client.RoleWithSignatures) string {
113 adminKeyList := roleWithSigs.KeyIDs

Callers 2

getRepoTrustInfoFunction · 0.85
prettyPrintTrustInfoFunction · 0.85

Calls 10

authResolverFunction · 0.85
newNotaryClientFunction · 0.85
clearChangeListFunction · 0.85
matchReleasedSignaturesFunction · 0.85
ReferenceMethod · 0.80
TagMethod · 0.45
NameMethod · 0.45
ListRolesMethod · 0.45
GetDelegationRolesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…