summaryrefslogtreecommitdiffstats
path: root/integrations/gen_docs_integrations.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:44 +0000
commit836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch)
tree1604da8f482d02effa033c94a84be42bc0c848c3 /integrations/gen_docs_integrations.py
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz
netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'integrations/gen_docs_integrations.py')
-rw-r--r--integrations/gen_docs_integrations.py123
1 files changed, 98 insertions, 25 deletions
diff --git a/integrations/gen_docs_integrations.py b/integrations/gen_docs_integrations.py
index 2b27db859..2382e1dbb 100644
--- a/integrations/gen_docs_integrations.py
+++ b/integrations/gen_docs_integrations.py
@@ -5,29 +5,29 @@ import re
# Dictionary responsible for making the symbolic links at the end of the script's run.
symlink_dict = {}
-am_i_inside_go = "go.d.plugin" in str(Path.cwd())
def cleanup():
"""
clean directories that are either data collection or exporting integrations
"""
- if am_i_inside_go:
- for element in Path("modules").glob('**/*/'):
- if "integrations" in str(element):
- shutil.rmtree(element)
- else:
- for element in Path("collectors").glob('**/*/'):
- if "integrations" in str(element):
- shutil.rmtree(element)
-
- for element in Path("exporting").glob('**/*/'):
- if "integrations" in str(element):
- shutil.rmtree(element)
- for element in Path("integrations/cloud-notifications").glob('**/*/'):
- if "integrations" in str(element) and not "metadata.yaml" in str(element):
- shutil.rmtree(element)
-
+ for element in Path("src/go/collectors/go.d.plugin/modules").glob('**/*/'):
+ if "integrations" in str(element):
+ shutil.rmtree(element)
+ for element in Path("src/collectors").glob('**/*/'):
+ # print(element)
+ if "integrations" in str(element):
+ shutil.rmtree(element)
+
+ for element in Path("src/exporting").glob('**/*/'):
+ if "integrations" in str(element):
+ shutil.rmtree(element)
+ for element in Path("integrations/cloud-notifications").glob('**/*/'):
+ if "integrations" in str(element) and not "metadata.yaml" in str(element):
+ shutil.rmtree(element)
+ for element in Path("integrations/cloud-authentication").glob('**/*/'):
+ if "integrations" in str(element) and not "metadata.yaml" in str(element):
+ shutil.rmtree(element)
def generate_category_from_name(category_fragment, category_array):
"""
@@ -61,8 +61,10 @@ def clean_and_write(md, path):
Then it writes the buffer on the file provided.
"""
# clean first, replace
- md = md.replace("{% details summary=\"", "<details><summary>").replace(
- "\" %}", "</summary>\n").replace("{% /details %}", "</details>\n")
+ md = md.replace("{% details summary=\"", "<details><summary>")
+ md = md.replace("{% details open=true summary=\"", "<details open><summary>")
+ md = md.replace("\" %}", "</summary>\n")
+ md = md.replace("{% /details %}", "</details>\n")
path.write_text(md)
@@ -83,6 +85,9 @@ def add_custom_edit_url(markdown_string, meta_yaml_link, sidebar_label_string, m
elif mode == 'agent-notifications':
path_to_md_file = meta_yaml_link.replace("metadata.yaml", "README")
+ elif mode == 'cloud-authentication':
+ path_to_md_file = meta_yaml_link.replace("metadata.yaml", f'integrations/{clean_string(sidebar_label_string)}')
+
output = markdown_string.replace(
"<!--startmeta",
f'<!--startmeta\ncustom_edit_url: \"{path_to_md_file}.md\"')
@@ -145,7 +150,7 @@ def build_readme_from_integration(integration, mode=''):
meta_yaml = integration['edit_link'].replace("blob", "edit")
sidebar_label = integration['meta']['monitored_instance']['name']
learn_rel_path = generate_category_from_name(
- integration['meta']['monitored_instance']['categories'][0].split("."), categories)
+ integration['meta']['monitored_instance']['categories'][0].split("."), categories).replace("Data Collection", "Collecting Metrics")
most_popular = integration['meta']['most_popular']
# build the markdown string
@@ -197,7 +202,7 @@ endmeta-->
meta_yaml: "{meta_yaml}"
sidebar_label: "{sidebar_label}"
learn_status: "Published"
-learn_rel_path: "Exporting"
+learn_rel_path: "Exporting Metrics"
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE EXPORTER'S metadata.yaml FILE"
endmeta-->
@@ -229,7 +234,7 @@ endmeta-->
meta_yaml: "{meta_yaml}"
sidebar_label: "{sidebar_label}"
learn_status: "Published"
-learn_rel_path: "{learn_rel_path.replace("notifications", "Alerting/Notifications")}"
+learn_rel_path: "{learn_rel_path.replace("notifications", "Alerts & Notifications/Notifications")}"
message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
endmeta-->
@@ -247,6 +252,39 @@ endmeta-->
except Exception as e:
print("Exception in notification md construction", e, integration['id'])
+
+ # AUTHENTICATIONS
+ elif mode == 'authentication':
+ if True:
+ # initiate the variables for the authentication method
+ meta_yaml = integration['edit_link'].replace("blob", "edit")
+ sidebar_label = integration['meta']['name']
+ learn_rel_path = generate_category_from_name(integration['meta']['categories'][0].split("."), categories)
+
+ # build the markdown string
+ md = \
+ f"""<!--startmeta
+meta_yaml: "{meta_yaml}"
+sidebar_label: "{sidebar_label}"
+learn_status: "Published"
+learn_rel_path: "{learn_rel_path.replace("authentication", "Netdata Cloud/Authentication & Authorization/Cloud Authentication & Authorization Integrations")}"
+message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE AUTHENTICATION'S metadata.yaml FILE"
+endmeta-->
+
+{create_overview(integration, integration['meta']['icon_filename'])}"""
+
+ if integration['setup']:
+ md += f"""
+{integration['setup']}
+"""
+
+ if integration['troubleshooting']:
+ md += f"""
+{integration['troubleshooting']}
+"""
+
+ # except Exception as e:
+ # print("Exception in authentication md construction", e, integration['id'])
if "community" in integration['meta'].keys():
community = "<img src=\"https://img.shields.io/badge/maintained%20by-Community-blue\" />"
@@ -332,14 +370,42 @@ def write_to_file(path, md, meta_yaml, sidebar_label, community, mode='default')
except FileNotFoundError as e:
print("Exception in writing to file", e)
+ elif mode == 'authentication':
+
+ name = clean_string(integration['meta']['name'])
+
+ if not Path(f'{path}/integrations').exists():
+ Path(f'{path}/integrations').mkdir()
+
+ # proper_edit_name = meta_yaml.replace(
+ # "metadata.yaml", f'integrations/{clean_string(sidebar_label)}.md\"')
+
+ md = add_custom_edit_url(md, meta_yaml, sidebar_label, mode='cloud-authentication')
+
+ finalpath = f'{path}/integrations/{name}.md'
+
+ try:
+ clean_and_write(
+ md,
+ Path(finalpath)
+ )
+
+ except FileNotFoundError as e:
+ print("Exception in writing to file", e)
+
def make_symlinks(symlink_dict):
"""
takes a dictionary with directories that have a 1:1 relationship between their README and the integration (only one) inside the "integrations" folder.
"""
for element in symlink_dict:
- # Remove the README to prevent it being a normal file
- Path(f'{element}/README.md').unlink()
+ if not Path(f'{element}/README.md').exists():
+ Path(f'{element}/README.md').touch()
+ try:
+ # Remove the README to prevent it being a normal file
+ Path(f'{element}/README.md').unlink()
+ except FileNotFoundError:
+ continue
# and then make a symlink to the actual markdown
Path(f'{element}/README.md').symlink_to(symlink_dict[element])
@@ -367,7 +433,7 @@ for integration in integrations:
path = build_path(meta_yaml)
write_to_file(path, md, meta_yaml, sidebar_label, community)
- elif not am_i_inside_go:
+ else:
# kind of specific if clause, so we can avoid running excessive code in the go repo
if integration['integration_type'] == "exporter":
@@ -384,5 +450,12 @@ for integration in integrations:
path = build_path(meta_yaml)
write_to_file(path, md, meta_yaml, sidebar_label, community, mode='notification')
+ elif integration['integration_type'] == "authentication":
+
+ meta_yaml, sidebar_label, learn_rel_path, md, community = build_readme_from_integration(
+ integration, mode='authentication')
+ path = build_path(meta_yaml)
+ write_to_file(path, md, meta_yaml, sidebar_label, community, mode='authentication')
+
make_symlinks(symlink_dict)