(notaryRepo notaryclient.Repository, newSigner data.RoleName)
| 195 | } |
| 196 | |
| 197 | func initNotaryRepoWithSigners(notaryRepo notaryclient.Repository, newSigner data.RoleName) error { |
| 198 | rootKey, err := getOrGenerateNotaryKey(notaryRepo, data.CanonicalRootRole) |
| 199 | if err != nil { |
| 200 | return err |
| 201 | } |
| 202 | rootKeyID := rootKey.ID() |
| 203 | |
| 204 | // Initialize the notary repository with a remotely managed snapshot key |
| 205 | if err := notaryRepo.Initialize([]string{rootKeyID}, data.CanonicalSnapshotRole); err != nil { |
| 206 | return err |
| 207 | } |
| 208 | |
| 209 | signerKey, err := getOrGenerateNotaryKey(notaryRepo, newSigner) |
| 210 | if err != nil { |
| 211 | return err |
| 212 | } |
| 213 | if err := addStagedSigner(notaryRepo, newSigner, []data.PublicKey{signerKey}); err != nil { |
| 214 | return fmt.Errorf("could not add signer to repo: %s: %w", strings.TrimPrefix(newSigner.String(), "targets/"), err) |
| 215 | } |
| 216 | |
| 217 | return notaryRepo.Publish() |
| 218 | } |
| 219 | |
| 220 | // generates an ECDSA key without a GUN for the specified role |
| 221 | func getOrGenerateNotaryKey(notaryRepo notaryclient.Repository, role data.RoleName) (data.PublicKey, error) { |
no test coverage detected
searching dependent graphs…