145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/puppet/application/resource.rb', line 145
def main
env = Puppet.lookup(:environments).get(Puppet[:environment]) || create_default_environment
Puppet.override(
current_environment: env,
loaders: Puppet::Pops::Loaders.new(env),
stringify_rich: true
) do
type, name, params = parse_args(command_line.args)
raise _("Editing with Yaml output is not supported") if options[:edit] and options[:to_yaml]
resources = find_or_save_resources(type, name, params)
if options[:to_yaml]
data = resources.map do |resource|
resource.prune_parameters(:parameters_to_include => ).to_hiera_hash
end.inject(:merge!)
text = YAML.dump(type.downcase => data)
else
text = resources.map do |resource|
resource.prune_parameters(:parameters_to_include => ).to_manifest.force_encoding(Encoding.default_external)
end.join("\n")
end
options[:edit] ?
handle_editing(text) :
(puts text)
end
end
|