(ctx context.Context, dockerCLI command.Cli, remote string)
| 69 | } |
| 70 | |
| 71 | func getRepoTrustInfo(ctx context.Context, dockerCLI command.Cli, remote string) ([]byte, error) { |
| 72 | signatureRows, adminRolesWithSigs, delegationRoles, err := lookupTrustInfo(ctx, dockerCLI, remote) |
| 73 | if err != nil { |
| 74 | return []byte{}, err |
| 75 | } |
| 76 | // process the signatures to include repo admin if signed by the base targets role |
| 77 | for idx, sig := range signatureRows { |
| 78 | if len(sig.Signers) == 0 { |
| 79 | signatureRows[idx].Signers = []string{releasedRoleName} |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | signerList, adminList := []trustSigner{}, []trustSigner{} |
| 84 | |
| 85 | signerRoleToKeyIDs := getDelegationRoleToKeyMap(delegationRoles) |
| 86 | |
| 87 | for signerName, signerKeys := range signerRoleToKeyIDs { |
| 88 | signerKeyList := []trustKey{} |
| 89 | for _, keyID := range signerKeys { |
| 90 | signerKeyList = append(signerKeyList, trustKey{ID: keyID}) |
| 91 | } |
| 92 | signerList = append(signerList, trustSigner{signerName, signerKeyList}) |
| 93 | } |
| 94 | sort.Slice(signerList, func(i, j int) bool { return signerList[i].Name > signerList[j].Name }) |
| 95 | |
| 96 | for _, adminRole := range adminRolesWithSigs { |
| 97 | switch adminRole.Name { |
| 98 | case data.CanonicalRootRole: |
| 99 | rootKeys := []trustKey{} |
| 100 | for _, keyID := range adminRole.KeyIDs { |
| 101 | rootKeys = append(rootKeys, trustKey{ID: keyID}) |
| 102 | } |
| 103 | adminList = append(adminList, trustSigner{"Root", rootKeys}) |
| 104 | case data.CanonicalTargetsRole: |
| 105 | targetKeys := []trustKey{} |
| 106 | for _, keyID := range adminRole.KeyIDs { |
| 107 | targetKeys = append(targetKeys, trustKey{ID: keyID}) |
| 108 | } |
| 109 | adminList = append(adminList, trustSigner{"Repository", targetKeys}) |
| 110 | } |
| 111 | } |
| 112 | sort.Slice(adminList, func(i, j int) bool { return adminList[i].Name > adminList[j].Name }) |
| 113 | |
| 114 | return json.Marshal(trustRepo{ |
| 115 | Name: remote, |
| 116 | SignedTags: signatureRows, |
| 117 | Signers: signerList, |
| 118 | AdministrativeKeys: adminList, |
| 119 | }) |
| 120 | } |
no test coverage detected
searching dependent graphs…