Skip to content

Commit

Permalink
Remove legacy top-scope syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Nov 23, 2023
1 parent eb76304 commit 933711b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions templates/alertmanager.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<% require 'yaml' -%>
<% global = scope.lookupvar('::prometheus::alertmanager::global') -%>
<% templates = scope.lookupvar('::prometheus::alertmanager::templates') -%>
<% route = scope.lookupvar('::prometheus::alertmanager::route') -%>
<% receivers = scope.lookupvar('::prometheus::alertmanager::receivers') -%>
<% inhibit_rules = scope.lookupvar('::prometheus::alertmanager::inhibit_rules') -%>
<% global = scope.lookupvar('prometheus::alertmanager::global') -%>
<% templates = scope.lookupvar('prometheus::alertmanager::templates') -%>
<% route = scope.lookupvar('prometheus::alertmanager::route') -%>
<% receivers = scope.lookupvar('prometheus::alertmanager::receivers') -%>
<% inhibit_rules = scope.lookupvar('prometheus::alertmanager::inhibit_rules') -%>
<% full_config = { 'global'=>global, 'templates'=>templates, 'route'=>route, 'receivers'=>receivers, 'inhibit_rules'=>inhibit_rules } -%>
<%
if scope.function_versioncmp([scope.lookupvar('::prometheus::alertmanager::version'), '0.22.0']) >= 0 &&
scope.lookupvar('::prometheus::alertmanager::time_intervals').empty?
full_config['mute_time_intervals'] = scope.lookupvar('::prometheus::alertmanager::mute_time_intervals')
if scope.function_versioncmp([scope.lookupvar('prometheus::alertmanager::version'), '0.22.0']) >= 0 &&
scope.lookupvar('prometheus::alertmanager::time_intervals').empty?
full_config['mute_time_intervals'] = scope.lookupvar('prometheus::alertmanager::mute_time_intervals')
end
if scope.function_versioncmp([scope.lookupvar('::prometheus::alertmanager::version'), '0.24.0']) >= 0 &&
! scope.lookupvar('::prometheus::alertmanager::time_intervals').empty?
full_config['time_intervals'] = scope.lookupvar('::prometheus::alertmanager::time_intervals')
if scope.function_versioncmp([scope.lookupvar('prometheus::alertmanager::version'), '0.24.0']) >= 0 &&
! scope.lookupvar('prometheus::alertmanager::time_intervals').empty?
full_config['time_intervals'] = scope.lookupvar('prometheus::alertmanager::time_intervals')
end
-%>
<%= full_config.to_yaml -%>
14 changes: 7 additions & 7 deletions templates/prometheus.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<% require 'yaml' -%>
<% global_config = scope.lookupvar('::prometheus::server::global_config') -%>
<% rule_files = scope.lookupvar('::prometheus::server::_rule_files') -%>
<% scrape_configs = scope.lookupvar('::prometheus::config::scrape_configs') -%>
<% remote_read_configs = scope.lookupvar('::prometheus::server::remote_read_configs') -%>
<% remote_write_configs = scope.lookupvar('::prometheus::server::remote_write_configs') -%>
<% global_config = scope.lookupvar('prometheus::server::global_config') -%>
<% rule_files = scope.lookupvar('prometheus::server::_rule_files') -%>
<% scrape_configs = scope.lookupvar('prometheus::config::scrape_configs') -%>
<% remote_read_configs = scope.lookupvar('prometheus::server::remote_read_configs') -%>
<% remote_write_configs = scope.lookupvar('prometheus::server::remote_write_configs') -%>
<% full_config = {
'global'=>global_config,
'rule_files'=>rule_files,
'scrape_configs'=>scrape_configs + @collected_scrape_jobs,
'alerting'=>{
'alert_relabel_configs'=>scope.lookupvar('::prometheus::server::alert_relabel_config'),
'alertmanagers'=>scope.lookupvar('::prometheus::server::alertmanagers_config'),
'alert_relabel_configs'=>scope.lookupvar('prometheus::server::alert_relabel_config'),
'alertmanagers'=>scope.lookupvar('prometheus::server::alertmanagers_config'),
},
}
if @prometheus_v2
Expand Down

0 comments on commit 933711b

Please sign in to comment.