Skip to content

Commit

Permalink
Download configuration files from git during run time
Browse files Browse the repository at this point in the history
Take all env vars as optional arguments during class initialization
  • Loading branch information
dormant-user committed Jan 4, 2022
1 parent be03d70 commit 6d1632c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 132 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change Log
==========

0.2.6 (01/04/2022)
------------------
- Download configuration files from git during run time
- Take all env vars as optional arguments during class initialization

0.2.5 (01/04/2022)
------------------
- Move configuration files into a dedicated directory

0.2.4 (01/03/2022)
------------------
- Fix `requirements.txt` path in `setup.py`
Expand Down
1 change: 1 addition & 0 deletions doc_generator/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys

sys.path.insert(0, os.path.abspath(f'..{os.path.sep}expose'))
sys.path.insert(0, os.path.abspath('..'))

# -- Project information -----------------------------------------------------

Expand Down
31 changes: 12 additions & 19 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h1>Welcome to Expose’s documentation!<a class="headerlink" href="#welcome-to-
<span id="expose-main-module"></span><h1>Expose - Main Module<a class="headerlink" href="#module-tunnel" title="Permalink to this headline"></a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="tunnel.Tunnel">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tunnel.</span></span><span class="sig-name descname"><span class="pre">Tunnel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">aws_access_key</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aws_secret_key</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aws_region_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'us-west-2'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tunnel.Tunnel" title="Permalink to this definition"></a></dt>
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tunnel.</span></span><span class="sig-name descname"><span class="pre">Tunnel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">aws_access_key</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aws_secret_key</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">aws_region_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'us-west-2'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">image_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subdomain</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tunnel.Tunnel" title="Permalink to this definition"></a></dt>
<dd><p>Initiates <code class="docutils literal notranslate"><span class="pre">Tunnel</span></code> object to spin up an EC2 instance with a pre-configured AMI which acts as a tunnel.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Tunnel</span>
</pre></div>
Expand All @@ -72,6 +72,10 @@ <h1>Welcome to Expose’s documentation!<a class="headerlink" href="#welcome-to-
<li><p><strong>aws_access_key</strong> – Access token for AWS account.</p></li>
<li><p><strong>aws_secret_key</strong> – Secret ID for AWS account.</p></li>
<li><p><strong>aws_region_name</strong> – Region where the instance should live. Defaults to <code class="docutils literal notranslate"><span class="pre">us-west-2</span></code></p></li>
<li><p><strong>image_id</strong> – Takes image ID as an argument. Defaults to <code class="docutils literal notranslate"><span class="pre">ami_id</span></code> in environment variable.</p></li>
<li><p><strong>port</strong> – Port number where the application/API is running in localhost.</p></li>
<li><p><strong>domain_name</strong> – Name of the hosted zone in which an <code class="docutils literal notranslate"><span class="pre">A</span></code> record has to be added. [<code class="docutils literal notranslate"><span class="pre">example.com</span></code>]</p></li>
<li><p><strong>subdomain</strong> – Subdomain using which the localhost has to be accessed. [<code class="docutils literal notranslate"><span class="pre">tunnel</span></code> or <code class="docutils literal notranslate"><span class="pre">tunnel.example.com</span></code>]</p></li>
</ul>
</dd>
</dl>
Expand Down Expand Up @@ -143,17 +147,14 @@ <h1>Welcome to Expose’s documentation!<a class="headerlink" href="#welcome-to-

<dl class="py method">
<dt class="sig sig-object py" id="tunnel.Tunnel._create_ec2_instance">
<span class="sig-name descname"><span class="pre">_create_ec2_instance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">image_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#tunnel.Tunnel._create_ec2_instance" title="Permalink to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">_create_ec2_instance</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#tunnel.Tunnel._create_ec2_instance" title="Permalink to this definition"></a></dt>
<dd><p>Creates an EC2 instance of type <code class="docutils literal notranslate"><span class="pre">t2.nano</span></code> with the pre-configured AMI id.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>image_id</strong> – Takes image ID as an argument. Defaults to <code class="docutils literal notranslate"><span class="pre">ami_id</span></code> in environment variable. Exits if <cite>null</cite>.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Instance ID.</p>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Instance ID.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>str or None</p>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>str or None</p>
</dd>
</dl>
</dd></dl>
Expand Down Expand Up @@ -225,27 +226,19 @@ <h1>Welcome to Expose’s documentation!<a class="headerlink" href="#welcome-to-

<dl class="py method">
<dt class="sig sig-object py" id="tunnel.Tunnel.start">
<span class="sig-name descname"><span class="pre">start</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#tunnel.Tunnel.start" title="Permalink to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">start</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#tunnel.Tunnel.start" title="Permalink to this definition"></a></dt>
<dd><p>Calls the class methods <code class="docutils literal notranslate"><span class="pre">_create_ec2_instance</span></code> and <code class="docutils literal notranslate"><span class="pre">_instance_info</span></code> to configure the ec2 instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>port</strong> – Port number where the application/API is running in localhost.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tunnel.Tunnel._configure_vm">
<span class="sig-name descname"><span class="pre">_configure_vm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">public_dns</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">public_ip</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subdomain</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tunnel.Tunnel._configure_vm" title="Permalink to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">_configure_vm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">public_dns</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">public_ip</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tunnel.Tunnel._configure_vm" title="Permalink to this definition"></a></dt>
<dd><p>Configures the ec2 instance to take traffic from localhost.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>public_dns</strong> – Public DNS name of the EC2 that was created.</p></li>
<li><p><strong>public_ip</strong> – Public IP of the EC2 that was created.</p></li>
<li><p><strong>port</strong> – Port number on which the app/api is running.</p></li>
<li><p><strong>domain_name</strong> – Name of the hosted zone in which an <code class="docutils literal notranslate"><span class="pre">A</span></code> record has to be added. [<code class="docutils literal notranslate"><span class="pre">example.com</span></code>]</p></li>
<li><p><strong>subdomain</strong> – Subdomain using which the localhost has to be accessed. [<code class="docutils literal notranslate"><span class="pre">tunnel</span></code> or <code class="docutils literal notranslate"><span class="pre">tunnel.example.com</span></code>]</p></li>
</ul>
</dd>
</dl>
Expand Down
Loading

0 comments on commit 6d1632c

Please sign in to comment.