2017-08-24 18:43:55 -04:00
|
|
|
package trust
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli/trust"
|
|
|
|
"github.com/docker/notary/client"
|
|
|
|
"github.com/docker/notary/tuf/data"
|
|
|
|
)
|
|
|
|
|
|
|
|
const releasedRoleName = "Repo Admin"
|
|
|
|
|
|
|
|
// check if a role name is "released": either targets/releases or targets TUF roles
|
|
|
|
func isReleasedTarget(role data.RoleName) bool {
|
|
|
|
return role == data.CanonicalTargetsRole || role == trust.ReleasesRole
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert TUF role name to a human-understandable signer name
|
|
|
|
func notaryRoleToSigner(tufRole data.RoleName) string {
|
|
|
|
// don't show a signer for "targets" or "targets/releases"
|
|
|
|
if isReleasedTarget(data.RoleName(tufRole.String())) {
|
|
|
|
return releasedRoleName
|
|
|
|
}
|
|
|
|
return strings.TrimPrefix(tufRole.String(), "targets/")
|
|
|
|
}
|
|
|
|
|
2017-09-11 17:07:00 -04:00
|
|
|
func clearChangeList(notaryRepo client.Repository) error {
|
2017-08-24 18:43:55 -04:00
|
|
|
cl, err := notaryRepo.GetChangelist()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-25 17:49:40 -04:00
|
|
|
return cl.Clear("")
|
2017-08-24 18:43:55 -04:00
|
|
|
}
|