Skip to content

Commit

Permalink
Remove INFLUX_ORG and INFLUX_BUCKET
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Apr 18, 2024
1 parent 5a3a4f6 commit c828ee8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
2 changes: 0 additions & 2 deletions node_cli/configs/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
'MONITORING_CONTAINERS': '',
'TELEGRAF': '',
'INFLUX_TOKEN': '',
'INFLUX_ORG': '',
'INFLUX_URL': '',
'INFLUX_BUCKET': '',
'TG_API_KEY': '',
'TG_CHAT_ID': '',
'CONTAINER_CONFIGS_DIR': '',
Expand Down
2 changes: 0 additions & 2 deletions node_cli/operations/telegraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class TelegrafNotConfiguredError(Exception):
def get_telegraf_options(env) -> dict:
options = {
'token': env.get('INFLUX_TOKEN'),
'org': env.get('INFLUX_ORG'),
'bucket': env.get('INFLUX_BUCKET'),
'url': env.get('INFLUX_URL')
}
missing = list(filter(lambda k: not options[k], options))
Expand Down
14 changes: 3 additions & 11 deletions tests/operations/telegraf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
def test_get_telegraf_options():
env = {
'INFLUX_TOKEN': 'token',
'INFLUX_ORG': 'org',
'INFLUX_BUCKET': 'bucket',
'INFLUX_URL': 'http://127.0.0.1:8444'
}
options = get_telegraf_options(env)
assert options == {
'token': 'token',
'org': 'org',
'bucket': 'bucket',
'url': 'http://127.0.0.1:8444'
}
env.pop('INFLUX_TOKEN')
Expand All @@ -32,10 +28,8 @@ def test_get_telegraf_options():
def template_path(tmp_dir_path):
path = os.path.join(tmp_dir_path, 'telegraf.conf.j2')
template = """
[[outputs.influxdb_v2]]
bucket = "{{ bucket }}"
organization = "{{ org }}"
token = "{{ token }}"
[[outputs.influxdb]]
http_headers = {"Authorization": "Bearer {{ token }}"}
urls = ["{{ url }}"]
"""
Expand All @@ -48,11 +42,9 @@ def test_generate_telegraf_config(tmp_dir_path, template_path):
test_config_path = os.path.join(tmp_dir_path, 'telegraf.conf')
generate_telegraf_config({
'token': 'token',
'org': 'org',
'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"\nurls = ["http://127.0.0.1:8444"]\n' # noqa
assert config == '\n[[outputs.influxdb]]\nhttp_headers = {"Authorization": "Bearer token"}\nurls = ["http://127.0.0.1:8444"]\n' # noqa

0 comments on commit c828ee8

Please sign in to comment.