-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #704 Tune icinga::icinga2_attributes function call
- Loading branch information
Showing
8 changed files
with
139 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# @summary | ||
# This function parse icinga object attributes. | ||
# | ||
function icinga2::parse( | ||
Hash[String, Any] $attrs, | ||
Integer $indent = 0, | ||
Array[String] $reserved = [], | ||
Hash[String, Any] $constants = {}, | ||
) { | ||
# @param attr | ||
# Object attributes to parse. | ||
# | ||
# @param indent | ||
# Indent to use. | ||
# | ||
# @param reserved | ||
# A list of addational reserved words. | ||
# | ||
# @param constants | ||
# A hash of additional constants. | ||
# | ||
icinga2::icinga2_attributes( | ||
$attrs, | ||
concat($::icinga2::globals::reserved, $reserved), | ||
merge($::icinga2::_constants, $constants), | ||
$indent | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<%- | Hash $attrs, | ||
Array $attrs_list, | ||
Variant[String, Boolean] $apply, | ||
Optional[String] $apply_target = undef, | ||
Variant[String, Boolean] $prefix, | ||
String $object_type, | ||
String $object_name, | ||
Boolean $template, | ||
Array $import, | ||
| -%> | ||
|
||
<% if $apply =~ String { %>apply <%= $object_type -%> | ||
<% if $prefix { -%> | ||
<% if $prefix =~ String { %> "<%= $prefix %>"<% } else { -%> | ||
<% if $object_name in $icinga2::_constants { -%> | ||
<%= $object_name -%> | ||
<% } else { -%> | ||
"<%= $object_name -%>"<% } -%> | ||
<% } -%> | ||
<% } -%> | ||
for (<%= $apply %>)<% if $apply_target { %> to <%= $apply_target %><% } %> { | ||
<% } else { -%> | ||
<% if $apply { %>apply<% } else { -%> | ||
<% if $template { %>template<% } else { %>object<% } -%> | ||
<% } %> <%= $object_type -%> | ||
<% if $object_name in $icinga2::_constants { -%> | ||
<%= $object_name -%> | ||
<% } else { -%> | ||
"<%= $object_name %>"<% } -%> | ||
<% if $apply and $apply_target { %> to <%= $apply_target %><% } %> { | ||
<% } -%> | ||
<% $import.each |$i| { -%> | ||
import "<%= $i %>" | ||
<% } -%> | ||
<% unless $import =~ Array[Data,0,0] { %><%= "\n" %><% } -%> | ||
<% if $apply =~String and $apply =~ /^([A-Za-z_]+)\s+in\s+.+$/ { -%> | ||
<%= icinga2::parse($attrs, 2, $attrs_list, {$1=>{}}) -%> | ||
<% } elsif $apply =~ String and $apply =~ /^([A-Za-z_]+)\s+=>\s+([A-Za-z_]+)\s+in\s+.+$/ { -%> | ||
<%= icinga2::parse($attrs, 2, $attrs_list+[$1], {$2=>{}}) -%> | ||
<% } else { -%> | ||
<%= icinga2::parse($attrs, 2, $attrs_list) -%> | ||
<% } -%> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters