summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-08-21 08:13:56 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-08-22 09:20:50 -0700
commitbed28bbb47637fd47107e73fa1225fbcceee8075 (patch)
tree3225b00922742503311f9abf30d744092e3ca16e
parentc29e097ec938641bc2177387dabf28a99ded59b7 (diff)
downloadchef-zero-bed28bbb47637fd47107e73fa1225fbcceee8075.tar.gz
Get adapters working with default facade for ChefFS
-rw-r--r--lib/chef_zero/data_store/v1_to_v2_adapter.rb35
-rw-r--r--lib/chef_zero/data_store/v2_to_v1_adapter.rb2
2 files changed, 25 insertions, 12 deletions
diff --git a/lib/chef_zero/data_store/v1_to_v2_adapter.rb b/lib/chef_zero/data_store/v1_to_v2_adapter.rb
index e081fd1..cb7e122 100644
--- a/lib/chef_zero/data_store/v1_to_v2_adapter.rb
+++ b/lib/chef_zero/data_store/v1_to_v2_adapter.rb
@@ -19,8 +19,12 @@ module ChefZero
def create_dir(path, name, *options)
return nil if skip_organizations?(path, name)
- fix_exceptions do
- real_store.create_dir(path[2..-1], name, *options)
+ if path.size <= 1
+ raise DataAlreadyExistsError.new(path + [ name ]) if !options[:recursive]
+ else
+ fix_exceptions do
+ real_store.create_dir(path[2..-1], name, *options)
+ end
end
end
@@ -61,22 +65,34 @@ module ChefZero
def list(path)
return nil if skip_organizations?(path)
- fix_exceptions do
- real_store.list(path[2..-1])
+ if path == []
+ [ 'organizations' ]
+ elsif path == [ 'organizations' ]
+ [ single_org ]
+ else
+ fix_exceptions do
+ real_store.list(path[2..-1])
+ end
end
end
def exists?(path)
- return nil if skip_organizations?(path)
+ return false if skip_organizations?(path)
fix_exceptions do
real_store.exists?(path[2..-1])
end
end
def exists_dir?(path)
- return nil if skip_organizations?(path)
- fix_exceptions do
- real_store.exists_dir?(path[2..-1])
+ return false if skip_organizations?(path)
+ if path == []
+ [ 'organizations' ]
+ elsif path == [ 'organizations' ]
+ [ single_org ]
+ else
+ fix_exceptions do
+ real_store.exists_dir?(path[2..-1])
+ end
end
end
@@ -101,9 +117,6 @@ module ChefZero
true
else
raise "Path #{path} must start with /organizations/#{single_org}" if path[0..1] != [ 'organizations', single_org ]
- if !name
- raise "Path #{path} must start with /organizations/#{single_org}/<something>" if path.size <= 2
- end
false
end
end
diff --git a/lib/chef_zero/data_store/v2_to_v1_adapter.rb b/lib/chef_zero/data_store/v2_to_v1_adapter.rb
index 6bc72c0..d663657 100644
--- a/lib/chef_zero/data_store/v2_to_v1_adapter.rb
+++ b/lib/chef_zero/data_store/v2_to_v1_adapter.rb
@@ -30,7 +30,7 @@ module ChefZero
def clear
real_store.clear
- real_store.create_dir([ 'organizations' ], single_org)
+ real_store.create_dir([ 'organizations' ], single_org, :recursive)
end
def create_dir(path, name, *options)