Skip to content

Commit

Permalink
(network-#13) normalize boolean values
Browse files Browse the repository at this point in the history
Puppet presents boolean values `true` and `false` to underlying classes
as symbols instead of actual booleans, so boolean types in the
providers were falsely being marked as out of sync. This normalizes
values for that.
  • Loading branch information
adrienthebo committed Dec 6, 2012
1 parent bc95e8d commit 7980cf8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/network_config/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def self.parse_file(filename, contents)
interfaces.delete_at(0)

interfaces.each do |iface|
iface_hash[iface][:hotplug] = true
iface_hash[iface][:hotplug] = :true
end

# Don't reset Reset the current parse state
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/network_config/redhat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def self.munge(pairs)

[:onboot, :hotplug].each do |bool_property|
if props[bool_property]
props[bool_property] = (props[bool_property] == 'yes')
props[bool_property] = (props[bool_property] == 'yes' ? :true : :false)
end
end

Expand Down Expand Up @@ -171,7 +171,7 @@ def self.unmunge(props)

[:onboot, :hotplug].each do |bool_property|
if props[bool_property]
props[bool_property] = (props[bool_property] ? 'yes' : 'no')
props[bool_property] = (props[bool_property] == :true ? 'yes' : 'no')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/provider/network_config/interfaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fixture_data(file)
:family => "inet",
:method => "dhcp",
:name => "eth0",
:hotplug => true,
:hotplug => :true,
:options => {},
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/provider/network_config/redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def fixture_data(file)
describe 'the hotplug property' do
describe 'when true' do
let(:data) { described_class.parse_file('eth0', fixture_data('eth0-hotplug'))[0] }
it { data[:hotplug].should be_true }
it { data[:hotplug].should == :true }
end

describe 'when false' do
let(:data) { described_class.parse_file('eth0', fixture_data('eth0-nohotplug'))[0] }
it { data[:hotplug].should be_false }
it { data[:hotplug].should == :false }
end
end

Expand Down

0 comments on commit 7980cf8

Please sign in to comment.