summaryrefslogtreecommitdiff
path: root/lib/chef/knife/user_create.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/knife/user_create.rb')
-rw-r--r--lib/chef/knife/user_create.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb
index 471fc24bd8..6e552e25b6 100644
--- a/lib/chef/knife/user_create.rb
+++ b/lib/chef/knife/user_create.rb
@@ -65,6 +65,10 @@ class Chef
Chef::UserV1.from_hash(hash).create
end
+ def chef_rest
+ user.chef_root_rest_v0
+ end
+
def run
test_mandatory_field(@name_args[0], "username")
user.username @name_args[0]
@@ -119,13 +123,13 @@ class Chef
end
end
- final_user = user.chef_root_rest_v0.post("users/", user_hash)
+ final_user = chef_rest.post("users/", user_hash)
if config[:orgname]
request_body = { user: user.username }
- response = user.chef_root_rest_v0.post("organizations/#{config[:orgname]}/association_requests", request_body)
+ response = chef_rest.post("organizations/#{config[:orgname]}/association_requests", request_body)
association_id = response["uri"].split("/").last
- user.chef_root_rest_v0.put("users/#{user.username}/association_requests/#{association_id}", { response: "accept" })
+ chef_rest.put("users/#{user.username}/association_requests/#{association_id}", { response: "accept" })
end
ui.info("Created #{user}")
@@ -141,7 +145,7 @@ class Chef
end
def prompt_for_password
- ui.ask("Please enter the user's password: ") { |q| q.echo = false }
+ ui.ask("Please enter the user's password: ", echo: false)
end
end
end