Class: Chef::Knife::UserShow

Inherits:
Knife
  • Object
show all
Includes:
Core::MultiAttributeReturnOption
Defined in:
lib/chef/knife/user_show.rb

Instance Method Summary collapse

Methods included from Core::MultiAttributeReturnOption

included

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/chef/knife/user_show.rb', line 33

def run
  @user_name = @name_args[0]

  if @user_name.nil?
    show_usage
    ui.fatal("You must specify a user name")
    exit 1
  end

  results = root_rest.get("users/#{@user_name}")
  if config[:with_orgs]
    orgs = root_rest.get("users/#{@user_name}/organizations")
    results["organizations"] = orgs.map { |o| o["organization"]["name"] }
  end
  output(format_for_display(results))
end