Skip to content

Commit

Permalink
Merge pull request #89 from Magisus/resolve-config
Browse files Browse the repository at this point in the history
(maint) Resolve config object before manipulating it
  • Loading branch information
justinstoller authored Oct 23, 2018
2 parents d9de8af + 91fefca commit e147dbb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/hocon_setting/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def conf_object
if @conf_file.nil? && !File.exist?(file_path)
File.new(file_path, 'w')
end
Hocon::ConfigFactory.parse_file(file_path)
Hocon::ConfigFactory.parse_file(file_path).resolve
end

def remove_value(value_to_remove)
Expand Down
29 changes: 29 additions & 0 deletions spec/unit/puppet/provider/conf_setting/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -839,4 +839,33 @@ def validate_file(expected_content, tmp = tmpfile)
expect(provider.value[0]).to eql('a' => 'b')
end
end

context 'substitutions' do
let(:orig_content) do
<<-EOS
test_key_1:
{
bar: barvalue
}
sub_key: ${test_key_1.bar}
EOS
end

it 'can change the value of a setting with a substitution' do
resource = Puppet::Type::Hocon_setting.new(common_params.merge(
setting: 'sub_key', ensure: 'present', value: 'newvalue', type: 'string',
))
provider = described_class.new(resource)
expect(provider.exists?).to be true
provider.value = 'newvalue'
validate_file(<<-EOS
test_key_1:
{
bar: barvalue
}
sub_key: "newvalue"
EOS
)
end
end
end

0 comments on commit e147dbb

Please sign in to comment.