mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-08-19 04:17:48 +00:00
Ensure the parent directory for key prefix exists
Currently we are trying to ensure that the parent directory exists as a key. But it is really a directory and etcd expects it to be a directory. So made the change to ensure that the parent key is created as a directory and not as a simple key. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
@@ -385,15 +385,15 @@ func (ds *datastore) GetObject(key string, o KVObject) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ds *datastore) ensureKey(key string) error {
|
||||
exists, err := ds.store.Exists(key)
|
||||
func (ds *datastore) ensureParent(parent string) error {
|
||||
exists, err := ds.store.Exists(parent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
return nil
|
||||
}
|
||||
return ds.store.Put(key, []byte{}, nil)
|
||||
return ds.store.Put(parent, []byte{}, &store.WriteOptions{IsDir: true})
|
||||
}
|
||||
|
||||
func (ds *datastore) List(key string, kvObject KVObject) ([]KVObject, error) {
|
||||
@@ -411,7 +411,7 @@ func (ds *datastore) List(key string, kvObject KVObject) ([]KVObject, error) {
|
||||
}
|
||||
|
||||
// Make sure the parent key exists
|
||||
if err := ds.ensureKey(key); err != nil {
|
||||
if err := ds.ensureParent(key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user