From 9482bc89545e5ba6a88906010265e0d40de2d561 Mon Sep 17 00:00:00 2001 From: "david.jones" Date: Tue, 13 Apr 2021 12:42:42 +0100 Subject: [PATCH 1/4] handling integration generation collisions --- local/bin/py/build/actions/integrations.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/local/bin/py/build/actions/integrations.py b/local/bin/py/build/actions/integrations.py index 184392d88f34a..0fe05652f1bcc 100644 --- a/local/bin/py/build/actions/integrations.py +++ b/local/bin/py/build/actions/integrations.py @@ -541,7 +541,10 @@ def process_integration_readme(self, file_name, marketplace=False): new_file_name = "{}.md".format( basename(dirname(file_name)) ) - exist_already = exists( + # is this the same as a committed hardcoded integration + exist_already = (self.content_integrations_dir + new_file_name in self.initial_integration_files) + # is this overwriting another generated integration + exist_collision = exists( self.content_integrations_dir + new_file_name ) @@ -624,13 +627,23 @@ def process_integration_readme(self, file_name, marketplace=False): if not exist_already and no_integration_issue: # lets only write out file.md if its going to be public if manifest_json.get("is_public", False): - with open(self.content_integrations_dir + new_file_name, "w", ) as out: + out_name = self.content_integrations_dir + new_file_name + + # if the same integration exists in multiple locations try name md after manifest name entry + if exist_collision: + f_name = manifest_json.get("name", new_file_name) + f_name = f_name if f_name.endswith('.md') else f_name + ".md" + out_name = self.content_integrations_dir + f_name + print("\x1b[33mWARNING\x1b[0m: Collision, duplicate integration {} trying as {}".format( + new_file_name, f_name)) + + with open(out_name, "w", ) as out: out.write(result) ## Reformating all links now that all processing is done if tab_logic: - final_text = format_link_file(self.content_integrations_dir + new_file_name,regex_skip_sections_start,regex_skip_sections_end) - with open(self.content_integrations_dir + new_file_name, 'w') as final_file: + final_text = format_link_file(out_name, regex_skip_sections_start, regex_skip_sections_end) + with open(out_name, 'w') as final_file: final_file.write(final_text) def add_integration_frontmatter( From 751f09f8b89c1d4298c197766aaa15a4ac7e85dc Mon Sep 17 00:00:00 2001 From: "david.jones" Date: Tue, 13 Apr 2021 14:11:02 +0100 Subject: [PATCH 2/4] handle marketplace images that are relative too --- local/bin/py/build/actions/integrations.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/local/bin/py/build/actions/integrations.py b/local/bin/py/build/actions/integrations.py index 0fe05652f1bcc..f19450093a70c 100644 --- a/local/bin/py/build/actions/integrations.py +++ b/local/bin/py/build/actions/integrations.py @@ -425,16 +425,16 @@ def process_images(self, file_name): copyfile(file_name, full_destination_path) @staticmethod - def replace_image_src(markdown_string): + def replace_image_src(markdown_string, integration_name): """ Takes a markdown string and replaces any image markdown with our img shortcode, pointing to the static/images folder. This is needed when dealing with Marketplace Integrations to properly display images pulled from a private repo. """ markdown_img_search_regex = r"!\[(.*?)\]\((.*?)\)" - img_shortcode = "{{< img src=\"\\2\" alt=\"\\1\" >}}" - integration_img_prefix = 'https://raw.githubusercontent.com/DataDog/marketplace/master/' + img_shortcode = "{{< img src=\"marketplace/" + integration_name + "/\\2\" alt=\"\\1\" >}}" + integration_img_prefix = 'https://raw.githubusercontent.com/DataDog/marketplace/master/{}/'.format(integration_name) - replaced_markdown_string = markdown_string.replace(integration_img_prefix, 'marketplace/') + replaced_markdown_string = markdown_string.replace(integration_img_prefix, '') regex_result = re.sub(markdown_img_search_regex, img_shortcode, replaced_markdown_string, 0, re.MULTILINE) if regex_result: @@ -561,7 +561,7 @@ def process_integration_readme(self, file_name, marketplace=False): else: with open(file_name, 'r+') as f: markdown_string = f.read() - markdown_with_replaced_images = self.replace_image_src(markdown_string) + markdown_with_replaced_images = self.replace_image_src(markdown_string, basename(dirname(file_name))) updated_markdown = self.remove_markdown_section(markdown_with_replaced_images, '## Setup') is_marketplace_integration_markdown_valid = self.validate_marketplace_integration_markdown(updated_markdown) From dfa6cb4e8572870f656ab8b1912866630b412225 Mon Sep 17 00:00:00 2001 From: "david.jones" Date: Tue, 13 Apr 2021 15:34:06 +0100 Subject: [PATCH 3/4] inject frontmatter after dealing with collisions --- local/bin/py/build/actions/integrations.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/local/bin/py/build/actions/integrations.py b/local/bin/py/build/actions/integrations.py index f19450093a70c..c66708adfc924 100644 --- a/local/bin/py/build/actions/integrations.py +++ b/local/bin/py/build/actions/integrations.py @@ -620,10 +620,6 @@ def process_integration_readme(self, file_name, marketplace=False): 0, ) - result = self.add_integration_frontmatter( - new_file_name, result, dependencies - ) - if not exist_already and no_integration_issue: # lets only write out file.md if its going to be public if manifest_json.get("is_public", False): @@ -636,6 +632,11 @@ def process_integration_readme(self, file_name, marketplace=False): out_name = self.content_integrations_dir + f_name print("\x1b[33mWARNING\x1b[0m: Collision, duplicate integration {} trying as {}".format( new_file_name, f_name)) + new_file_name = f_name + + result = self.add_integration_frontmatter( + new_file_name, result, dependencies + ) with open(out_name, "w", ) as out: out.write(result) From 2729638c6bff04ee3ab5d72356c80f84615068b3 Mon Sep 17 00:00:00 2001 From: "david.jones" Date: Tue, 13 Apr 2021 15:34:43 +0100 Subject: [PATCH 4/4] add logo for name change --- .../images/integrations_logos/bigpanda_saas.png | Bin 0 -> 3484 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/images/integrations_logos/bigpanda_saas.png diff --git a/static/images/integrations_logos/bigpanda_saas.png b/static/images/integrations_logos/bigpanda_saas.png new file mode 100644 index 0000000000000000000000000000000000000000..7c31296af95d52b2d0efa84fdaac77e6f5532694 GIT binary patch literal 3484 zcmbVP2~-nV7Oen-fY`V;f;tot5zs6Zl8{6qgb-yBMZkpykt9`tC|O7X35pOmY#VG8 zZ~;-!5ygc?97R9@9V5_q7azA{du&$Lsg#tYs3>JoQPKOM-m2T>;o*{*GryfO#aJN^ zJ8~$I7aV{JA>bD+p_APQ_Lrd@L#dm;8~`TI&^{O-Eqyis=mSE(^@{agD;Ru<2+xHj zJOr;2Nl`QaI6A4MT>fT60rHR#p_qw%T~dYxg)kGlj^ai1lCqIdq1zT2;=5&~AAiec zJ{`t7Ed?D_43t2GD7c_X6egB4R7~s`F9U6BhY47445HY~#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