eureka_template - library to generate files from eureka information
This library helps you generate files based on jinja2 templates based on information retrieved from Eureka
eureka_template can be installed using the pip distribution system for python by issuing:
$ pip install eureka_template
Alternatively, you can run use setup.py to install by cloning this repository and issuing:
# python setup.py install
Create a file named template.conf.tmpl:
[
{% for app in apps %}
{
"name": "{{ app.name }}",
"instances": [
{% for instance in app.instances %}
{
"hostName": "{{ instance.hostname }}",
"port": {{ instance.port }}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}{% if not loop.last %},{% endif %}
{% endfor %}
]
Then execute:
eureka-template -e http://eureka.example.com/eureka/v2/ \
-t template.conf.tmpl \
-o /dev/stdout
You'll see your template filled with data on the screen.
It will keep running and polling eureka and will generate a new template any time there's a change.
You can specify a command to execute whenever the template is generated by using the -c flag
eureka-template -e http://eureka.example.com/eureka/v2/ \
-t template.conf.tmpl \
-o /dev/stdout
-c "echo hi"
You can also run it and exit immediately:
eureka-template -e http://eureka.example.com/eureka/v2/ \
-t template.conf.tmpl \
-o /dev/stdout \
-c "echo hi" \
--once
eureka_template is licensed under the Apache License 2.0. See LICENSE for the eureka_template full license text.