Skip to content
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

Create a macro for environment variables #1501

Open
sdelamo opened this issue Oct 11, 2024 · 0 comments · May be fixed by #1513
Open

Create a macro for environment variables #1501

sdelamo opened this issue Oct 11, 2024 · 0 comments · May be fixed by #1513
Assignees

Comments

@sdelamo
Copy link
Contributor

sdelamo commented Oct 11, 2024

We will need a macro for outputting environment variables.

see: https://graal.cloud/gdk/gdk-modules/database/micronaut-autonomous-database-oci/?buildTool=gradle&lang=java&system=linux

CleanShot 2024-10-11 at 12 11 10@2x

Maybe the guide write could write something like:

@envs[DATASOURCES_DEFAULT_OCID,<ocid>,DATASOURCES_DEFAULT_WALLET_PASSWORD,<wallet_password>, DATASOURCES_DEFAULT_USERNAME,<username>,DATASOURCES_DEFAULT_PASSWORD,<password>]

We could generate this HTML as in GDK Views:

<div class="tabs-doc ui-tabs ui-corner-all ui-widget ui-widget-content" data-name="system"><ul role="tablist" class="ui-tabs-nav ui-corner-all ui-helper-reset ui-helper-clearfix ui-widget-header"><li role="tab" tabindex="0" class="ui-tabs-tab ui-corner-top ui-state-default ui-tabs-active ui-state-active" aria-controls="linux" aria-labelledby="ui-id-9" aria-selected="true" aria-expanded="true"><a href="#linux" tabindex="-1" class="ui-tabs-anchor" id="ui-id-9">Linux &amp; macOS</a></li><li role="tab" tabindex="-1" class="ui-tabs-tab ui-corner-top ui-state-default" aria-controls="windows" aria-labelledby="ui-id-10" aria-selected="false" aria-expanded="false"><a href="#windows" tabindex="-1" class="ui-tabs-anchor" id="ui-id-10">Windows</a></li><li role="tab" tabindex="-1" class="ui-tabs-tab ui-corner-top ui-state-default" aria-controls="windows-powershell" aria-labelledby="ui-id-11" aria-selected="false" aria-expanded="false"><a href="#windows-powershell" tabindex="-1" class="ui-tabs-anchor" id="ui-id-11">Windows PowerShell</a></li></ul>
    <div data-value="linux" data-label="Linux &amp; macOS" id="linux" aria-labelledby="ui-id-9" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="false" style="">
      <pre><code class="language-bash hljs" data-highlighted="yes"><span class="hljs-built_in">export</span> DATASOURCES_DEFAULT_OCID=&lt;ocid&gt; <span class="hljs-comment"># 1</span>
<span class="hljs-built_in">export</span> DATASOURCES_DEFAULT_WALLET_PASSWORD=&lt;wallet_password&gt; <span class="hljs-comment"># 2</span>
<span class="hljs-built_in">export</span> DATASOURCES_DEFAULT_USERNAME=&lt;username&gt; <span class="hljs-comment"># 3</span>
<span class="hljs-built_in">export</span> DATASOURCES_DEFAULT_PASSWORD=&lt;password&gt; <span class="hljs-comment"># 4</span></code><button>Copy</button></pre>
   </div>
   <div data-value="windows" data-label="Windows" id="windows" aria-labelledby="ui-id-10" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="true" style="display: none;">
      <pre><code class="language-bash hljs" data-highlighted="yes"><span class="hljs-built_in">set</span> DATASOURCES_DEFAULT_OCID=&lt;ocid&gt; <span class="hljs-comment"># 1</span>
<span class="hljs-built_in">set</span> DATASOURCES_DEFAULT_WALLET_PASSWORD=&lt;wallet_password&gt; <span class="hljs-comment"># 2</span>
<span class="hljs-built_in">set</span> DATASOURCES_DEFAULT_USERNAME=&lt;username&gt; <span class="hljs-comment"># 3</span>
<span class="hljs-built_in">set</span> DATASOURCES_DEFAULT_PASSWORD=&lt;password&gt; <span class="hljs-comment"># 4</span></code><button>Copy</button></pre>
   </div>
   <div data-value="windows-powershell" data-label="Windows PowerShell" id="windows-powershell" aria-labelledby="ui-id-11" role="tabpanel" class="ui-tabs-panel ui-corner-bottom ui-widget-content" aria-hidden="true" style="display: none;">
      <pre><code class="language-bash hljs" data-highlighted="yes"><span class="hljs-variable">$ENV</span>:DATASOURCES_DEFAULT_OCID = <span class="hljs-string">"&lt;ocid&gt;"</span> <span class="hljs-comment"># 1</span>
<span class="hljs-variable">$ENV</span>:DATASOURCES_DEFAULT_WALLET_PASSWORD = <span class="hljs-string">"&lt;wallet_password&gt;"</span> <span class="hljs-comment"># 2</span>
<span class="hljs-variable">$ENV</span>:DATASOURCES_DEFAULT_USERNAME = <span class="hljs-string">"&lt;username&gt;"</span> <span class="hljs-comment"># 3</span>
<span class="hljs-variable">$ENV</span>:DATASOURCES_DEFAULT_PASSWORD = <span class="hljs-string">"&lt;password&gt;"</span> <span class="hljs-comment"># 4</span></code><button>Copy</button></pre>
   </div>
</div>

We could create an interface

interface EnvironmentVariablesMacroRenderer

and an implementation (this will allow consumers of the API the possibility to customise the rendering of their macro to their needs.

@Singleton
class DefaultEnvironmentVariablesMacroRenderer implements EnvironmentVariablesMacroRenderer {

We could use Micronaut Views to generate the HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants