Skip to content
Snippets Groups Projects
Verified Commit 8aa53518 authored by Robotka István Adrián's avatar Robotka István Adrián
Browse files

add job definition to the templating

parent 881c3e96
No related branches found
No related tags found
1 merge request!8add job definition to the templating
Pipeline #4216 passed with warnings
......@@ -22,12 +22,13 @@ class ConfigBuilder:
for job in service['scraping']:
self.logger.debug("Templating: " + service['service_name'] + ' -> ' + job['template'])
self.load_template(job)
template = self.substitute_template_field(job, service)
output = self.substitute_template_field(job, service)
# store generated prometheus job config
if 'ignore' in job and check_true(job['ignore']):
job['output_yaml'] = None
else:
job['output_yaml'] = yaml.safe_load(template)
job['output_yaml'] = yaml.safe_load(output)
def load_template(self, job):
"""Substitute 'template' field with its content"""
......@@ -39,7 +40,7 @@ class ConfigBuilder:
env = jinja2.Environment(undefined=jinja2.DebugUndefined)
template = env.from_string(job['template'])
data = service.copy()
data['targets'] = job['targets']
data['job'] = job
data['snippet'] = collect_snippets(self.config.templates)
return template.render(data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment