Propagate any walking errors separately from no-targets-found-errors

Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
Ying Li 2016-05-23 11:53:44 -07:00
parent c4dee70ee9
commit 717ac691ad
1 changed files with 6 additions and 4 deletions

View File

@ -486,11 +486,13 @@ func (r *NotaryRepository) GetAllTargetMetadataByName(name string) ([]*TargetWit
} }
// Check that we didn't error, and that we found the target at least once // Check that we didn't error, and that we found the target at least once
if err := r.tufRepo.WalkTargets(name, "", getAllTargetInfoByNameVisitorFunc); err == nil && len(targetInfo) > 0 { if err := r.tufRepo.WalkTargets(name, "", getAllTargetInfoByNameVisitorFunc); err != nil {
return targetInfo, nil return nil, err
} }
return nil, fmt.Errorf("No trust data for %s", name) if len(targetInfo) == 0 {
return nil, fmt.Errorf("No trust data for %s", name)
}
return targetInfo, nil
} }
// GetChangelist returns the list of the repository's unpublished changes // GetChangelist returns the list of the repository's unpublished changes