Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/puppet/face/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def report_section_and_environment(section_name, environment_name)
end

path = Puppet::FileSystem.pathname(Puppet.settings.which_configuration_file)
Puppet::FileSystem.dir_mkpath(path)
Puppet::FileSystem.touch(path)
Comment on lines +174 to 175
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thought to go in the other direction: should it return if the file doesn't exist? What's the point in creating an empty file and then reading it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not "reading" the file, it's opening it and manipulating it. Which ultimately means either changing the contents or adding content -- but the difference is irrelevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, my bad.

Puppet::FileSystem.open(path, nil, 'r+:UTF-8') do |file|
Puppet::Settings::IniFile.update(file) do |config|
Expand Down
1 change: 1 addition & 0 deletions spec/unit/face/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def render(action, result)
before(:each) do
Puppet[:config] = config_file
allow(Puppet::FileSystem).to receive(:pathname).with(path.to_s).and_return(path)
allow(Puppet::FileSystem).to receive(:dir_mkpath)
allow(Puppet::FileSystem).to receive(:touch)
end

Expand Down