-
Notifications
You must be signed in to change notification settings - Fork 184
Docs: add reusable markdown fences for Holmes toolset configuration #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| """ | ||
| Custom fence processors for MkDocs documentation. | ||
|
|
||
| Fences available: | ||
| - yaml-toolset-config: Creates 3 tabs (Holmes CLI, Holmes Helm Chart, Robusta Helm Chart) for toolset configurations | ||
| - yaml-helm-values: Creates 2 tabs (Holmes Helm Chart, Robusta Helm Chart) for Helm-only configurations like permissions | ||
| """ | ||
|
|
||
| import html | ||
| import uuid | ||
|
|
||
|
|
||
| def toolset_config_fence_format(source, language, css_class, options, md, **kwargs): | ||
| """ | ||
| Format YAML content into Holmes CLI, Holmes Helm Chart, and Robusta Helm Chart tabs for toolset configuration. | ||
| This fence does NOT process Jinja2, so {{ env.VAR }} stays as-is. | ||
| """ | ||
| # Generate unique IDs for this tab group to prevent conflicts | ||
| tab_group_id = str(uuid.uuid4()).replace("-", "_") | ||
| tab_id_1 = f"__tabbed_{tab_group_id}_1" | ||
| tab_id_2 = f"__tabbed_{tab_group_id}_2" | ||
| tab_id_3 = f"__tabbed_{tab_group_id}_3" | ||
| group_name = f"__tabbed_{tab_group_id}" | ||
|
|
||
| # Escape HTML in the source to prevent XSS | ||
| escaped_source = html.escape(source) | ||
|
|
||
| # Strip any leading/trailing whitespace | ||
| yaml_content = source.strip() | ||
|
|
||
| # Indent the yaml content for Robusta (add 2 spaces to each line under holmes:) | ||
pavangudiwada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| robusta_yaml_lines = yaml_content.split("\n") | ||
| robusta_yaml_indented = "\n".join( | ||
| " " + line if line else "" for line in robusta_yaml_lines | ||
| ) | ||
|
|
||
| # Build the tabbed HTML structure for CLI, Holmes Helm, and Robusta | ||
| tabs_html = f""" | ||
| <div class="tabbed-set" data-tabs="1:3"> | ||
| <input checked="checked" id="{tab_id_1}" name="{group_name}" type="radio"> | ||
| <input id="{tab_id_2}" name="{group_name}" type="radio"> | ||
| <input id="{tab_id_3}" name="{group_name}" type="radio"> | ||
| <div class="tabbed-labels"> | ||
| <label for="{tab_id_1}">Holmes CLI</label> | ||
| <label for="{tab_id_2}">Holmes Helm Chart</label> | ||
| <label for="{tab_id_3}">Robusta Helm Chart</label> | ||
| </div> | ||
| <div class="tabbed-content"> | ||
| <div class="tabbed-block"> | ||
| <p>Add the following to <strong>~/.holmes/config.yaml</strong>. Create the file if it doesn't exist:</p> | ||
| <pre><code class="language-yaml">{escaped_source}</code></pre> | ||
| </div> | ||
| <div class="tabbed-block"> | ||
| <p>When using the <strong>standalone Holmes Helm Chart</strong>, update your <code>values.yaml</code>:</p> | ||
| <pre><code class="language-yaml">{escaped_source}</code></pre> | ||
| <p>Apply the configuration:</p> | ||
| <pre><code class="language-bash">helm upgrade holmes holmes/holmes --values=values.yaml</code></pre> | ||
| </div> | ||
| <div class="tabbed-block"> | ||
| <p>When using the <strong>Robusta Helm Chart</strong> (which includes HolmesGPT), update your <code>generated_values.yaml</code>:</p> | ||
| <pre><code class="language-yaml">holmes: | ||
| {html.escape(robusta_yaml_indented)}</code></pre> | ||
| <p>Apply the configuration:</p> | ||
| <pre><code class="language-bash">helm upgrade robusta robusta/robusta --values=generated_values.yaml --set clusterName=<YOUR_CLUSTER_NAME></code></pre> | ||
| </div> | ||
| </div> | ||
| </div>""" | ||
|
|
||
| return tabs_html | ||
|
|
||
|
|
||
| def helm_tabs_fence_format(source, language, css_class, options, md, **kwargs): | ||
| """ | ||
| Format YAML content into Holmes and Robusta Helm Chart tabs. | ||
| This fence does NOT process Jinja2, so {{ env.VAR }} stays as-is. | ||
| """ | ||
| # Generate unique IDs for this tab group to prevent conflicts | ||
| tab_group_id = str(uuid.uuid4()).replace("-", "_") | ||
| tab_id_1 = f"__tabbed_{tab_group_id}_1" | ||
| tab_id_2 = f"__tabbed_{tab_group_id}_2" | ||
| group_name = f"__tabbed_{tab_group_id}" | ||
|
|
||
| # Escape HTML in the source to prevent XSS | ||
| escaped_source = html.escape(source) | ||
|
|
||
| # Strip any leading/trailing whitespace | ||
| yaml_content = source.strip() | ||
|
|
||
| # Indent the yaml content for Robusta (add 2 spaces to each line) | ||
| robusta_yaml_lines = yaml_content.split("\n") | ||
| robusta_yaml_indented = "\n".join( | ||
| " " + line if line else "" for line in robusta_yaml_lines | ||
| ) | ||
|
|
||
| # Build the tabbed HTML structure | ||
| tabs_html = f""" | ||
| <div class="tabbed-set" data-tabs="1:2"> | ||
| <input checked="checked" id="{tab_id_1}" name="{group_name}" type="radio"> | ||
| <input id="{tab_id_2}" name="{group_name}" type="radio"> | ||
| <div class="tabbed-labels"> | ||
| <label for="{tab_id_1}">Holmes Helm Chart</label> | ||
| <label for="{tab_id_2}">Robusta Helm Chart</label> | ||
| </div> | ||
| <div class="tabbed-content"> | ||
| <div class="tabbed-block"> | ||
| <p>When using the <strong>standalone Holmes Helm Chart</strong>, update your <code>values.yaml</code>:</p> | ||
| <pre><code class="language-yaml">{escaped_source}</code></pre> | ||
| <p>Apply the configuration:</p> | ||
| <pre><code class="language-bash">helm upgrade holmes holmes/holmes --values=values.yaml</code></pre> | ||
| </div> | ||
| <div class="tabbed-block"> | ||
| <p>When using the <strong>Robusta Helm Chart</strong> (which includes HolmesGPT), update your <code>generated_values.yaml</code> (note: add the <code>holmes:</code> prefix):</p> | ||
| <pre><code class="language-yaml">enableHolmesGPT: true | ||
| holmes: | ||
| {html.escape(robusta_yaml_indented)}</code></pre> | ||
| <p>Apply the configuration:</p> | ||
| <pre><code class="language-bash">helm upgrade robusta robusta/robusta --values=generated_values.yaml --set clusterName=<YOUR_CLUSTER_NAME></code></pre> | ||
| </div> | ||
| </div> | ||
| </div>""" | ||
|
|
||
| return tabs_html | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.