diff options
-rw-r--r-- | lib/chef_zero/data_store/v1_to_v2_adapter.rb | 35 | ||||
-rw-r--r-- | lib/chef_zero/data_store/v2_to_v1_adapter.rb | 2 |
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) |