trust: define new commands and helpers

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
Riyaz Faizullabhoy
2017-09-26 11:33:54 -07:00
parent f47b1a3c6d
commit 5ab3ae7aba
3 changed files with 21 additions and 4 deletions

View File

@ -18,6 +18,10 @@ func NewTrustCommand(dockerCli command.Cli) *cobra.Command {
newViewCommand(dockerCli),
newRevokeCommand(dockerCli),
newSignCommand(dockerCli),
newKeyGenerateCommand(dockerCli),
newKeyLoadCommand(dockerCli),
newSignerAddCommand(dockerCli),
newSignerRemoveCommand(dockerCli),
)
return cmd
}

View File

@ -9,6 +9,7 @@ import (
)
const releasedRoleName = "Repo Admin"
const releasesRoleTUFName = "targets/releases"
// check if a role name is "released": either targets/releases or targets TUF roles
func isReleasedTarget(role data.RoleName) bool {
@ -31,3 +32,13 @@ func clearChangeList(notaryRepo client.Repository) error {
}
return cl.Clear("")
}
func getOrGenerateRootKeyAndInitRepo(notaryRepo client.Repository) error {
rootKey, err := getOrGenerateNotaryKey(notaryRepo, data.CanonicalRootRole)
if err != nil {
return err
}
// Initialize the notary repository with a remotely managed snapshot
// key
return notaryRepo.Initialize([]string{rootKey.ID()}, data.CanonicalSnapshotRole)
}