Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Pupák
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KSZK
Open Source
Pupák
Commits
e0f3f213
Commit
e0f3f213
authored
May 31, 2020
by
Robotka István Adrián
Browse files
Options
Downloads
Plain Diff
Merge branch 'job' into 'master'
add job definition to the templating See merge request
!8
parents
881c3e96
8aa53518
Branches
Branches containing commit
Tags
v0.2
Tags containing commit
1 merge request
!8
add job definition to the templating
Pipeline
#4294
failed
Jun 9, 2020
Stage: Get dependencies
Stage: Static Analysis
Stage: Docker build
Changes
1
Pipelines
3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
build.py
+4
-3
4 additions, 3 deletions
build.py
with
4 additions
and
3 deletions
build.py
+
4
−
3
View file @
e0f3f213
...
@@ -22,12 +22,13 @@ class ConfigBuilder:
...
@@ -22,12 +22,13 @@ class ConfigBuilder:
for
job
in
service
[
'
scraping
'
]:
for
job
in
service
[
'
scraping
'
]:
self
.
logger
.
debug
(
"
Templating:
"
+
service
[
'
service_name
'
]
+
'
->
'
+
job
[
'
template
'
])
self
.
logger
.
debug
(
"
Templating:
"
+
service
[
'
service_name
'
]
+
'
->
'
+
job
[
'
template
'
])
self
.
load_template
(
job
)
self
.
load_template
(
job
)
template
=
self
.
substitute_template_field
(
job
,
service
)
output
=
self
.
substitute_template_field
(
job
,
service
)
# store generated prometheus job config
# store generated prometheus job config
if
'
ignore
'
in
job
and
check_true
(
job
[
'
ignore
'
]):
if
'
ignore
'
in
job
and
check_true
(
job
[
'
ignore
'
]):
job
[
'
output_yaml
'
]
=
None
job
[
'
output_yaml
'
]
=
None
else
:
else
:
job
[
'
output_yaml
'
]
=
yaml
.
safe_load
(
template
)
job
[
'
output_yaml
'
]
=
yaml
.
safe_load
(
output
)
def
load_template
(
self
,
job
):
def
load_template
(
self
,
job
):
"""
Substitute
'
template
'
field with its content
"""
"""
Substitute
'
template
'
field with its content
"""
...
@@ -39,7 +40,7 @@ class ConfigBuilder:
...
@@ -39,7 +40,7 @@ class ConfigBuilder:
env
=
jinja2
.
Environment
(
undefined
=
jinja2
.
DebugUndefined
)
env
=
jinja2
.
Environment
(
undefined
=
jinja2
.
DebugUndefined
)
template
=
env
.
from_string
(
job
[
'
template
'
])
template
=
env
.
from_string
(
job
[
'
template
'
])
data
=
service
.
copy
()
data
=
service
.
copy
()
data
[
'
targets
'
]
=
job
[
'
targets
'
]
data
[
'
job
'
]
=
job
data
[
'
snippet
'
]
=
collect_snippets
(
self
.
config
.
templates
)
data
[
'
snippet
'
]
=
collect_snippets
(
self
.
config
.
templates
)
return
template
.
render
(
data
)
return
template
.
render
(
data
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment