store: define specific error for key not found.

It's needed when you want to know if the key exists.
This commit is contained in:
Simone Gotti
2015-04-30 11:53:13 +02:00
parent 5020a97807
commit c1e9a85008
+6 -1
View File
@@ -20,6 +20,7 @@ import (
"crypto/sha512"
"database/sql"
"encoding/json"
"errors"
"fmt"
"hash"
"io"
@@ -59,6 +60,10 @@ var diskvStores = [...]string{
"imageManifest",
}
var (
ErrKeyNotFound = errors.New("no keys found")
)
// Store encapsulates a content-addressable-storage for storing ACIs on disk.
type Store struct {
base string
@@ -220,7 +225,7 @@ func (s Store) ResolveKey(key string) (string, error) {
keyCount := len(aciInfos)
if keyCount == 0 {
return "", fmt.Errorf("no keys found")
return "", ErrKeyNotFound
}
if keyCount != 1 {
return "", fmt.Errorf("ambiguous key: %q", key)