diff options
author | John Keiser <jkeiser@opscode.com> | 2014-07-16 11:59:36 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-07-23 19:21:23 -0600 |
commit | 271023e69a05f24f1c5a16256f4a5c00ac1de021 (patch) | |
tree | 58ca62636e78f9d6f0a0b1f3d034312b96ab5597 /lib/chef_zero/data_store | |
parent | 02756799c6c1af37638a640acf48cc4cc301afe4 (diff) | |
download | chef-zero-271023e69a05f24f1c5a16256f4a5c00ac1de021.tar.gz |
Add ACL put
Diffstat (limited to 'lib/chef_zero/data_store')
-rw-r--r-- | lib/chef_zero/data_store/default_facade.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/chef_zero/data_store/default_facade.rb b/lib/chef_zero/data_store/default_facade.rb index c0b5697..0fc385d 100644 --- a/lib/chef_zero/data_store/default_facade.rb +++ b/lib/chef_zero/data_store/default_facade.rb @@ -20,10 +20,30 @@ module ChefZero if value.is_a?(Proc) return value.call(self, path) else + # ACLs are a special case: defaults for them exist as long as the + # underlying object does + if value.nil? && path[2] == 'acls' && target_object_exists?(path) + return '{}' + end return value end end + def target_object_exists?(acl_path) + org_path = acl_path[0..1] + object_part = acl_path[3..-1] + if object_part == [ 'organization' ] + exists_dir?(org_path) + else + path = org_path + object_part + if object_part.size == 2 && %w(cookbooks data).include?(object_part[0]) + exists_dir?(path) + else + exists?(path) + end + end + end + def delete_default(path) value = @defaults for part in path[0..-2] @@ -109,7 +129,7 @@ module ChefZero real_store.set(path, data, *options) rescue DataNotFoundError if default(path) - real_store.create(path[0..-2], path[-1], data, *options) + real_store.create(path[0..-2], path[-1], data, :create_dir, *options) else raise end |