From c828ee8346493c42e243503ef6e3438c613f9ad9 Mon Sep 17 00:00:00 2001 From: badrogger Date: Thu, 18 Apr 2024 16:51:46 +0000 Subject: [PATCH] Remove INFLUX_ORG and INFLUX_BUCKET --- node_cli/configs/env.py | 2 -- node_cli/operations/telegraf.py | 2 -- tests/operations/telegraf_test.py | 14 +++----------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/node_cli/configs/env.py b/node_cli/configs/env.py index 7b619797..7b6bf116 100644 --- a/node_cli/configs/env.py +++ b/node_cli/configs/env.py @@ -36,9 +36,7 @@ 'MONITORING_CONTAINERS': '', 'TELEGRAF': '', 'INFLUX_TOKEN': '', - 'INFLUX_ORG': '', 'INFLUX_URL': '', - 'INFLUX_BUCKET': '', 'TG_API_KEY': '', 'TG_CHAT_ID': '', 'CONTAINER_CONFIGS_DIR': '', diff --git a/node_cli/operations/telegraf.py b/node_cli/operations/telegraf.py index f3d3e232..de876197 100644 --- a/node_cli/operations/telegraf.py +++ b/node_cli/operations/telegraf.py @@ -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)) diff --git a/tests/operations/telegraf_test.py b/tests/operations/telegraf_test.py index 15cec227..df41b51d 100644 --- a/tests/operations/telegraf_test.py +++ b/tests/operations/telegraf_test.py @@ -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') @@ -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 }}"] """ @@ -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