Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-velonis1 committed Jul 24, 2024
2 parents 53512e4 + f90b2d9 commit 17663cb
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,14 @@ <h3>Step-by-step instructions</h3>
<li>Once the environment is active, install packages using <code>pip install &lt;some package&gt;</code>.</li>
<li> Provide a path to the Python executable that is based on your virtual environment so <MadCap:variable name="General.Liquibase" /> can recognize the environment.<br /><code>liquibase --script-python-executable-path ./your/path/to/venv/bin/python checks run --check-name MySweetPythonCheck --checks-scripts-enabled --checks-scope database</code></li>
</ol>
<ol>
<li>Create a virtual environment in your directory that contains the custom policy check script by running the following in the CLI:<p><code>python -m venv &lt;path to your venv&gt;</code></p></li>
<li>Install the package by running <code>pip install liquibase-checks-python</code> in the CLI.</li>
<li>Navigate to the location where you import <code>liquibase_utilities</code> and replace <code>import liquibase_utilities</code> with <code>from liquibase_checks_python import liquibase_utilities</code> in your Python script.<br />Now the Python package that includes the helper scripts is activated.<br /></li>
<li>Next you will call on a specific helper script.<br />In this example we will run <code>logger = liquibase_utilities.get_logger</code></li>
<li>When the check runs it will retrieve any content it finds based on the criteria you asked for and display it in the CLI.</li>
</ol>
<h2>Install the Python package</h2>
<p><MadCap:variable name="General.Liquibase" /> provides a Python package called <code>liquibase-checks-python</code> to assist with in-IDE documentation and auto complete with your helper scripts. Install our Python package by following these instructions.</p>
<p>Now that you've configured and ran a standard custom policy check you're ready to cover using the Python package. <MadCap:variable name="General.Liquibase" /> provides a Python package called <code>liquibase-checks-python</code> to assist with in-IDE documentation and auto complete with your helper scripts. Install our Python package by following these instructions.</p>
<p>If&#160;you want the custom policy check helper scripts <b>with in-IDE documentation and auto-complete</b>, you must complete the <b>Install the Python package</b> steps first. If you want the custom policy check helper scripts <b>without those features</b>, skip that section and follow the <b>Access helper scripts</b> steps.</p>
<h3>Step-by-step</h3>
<h3>Install the Python package step-by-step</h3>
<p>This option allows you to enhance your checks further with usage of specific items within the Python package.</p>
<ol>
<li>Create a virtual environment in your directory that contains the custom policy check script by running the following in the CLI:<p><code>python -m venv &lt;path to your venv&gt;</code></p></li>
<li>Install the Python package by running <code>pip install liquibase-checks-python</code> in the CLI.</li>
<li>In your custom policy check file, replace <code>import liquibase_utilities</code> with <code>from liquibase_checks_python import liquibase_utilities</code> in your Python script.<br /><ol><li><MadCap:codeSnippet><MadCap:codeSnippetCopyButton /><MadCap:codeSnippetBody MadCap:useLineNumbers="False" MadCap:lineNumberStart="1" MadCap:continue="False" xml:space="preserve" style="mc-code-lang: Python;">import sys # useful for indicating a check has been triggered
<li>In your virtual environment, install the Python package by running <code>pip install liquibase-checks-python</code> in the CLI.</li>
<li>In your custom policy check file, replace <code>import liquibase_utilities</code> with <code>from liquibase_checks_python import liquibase_utilities</code> in your Python script.<br /><MadCap:codeSnippet><MadCap:codeSnippetCopyButton /><MadCap:codeSnippetBody MadCap:useLineNumbers="False" MadCap:lineNumberStart="1" MadCap:continue="False" xml:space="preserve" style="mc-code-lang: Python;">import sys # useful for indicating a check has been triggered
from liquibase_checks_python import liquibase_utilities as lb # this is where we are importing our liquibase_utilities helper script provided by the liquibase-checks-python package

obj = lb.get_database_object() # this gets the database object the liquibase policy check is examining
Expand All @@ -61,7 +54,15 @@ <h3>Step-by-step</h3>
if lb.is_table(obj): # function provided from liquibase utilities
status.fired = True # indicates the custom check has been triggered
status.message = No tables allowed! # set the message of the custom check, which liquibase will return
sys.exit(1) # exit from the check</MadCap:codeSnippetBody></MadCap:codeSnippet></li></ol>You have successfully activated the Checks Python package. Next you will go over usage of our helper scripts.</li>
sys.exit(1) # exit from the check</MadCap:codeSnippetBody></MadCap:codeSnippet><p>You have successfully activated the Checks Python package. Next you will go over usage of our helper scripts.</p></li>
</ol>
<h3>Install the Python package and import tools step-by-step</h3>
<p>This option allows you to enhance your checks further with usage of specific items within the Python package.</p>
<ol>
<li>In your virtual environment, install the package by running <code>pip install liquibase-checks-python</code> in the CLI.</li>
<li>Navigate to the location where you import <code>liquibase_utilities</code> and replace <code>import liquibase_utilities</code> with <code>from liquibase_checks_python import liquibase_utilities</code> in your Python script.<br />Now the Python package that includes the helper scripts is activated.<br /></li>
<li>Next you will call on a specific helper script.<br />In this example we will run <code>logger = liquibase_utilities.get_logger</code></li>
<li>When the check runs it will retrieve any content it finds based on the criteria you asked for and display it in the CLI.</li>
</ol>
<h2>Access helper scripts</h2>
<h3>Step-by-step</h3>
Expand Down

0 comments on commit 17663cb

Please sign in to comment.