summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorjkeiser <jkeiser@opscode.com>2013-03-14 20:22:49 -0700
committerJohn Keiser <jkeiser@opscode.com>2013-06-07 13:12:30 -0700
commit7293212179dcf1f7ef30792f421b2f6e3a07b69c (patch)
treea66cfba4bb57eb6aca3d20fc40f499dda7e65e40 /lib/chef
parent55cdfaecf827c258434d51387d92bc21e8106950 (diff)
downloadchef-7293212179dcf1f7ef30792f421b2f6e3a07b69c.tar.gz
Fix groups PUT, make groups download prettier
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/chef_fs/data_handler/client_data_handler.rb8
-rw-r--r--lib/chef/chef_fs/data_handler/data_handler_base.rb4
-rw-r--r--lib/chef/chef_fs/data_handler/group_data_handler.rb20
-rw-r--r--lib/chef/chef_fs/file_system/rest_list_entry.rb2
4 files changed, 29 insertions, 5 deletions
diff --git a/lib/chef/chef_fs/data_handler/client_data_handler.rb b/lib/chef/chef_fs/data_handler/client_data_handler.rb
index 30850809db..a92e486782 100644
--- a/lib/chef/chef_fs/data_handler/client_data_handler.rb
+++ b/lib/chef/chef_fs/data_handler/client_data_handler.rb
@@ -6,14 +6,18 @@ class Chef
module DataHandler
class ClientDataHandler < DataHandlerBase
def normalize(client, entry)
- result = super(client, {
+ defaults = {
'name' => remove_dot_json(entry.name),
'clientname' => remove_dot_json(entry.name),
'orgname' => entry.org,
'admin' => false,
'validator' => false,
'chef_type' => 'client'
- })
+ }
+ if entry.org
+ defaults['orgname'] = entry.org
+ end
+ result = super(client, defaults)
# You can NOT send json_class, or it will fail
result.delete('json_class')
result
diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb
index 3fe539b29f..c5f1b93378 100644
--- a/lib/chef/chef_fs/data_handler/data_handler_base.rb
+++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb
@@ -39,6 +39,10 @@ class Chef
result
end
+ def normalize_for_put(object, entry)
+ normalize(object, entry)
+ end
+
def normalize_run_list(run_list)
run_list.map{|item|
case item.to_s
diff --git a/lib/chef/chef_fs/data_handler/group_data_handler.rb b/lib/chef/chef_fs/data_handler/group_data_handler.rb
index 18d2b28241..b27bf87c50 100644
--- a/lib/chef/chef_fs/data_handler/group_data_handler.rb
+++ b/lib/chef/chef_fs/data_handler/group_data_handler.rb
@@ -10,14 +10,30 @@ class Chef
'name' => remove_dot_json(entry.name),
'groupname' => remove_dot_json(entry.name),
'users' => [],
- 'actors' => [],
'clients' => [],
'groups' => [],
}
if entry.org
defaults['orgname'] = entry.org
end
- super(group, defaults)
+ result = super(group, defaults)
+ if result['actors'] && result['actors'].sort.uniq == (result['users'] + result['clients']).sort.uniq
+ result.delete('actors')
+ end
+ result
+ end
+
+ def normalize_for_put(group, entry)
+ result = super(group, entry)
+ result['actors'] = {
+ 'users' => result['users'],
+ 'clients' => result['clients'],
+ 'groups' => result['groups']
+ }
+ result.delete('users')
+ result.delete('clients')
+ result.delete('groups')
+ result
end
def preserve_key(key)
diff --git a/lib/chef/chef_fs/file_system/rest_list_entry.rb b/lib/chef/chef_fs/file_system/rest_list_entry.rb
index eb9bccd13b..cd1e439c47 100644
--- a/lib/chef/chef_fs/file_system/rest_list_entry.rb
+++ b/lib/chef/chef_fs/file_system/rest_list_entry.rb
@@ -149,7 +149,7 @@ class Chef
end
if data_handler
- object = data_handler.normalize(object, self)
+ object = data_handler.normalize_for_put(object, self)
end
base_name = name[0,name.length-5]