mirror of
https://github.com/clearlinux/rkt.git
synced 2026-09-06 22:01:54 +00:00
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:
+6
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user