mirror of https://github.com/docker/docs.git
Simplify the logic to determine whether to publish the root
Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
642cf7f353
commit
d0e789740a
|
|
@ -353,11 +353,9 @@ func (r *NotaryRepository) Publish() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// We had local data but the server doesn't know about the repo yet,
|
// We had local data but the server doesn't know about the repo yet,
|
||||||
// ensure we will push the initial root file
|
// ensure we will push the initial root file. The root may not
|
||||||
root, err = r.tufRepo.Root.ToSigned()
|
// be marked as Dirty, since there may not be any changes that
|
||||||
if err != nil {
|
// update it, so use a different boolean.
|
||||||
return err
|
|
||||||
}
|
|
||||||
updateRoot = true
|
updateRoot = true
|
||||||
} else {
|
} else {
|
||||||
// The remote store returned an error other than 404. We're
|
// The remote store returned an error other than 404. We're
|
||||||
|
|
@ -393,12 +391,9 @@ func (r *NotaryRepository) Publish() error {
|
||||||
update := make(map[string][]byte)
|
update := make(map[string][]byte)
|
||||||
|
|
||||||
// check if our root file is nearing expiry. Resign if it is.
|
// check if our root file is nearing expiry. Resign if it is.
|
||||||
if nearExpiry(r.tufRepo.Root) || r.tufRepo.Root.Dirty {
|
if nearExpiry(r.tufRepo.Root) || r.tufRepo.Root.Dirty || updateRoot {
|
||||||
root, err = r.tufRepo.SignRoot(data.DefaultExpires("root"))
|
root, err = r.tufRepo.SignRoot(data.DefaultExpires("root"))
|
||||||
updateRoot = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if updateRoot {
|
|
||||||
rootJSON, err := json.Marshal(root)
|
rootJSON, err := json.Marshal(root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue