43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/chef/knife/config_list.rb', line 43
def run
credentials_data = self.class.config_loader.parse_credentials_file
if credentials_data.nil? || credentials_data.empty?
ui.fatal("No profiles found, #{self.class.config_loader.credentials_file_path} does not exist or is empty")
exit 1
end
current_profile = self.class.config_loader.credentials_profile(config[:profile])
profiles = credentials_data.keys.map do |profile|
if config[:ignore_knife_rb]
profile_data = credentials_data[profile]
{
profile: profile,
active: profile == current_profile,
client_name: profile_data["client_name"] || profile_data["node_name"],
client_key: profile_data["client_key"],
server_url: profile_data["chef_server_url"],
}
else
Chef::Config.reset
wcl = Chef::WorkstationConfigLoader.new(nil, Chef::Log, profile: profile)
wcl.load
{
profile: profile,
active: profile == current_profile,
client_name: Chef::Config[:node_name],
client_key: Chef::Config[:client_key],
server_url: Chef::Config[:chef_server_url],
}
end
end
unless config[:ignore_knife_rb]
Chef::Config.reset
apply_computed_config
end
if ui.interchange?
ui.output(profiles)
else
ui.output(render_table(profiles))
end
end
|