Skip to content

Commit

Permalink
Add missing INFLUX_URL parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Apr 11, 2024
1 parent fc633c1 commit 5a3a4f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions node_cli/configs/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'TELEGRAF': '',
'INFLUX_TOKEN': '',
'INFLUX_ORG': '',
'INFLUX_URL': '',
'INFLUX_BUCKET': '',
'TG_API_KEY': '',
'TG_CHAT_ID': '',
Expand Down
3 changes: 2 additions & 1 deletion node_cli/operations/telegraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def get_telegraf_options(env) -> dict:
options = {
'token': env.get('INFLUX_TOKEN'),
'org': env.get('INFLUX_ORG'),
'bucket': env.get('INFLUX_BUCKET')
'bucket': env.get('INFLUX_BUCKET'),
'url': env.get('INFLUX_URL')
}
missing = list(filter(lambda k: not options[k], options))
if missing:
Expand Down
13 changes: 9 additions & 4 deletions tests/operations/telegraf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ def test_get_telegraf_options():
env = {
'INFLUX_TOKEN': 'token',
'INFLUX_ORG': 'org',
'INFLUX_BUCKET': 'bucket'
'INFLUX_BUCKET': 'bucket',
'INFLUX_URL': 'http://127.0.0.1:8444'
}
options = get_telegraf_options(env)
assert options == {
'token': 'token',
'org': 'org',
'bucket': 'bucket'
'bucket': 'bucket',
'url': 'http://127.0.0.1:8444'
}
env.pop('INFLUX_TOKEN')
with pytest.raises(TelegrafNotConfiguredError):
Expand All @@ -34,6 +36,8 @@ def template_path(tmp_dir_path):
bucket = "{{ bucket }}"
organization = "{{ org }}"
token = "{{ token }}"
urls = ["{{ url }}"]
"""
with open(path, 'w') as tf:
tf.write(template)
Expand All @@ -45,9 +49,10 @@ def test_generate_telegraf_config(tmp_dir_path, template_path):
generate_telegraf_config({
'token': 'token',
'org': 'org',
'bucket': 'bucket'
'bucket': 'bucket',
'url': 'http://127.0.0.1:8444'
}, template_path, test_config_path)

with open(test_config_path) as config_path:
config = config_path.read()
assert config == '\n[[outputs.influxdb_v2]]\nbucket = "bucket"\norganization = "org"\ntoken = "token"' # noqa
assert config == '\n[[outputs.influxdb_v2]]\nbucket = "bucket"\norganization = "org"\ntoken = "token"\nurls = ["http://127.0.0.1:8444"]\n' # noqa

0 comments on commit 5a3a4f6

Please sign in to comment.