38
39
40
41
42
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/chef/knife/config_show.rb', line 38
def run
if config[:format] == "summary" && !config[:raw]
wcl = self.class.config_loader
if wcl.credentials_found
loading_from("credentials", ChefConfig::PathHelper.home(".chef", "credentials"))
end
if wcl.config_location
loading_from("configuration", wcl.config_location)
end
if Chef::Config[:config_d_dir]
wcl.find_dot_d(Chef::Config[:config_d_dir]).each do |path|
loading_from(".d/ configuration", path)
end
end
end
config_data = Chef::Config.save(config[:all])
unless config[:all]
config_data.delete(:color)
config_data.delete(:local_mode) unless config_data[:local_mode]
config_data.delete(:enforce_default_paths) unless config_data[:enforce_default_paths]
config_data.delete(:enforce_path_sanity) unless config_data[:enforce_path_sanity]
end
output_data = {}
if @name_args.empty?
output_data = config_data
else
@name_args.each do |filter|
if filter =~ %r{^/(.*)/(i?)$}
filter_re = Regexp.new($1, $2 ? Regexp::IGNORECASE : 0)
config_data.each do |key, value|
output_data[key] = value if key.to_s.match?(filter_re)
end
else
filter_parts = filter.split(".")
= lambda do |memo, filter_part|
memo.is_a?(Hash) ? memo[filter_part.to_sym] : nil
end
output_data[filter] = filter_parts.inject(config_data, &) || filter_parts.inject(Chef::Config.save(true), &)
end
end
end
output_data.each do |key, value|
if value == STDOUT
output_data[key] = "STDOUT"
elsif value == STDERR
output_data[key] = "STDERR"
end
end
if config[:raw]
output_data.each_value do |value|
ui.msg(value)
end
else
ui.output(output_data)
end
end
|