<a href="https://github.com/binbashar">
<img src="https://raw.githubusercontent.com/binbashar/le-ref-architecture-doc/master/docs/assets/images/logos/binbash-leverage-banner.png" width="1032" align="left" alt="Binbash"/>
</a>
<br clear="left"/>
# Leverage CLI
Leverage CLI is the tool used to manage and interact with any Leverage project.
It transparently handles the most complex and error prone tasks that arise from working with a state-of-the-art
infrastructure definition like our Leverage Reference Architecture. Leverage CLI uses a dockerized approach to
encapsulate the tools needed to perform such tasks and to free the user from having to deal with the configuration and
management of said tools.
Provides the means to interact with your Leverage project and allows you to define custom tasks to run.
Reviewing and implementing the [Binbash Leverage Landing Zone for AWS](https://leverage.binbash.co/try-leverage/) would
be a very good place to start!
## Documentation
For installation instructions and all documentation regarding Leverage CLI, please refer
to [this page](https://leverage.binbash.co/user-guide/leverage-cli/installation/).
### Note for migration from previous versions
If you come from Leverage CLI version <1.8.0 and want to install Leverage CLI version >= 1.8.0 keep into account the
following.
The `build.env` file format has changed. As an example, this is the old format:
```
# Project settings
PROJECT=bb
# General
MFA_ENABLED=false
# Terraform
TERRAFORM_IMAGE_NAME=binbash/terraform-awscli-slim
TERRAFORM_IMAGE_TAG=1.1.9
```
New version example:
```
# Project settings
PROJECT=bb
# General
MFA_ENABLED=false
# Terraform
TERRAFORM_IMAGE_TAG=1.2.7-0.1.0
```
So, if you have created a project with version <1.8.0 and want to use it with version >=1.8.0 you should:
- remove TERRAFORM_IMAGE_NAME line
- update TERRAFORM_IMAGE_TAG from this form '9.9.9' to this one '9.9.9-9.9.9'.
For the second item you can check the version [here](https://hub.docker.com/r/binbash/leverage-toolbox/tags).
## System requirements
### Supported python versions
Leverage CLI explicitly supports the following Python versions:
- Python 3.8.x
- Python 3.9.x
- Python 3.10.x
- Python 3.11.x
These versions are not only supported but are also the only versions used in our CI/CD pipelines to ensure compatibility
and performance. This rigorous testing helps prevent compatibility issues and ensures that the Leverage CLI performs as
expected under these versions.
Please ensure that your development and deployment environments are set up with one of these supported versions. Our
GitHub Actions and other CI workflows are specifically configured to test against these Python versions, which
reinforces our commitment to maintaining a reliable and stable toolset.
### Installing multiple python versions with pyenv
If you need to install one of the supported Python versions (3.8, 3.9, 3.10 or 3.11) and would like to manage multiple
Python environments, `pyenv` is a highly recommended tool. Here’s how you can use `pyenv` to install and manage Python
versions:
1. Installing Pyenv:
```bash
curl https://pyenv.run | bash
```
2. Add Pyenv to your shell to automate the setup process (if using bash, otherwise you can find details on how to set it
up [here](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)):
```bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
exec "$SHELL"
```
3. Installing python versions:
Once pyenv is installed, you can install any supported Python version by following these steps:
```bash
pyenv install 3.8.10
pyenv install 3.9.7
pyenv install 3.10.1
pyenv install 3.11.8
```
4. Create a virtual environment for the leverage project:
Create a virtual environment for your project using Python 3.9.7:
```bash
pyenv virtualenv 3.9.7 leverage_py_39_venv
```
5. Set your virtual environment to be used in the project:
To set this virtual environment as the local environment for your project, navigate to your project directory and run:
```bash
cd <path_to_leverage_project_root>
pyenv local leverage_py_39_venv
```
This setup commands `pyenv` to use `leverage_py_39_venv` as the local Python version for your project directory,
ensuring that all Python operations within this directory use this isolated environment.
## Setting up development environment
Before you begin, ensure you are running Python 3.8, 3.9, or 3.10 as these are the only versions Leverage CLI supports
and tests against.
We now use Poetry for dependency management. Setup your development environment as follows:
1. Install Poetry:
```bash
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -
```
2. Clone the repository and navigate into it:
```bash
git clone https://github.com/binbashar/leverage.git
cd leverage
```
3. Install dependencies using Poetry:
```bash
poetry install --with=dev --with=main
```
4. To activate the virtual environment and start using the CLI in dev mode, use:
```bash
poetry shell
```
## Pre-commit hooks
In order to run black automatically on every commit, you should install `pre-commit` first:
https://pre-commit.com/#installation
And then the hooks:
```
poetry run pre-commit install
```
## Running Tests
To run unit tests, pytest is the tool of choice, and the required dependencies are available in the
corresponding `dev-requirements.txt`.
Integration tests are implemented using [bats](https://github.com/bats-core/bats-core/). Bear in mind that bats tests
are meant to be run in a throwaway environment since they perform filesystem manipulations and installation and removal
of packages, and the cleanup may not be completely thorough. As such, is highly recommended to run these tests using the
docker image.
### Manually
1. Unit tests:
```bash
poetry run pytest
```
2. Integration tests:
Install dependencies (MacOS):
```bash
brew install bats-core
brew tap bats-core/bats-core
brew install bats-support
brew install bats-assert
```
```bash
bats -r tests/bats
```
### Using docker image
A Docker image suitable for running all tests can be crafted by running `make build-image`. After crafting the image all
tests can be executed.
To run all tests, run `make tests`. Alternatively `make test-unit` or `make test-int` for unit or integration tests
respectively.
## Release Process
* On every PR, a Github Action workflow is triggered to create/update a release draft.
* The version number is determined by the labels of those PRs (major, minor, fix).
* The release draft has to be manually published. This allows for any number of PR (features, fixes) to make the cut.
* Once a release is published, another workflow is triggered to create and push the package to PyPi.
## Release Candidate Process
* There is an Action called "Test Build Package and Push".
* This Action can be called manually on any branch specifying the version to release to test.
* The version is a Release Candidate following the Semver: e.g. if the next release is 1.2.3, the test version
should be 1.2.3-rc.1
* The package will be published to [PyPi](https://pypi.org/project/leverage/).
## Contributors/Contributing
* Leverage CLI was initially based on Pynt: https://github.com/rags/pynt
## License
Leverage CLI is licensed
under [MIT license](http://opensource.org/licenses/MIT)[BinBash Inc](https://github.com/binbashar)
Raw data
{
"_id": null,
"home_page": "https://github.com/binbashar/leverage",
"name": "leverage",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.8",
"maintainer_email": null,
"keywords": "leverage, binbash",
"author": "BinBash Inc",
"author_email": "leverage@binbash.com.ar",
"download_url": "https://files.pythonhosted.org/packages/df/c2/444c51c2723a7844670e0fb6db0c39fc9d8f38a08c195f928fece6a7ff96/leverage-1.13.0.tar.gz",
"platform": null,
"description": "<a href=\"https://github.com/binbashar\">\n <img src=\"https://raw.githubusercontent.com/binbashar/le-ref-architecture-doc/master/docs/assets/images/logos/binbash-leverage-banner.png\" width=\"1032\" align=\"left\" alt=\"Binbash\"/>\n</a>\n<br clear=\"left\"/>\n\n# Leverage CLI\n\nLeverage CLI is the tool used to manage and interact with any Leverage project.\n\nIt transparently handles the most complex and error prone tasks that arise from working with a state-of-the-art\ninfrastructure definition like our Leverage Reference Architecture. Leverage CLI uses a dockerized approach to\nencapsulate the tools needed to perform such tasks and to free the user from having to deal with the configuration and\nmanagement of said tools.\nProvides the means to interact with your Leverage project and allows you to define custom tasks to run.\n\nReviewing and implementing the [Binbash Leverage Landing Zone for AWS](https://leverage.binbash.co/try-leverage/) would\nbe a very good place to start!\n\n## Documentation\n\nFor installation instructions and all documentation regarding Leverage CLI, please refer\nto [this page](https://leverage.binbash.co/user-guide/leverage-cli/installation/).\n\n### Note for migration from previous versions\n\nIf you come from Leverage CLI version <1.8.0 and want to install Leverage CLI version >= 1.8.0 keep into account the\nfollowing.\n\nThe `build.env` file format has changed. As an example, this is the old format:\n\n```\n# Project settings\nPROJECT=bb\n\n# General\nMFA_ENABLED=false\n\n# Terraform\nTERRAFORM_IMAGE_NAME=binbash/terraform-awscli-slim\nTERRAFORM_IMAGE_TAG=1.1.9\n```\n\nNew version example:\n\n```\n# Project settings\nPROJECT=bb\n\n# General\nMFA_ENABLED=false\n\n# Terraform\nTERRAFORM_IMAGE_TAG=1.2.7-0.1.0\n```\n\nSo, if you have created a project with version <1.8.0 and want to use it with version >=1.8.0 you should:\n\n- remove TERRAFORM_IMAGE_NAME line\n- update TERRAFORM_IMAGE_TAG from this form '9.9.9' to this one '9.9.9-9.9.9'.\n\nFor the second item you can check the version [here](https://hub.docker.com/r/binbash/leverage-toolbox/tags).\n\n## System requirements\n\n### Supported python versions\n\nLeverage CLI explicitly supports the following Python versions:\n\n- Python 3.8.x\n- Python 3.9.x\n- Python 3.10.x\n- Python 3.11.x\n\nThese versions are not only supported but are also the only versions used in our CI/CD pipelines to ensure compatibility\nand performance. This rigorous testing helps prevent compatibility issues and ensures that the Leverage CLI performs as\nexpected under these versions.\n\nPlease ensure that your development and deployment environments are set up with one of these supported versions. Our\nGitHub Actions and other CI workflows are specifically configured to test against these Python versions, which\nreinforces our commitment to maintaining a reliable and stable toolset.\n\n### Installing multiple python versions with pyenv\n\nIf you need to install one of the supported Python versions (3.8, 3.9, 3.10 or 3.11) and would like to manage multiple\nPython environments, `pyenv` is a highly recommended tool. Here\u2019s how you can use `pyenv` to install and manage Python\nversions:\n\n1. Installing Pyenv:\n\n```bash\ncurl https://pyenv.run | bash\n```\n\n2. Add Pyenv to your shell to automate the setup process (if using bash, otherwise you can find details on how to set it\n up [here](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)):\n\n```bash\necho 'export PYENV_ROOT=\"$HOME/.pyenv\"' >> ~/.bashrc\necho 'export PATH=\"$PYENV_ROOT/bin:$PATH\"' >> ~/.bashrc\necho 'eval \"$(pyenv init --path)\"' >> ~/.bashrc\necho 'eval \"$(pyenv virtualenv-init -)\"' >> ~/.bashrc\nexec \"$SHELL\"\n```\n\n3. Installing python versions:\n\nOnce pyenv is installed, you can install any supported Python version by following these steps:\n\n```bash\npyenv install 3.8.10\npyenv install 3.9.7\npyenv install 3.10.1\npyenv install 3.11.8\n```\n\n4. Create a virtual environment for the leverage project:\n\nCreate a virtual environment for your project using Python 3.9.7:\n\n```bash\npyenv virtualenv 3.9.7 leverage_py_39_venv\n```\n\n5. Set your virtual environment to be used in the project:\n\nTo set this virtual environment as the local environment for your project, navigate to your project directory and run:\n\n```bash\ncd <path_to_leverage_project_root>\npyenv local leverage_py_39_venv\n```\n\nThis setup commands `pyenv` to use `leverage_py_39_venv` as the local Python version for your project directory,\nensuring that all Python operations within this directory use this isolated environment.\n\n## Setting up development environment\n\nBefore you begin, ensure you are running Python 3.8, 3.9, or 3.10 as these are the only versions Leverage CLI supports\nand tests against.\n\nWe now use Poetry for dependency management. Setup your development environment as follows:\n\n1. Install Poetry:\n\n```bash\ncurl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -\n```\n\n2. Clone the repository and navigate into it:\n\n```bash\ngit clone https://github.com/binbashar/leverage.git\ncd leverage\n```\n\n3. Install dependencies using Poetry:\n\n```bash\npoetry install --with=dev --with=main\n```\n\n4. To activate the virtual environment and start using the CLI in dev mode, use:\n\n```bash\npoetry shell\n```\n\n## Pre-commit hooks\n\nIn order to run black automatically on every commit, you should install `pre-commit` first:\n\nhttps://pre-commit.com/#installation\n\nAnd then the hooks:\n\n```\npoetry run pre-commit install\n```\n\n## Running Tests\n\nTo run unit tests, pytest is the tool of choice, and the required dependencies are available in the\ncorresponding `dev-requirements.txt`.\n\nIntegration tests are implemented using [bats](https://github.com/bats-core/bats-core/). Bear in mind that bats tests\nare meant to be run in a throwaway environment since they perform filesystem manipulations and installation and removal\nof packages, and the cleanup may not be completely thorough. As such, is highly recommended to run these tests using the\ndocker image.\n\n### Manually\n\n1. Unit tests:\n\n```bash\npoetry run pytest\n```\n\n2. Integration tests:\n\nInstall dependencies (MacOS):\n\n```bash\nbrew install bats-core\nbrew tap bats-core/bats-core\nbrew install bats-support\nbrew install bats-assert\n```\n\n```bash\nbats -r tests/bats\n```\n\n### Using docker image\n\nA Docker image suitable for running all tests can be crafted by running `make build-image`. After crafting the image all\ntests can be executed.\n\nTo run all tests, run `make tests`. Alternatively `make test-unit` or `make test-int` for unit or integration tests\nrespectively.\n\n## Release Process\n\n* On every PR, a Github Action workflow is triggered to create/update a release draft.\n* The version number is determined by the labels of those PRs (major, minor, fix).\n* The release draft has to be manually published. This allows for any number of PR (features, fixes) to make the cut.\n* Once a release is published, another workflow is triggered to create and push the package to PyPi.\n\n## Release Candidate Process\n\n* There is an Action called \"Test Build Package and Push\".\n* This Action can be called manually on any branch specifying the version to release to test.\n * The version is a Release Candidate following the Semver: e.g. if the next release is 1.2.3, the test version\n should be 1.2.3-rc.1\n* The package will be published to [PyPi](https://pypi.org/project/leverage/).\n\n## Contributors/Contributing\n\n* Leverage CLI was initially based on Pynt: https://github.com/rags/pynt\n\n## License\n\nLeverage CLI is licensed\nunder [MIT license](http://opensource.org/licenses/MIT)[BinBash Inc](https://github.com/binbashar)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Binbash Leverage Command-Line tool.",
"version": "1.13.0",
"project_urls": {
"Documentation": "https://leverage.binbash.co/",
"Homepage": "https://github.com/binbashar/leverage",
"Repository": "https://github.com/binbashar/leverage"
},
"split_keywords": [
"leverage",
" binbash"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eff5b3487d084d4f89196ed5d0c33e2b4d7553cb32d02a9353461972f75c8f7f",
"md5": "66079a41a5d84587336b39c256b7074f",
"sha256": "a553444fc53c48e55707d3aadfc60aa4a16c6633fc1c69ca19021225edb0ea0a"
},
"downloads": -1,
"filename": "leverage-1.13.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "66079a41a5d84587336b39c256b7074f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.8",
"size": 56799,
"upload_time": "2024-10-07T19:28:25",
"upload_time_iso_8601": "2024-10-07T19:28:25.474121Z",
"url": "https://files.pythonhosted.org/packages/ef/f5/b3487d084d4f89196ed5d0c33e2b4d7553cb32d02a9353461972f75c8f7f/leverage-1.13.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dfc2444c51c2723a7844670e0fb6db0c39fc9d8f38a08c195f928fece6a7ff96",
"md5": "5ea1ac9d057e92a5a988cffda170b3f6",
"sha256": "81e1bc6b83ab9eb2eeca03cfbc1e664397ccffd2ccfe7aee15a6eae350346c5b"
},
"downloads": -1,
"filename": "leverage-1.13.0.tar.gz",
"has_sig": false,
"md5_digest": "5ea1ac9d057e92a5a988cffda170b3f6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.8",
"size": 49809,
"upload_time": "2024-10-07T19:28:26",
"upload_time_iso_8601": "2024-10-07T19:28:26.744974Z",
"url": "https://files.pythonhosted.org/packages/df/c2/444c51c2723a7844670e0fb6db0c39fc9d8f38a08c195f928fece6a7ff96/leverage-1.13.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-07 19:28:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "binbashar",
"github_project": "leverage",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "leverage"
}