Skip to content

Commit

Permalink
Use correct user-association endpoint for Chef 12
Browse files Browse the repository at this point in the history
The correct endpoint for user-association is:

POST /organizations/ORGNAME/users

The API currently being made will be rejected with a 405 Method Not
Allowed error.
  • Loading branch information
stevendanna committed May 27, 2015
1 parent 53cfafe commit 919a5d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/chef/provider/chef_organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def whyrun_supported?
new_resource.members.each do |user|
if !existing_members.include?(user)
converge_by "Add #{user} to organization #{new_resource.name}" do
rest.post("#{rest.root_url}/organizations/#{new_resource.name}/users/#{user}", {})
rest.post("#{rest.root_url}/organizations/#{new_resource.name}/users/", { 'username' => user })
end
end
end
Expand Down
9 changes: 5 additions & 4 deletions lib/chef/resource/chef_organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ def invites_specified?
!!@invites
end

# A list of users who must be members of the org. This will use the new Chef 12
# POST /organizations/ORG/users/NAME endpoint to add them directly to the org.
# If you do not have permission to perform this operation, and the users are not
# a part of the org, the resource update will fail.
# A list of users who must be members of the org. This will use the
# new Chef 12 POST /organizations/ORG/users endpoint to add them
# directly to the org. If you do not have permission to perform
# this operation, and the users are not a part of the org, the
# resource update will fail.
def members(*users)
if users.size == 0
@members || []
Expand Down

0 comments on commit 919a5d3

Please sign in to comment.