Skip to content

Commit

Permalink
fix #575 Downgrade restore of vars
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Jul 13, 2019
1 parent ce1e783 commit 2ddfaa6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
5 changes: 2 additions & 3 deletions lib/puppet_x/icinga2/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,8 @@ def self.process_hash(attrs, indent=2, level=3, prefix=' '*indent)
end
end
else
if value =~ /^\+\s+/
config += "%s%s += %s\n" % [ ' ' * indent, attr, value.sub(/^\+\s+/, '') ]
end
op = '+' if value =~ /^\+\s+/
config += "%s%s #{op}= %s\n" % [ ' ' * indent, attr, parse(value.sub(/^\+\s+/, '')) ]
end
else
if value.is_a?(Hash)
Expand Down
25 changes: 15 additions & 10 deletions spec/functions/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,24 @@
end


# vars = +config1
it 'assign multiple custom attributes' do
# vars += config1
is_expected.to run.with_params({
'vars' => '+ config',
}).and_return("vars += config\n")

# vars += config1
# vars += {}
# vars.foo = "some string"
# vars.bar += [ 42, 3.141, -42, -3.141, ]
# vars.baz["number"] -= 42
# vars.baz["floating"] += 3.141
# vars += config2
}, 0, ['config']).and_return("vars += config\n")

# vars = vars + config1
is_expected.to run.with_params({
'vars' => 'vars + config',
}, 0, ['vars','config']).and_return("vars = vars + config\n")

# vars += config1
# vars += {}
# vars.foo = "some string"
# vars.bar += [ 42, 3.141, -42, -3.141, ]
# vars.baz["number"] -= 42
# vars.baz["floating"] += 3.141
# vars += config2
is_expected.to run.with_params({
'vars' => [
'+ config1',
Expand Down

0 comments on commit 2ddfaa6

Please sign in to comment.