leverage 1.9.2__tar.gz → 1.9.4rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- leverage-1.9.4rc1/PKG-INFO +279 -0
- leverage-1.9.4rc1/README.md +243 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/__init__.py +4 -4
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/_internals.py +8 -7
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/_parsing.py +6 -2
- leverage-1.9.4rc1/leverage/_utils.py +235 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/conf.py +1 -1
- leverage-1.9.4rc1/leverage/container.py +708 -0
- leverage-1.9.4rc1/leverage/containers/kubectl.py +67 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/leverage.py +17 -17
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/logger.py +54 -30
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/modules/__init__.py +2 -2
- leverage-1.9.4rc1/leverage/modules/auth.py +150 -0
- leverage-1.9.4rc1/leverage/modules/aws.py +225 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/modules/credentials.py +213 -192
- leverage-1.9.4rc1/leverage/modules/kubectl.py +36 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/modules/project.py +81 -66
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/modules/run.py +9 -10
- leverage-1.9.4rc1/leverage/modules/shell.py +44 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/modules/terraform.py +212 -119
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/modules/tfautomv.py +10 -12
- leverage-1.9.4rc1/leverage/modules/utils.py +43 -0
- leverage-1.9.4rc1/leverage/path.py +288 -0
- {leverage-1.9.2 → leverage-1.9.4rc1}/leverage/tasks.py +28 -29
- leverage-1.9.4rc1/pyproject.toml +64 -0
- leverage-1.9.2/PKG-INFO +0 -114
- leverage-1.9.2/README.md +0 -89
- leverage-1.9.2/leverage/_utils.py +0 -52
- leverage-1.9.2/leverage/container.py +0 -702
- leverage-1.9.2/leverage/modules/aws.py +0 -206
- leverage-1.9.2/leverage/path.py +0 -124
- leverage-1.9.2/leverage.egg-info/PKG-INFO +0 -114
- leverage-1.9.2/leverage.egg-info/SOURCES.txt +0 -28
- leverage-1.9.2/leverage.egg-info/dependency_links.txt +0 -1
- leverage-1.9.2/leverage.egg-info/entry_points.txt +0 -3
- leverage-1.9.2/leverage.egg-info/requires.txt +0 -9
- leverage-1.9.2/leverage.egg-info/top_level.txt +0 -2
- leverage-1.9.2/pyproject.toml +0 -3
- leverage-1.9.2/setup.cfg +0 -59
- leverage-1.9.2/setup.py +0 -4
- {leverage-1.9.2 → leverage-1.9.4rc1}/LICENSE.txt +0 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: leverage
|
|
3
|
+
Version: 1.9.4rc1
|
|
4
|
+
Summary: Binbash Leverage Command-Line tool.
|
|
5
|
+
Home-page: https://github.com/binbashar/leverage
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: leverage,binbash
|
|
8
|
+
Author: BinBash Inc
|
|
9
|
+
Author-email: leverage@binbash.com.ar
|
|
10
|
+
Requires-Python: >=3.8,<3.12
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
20
|
+
Requires-Dist: boto3 (==1.33.2)
|
|
21
|
+
Requires-Dist: click (==8.0.1)
|
|
22
|
+
Requires-Dist: configupdater (==3.2)
|
|
23
|
+
Requires-Dist: docker (==6.1.0)
|
|
24
|
+
Requires-Dist: dockerpty (==0.4.1)
|
|
25
|
+
Requires-Dist: docutils (==0.17.1)
|
|
26
|
+
Requires-Dist: jinja2 (==3.0.1)
|
|
27
|
+
Requires-Dist: python-hcl2 (==3.0.1)
|
|
28
|
+
Requires-Dist: questionary (==1.10.0)
|
|
29
|
+
Requires-Dist: rich (==10.4.0)
|
|
30
|
+
Requires-Dist: ruamel.yaml (==0.17.10)
|
|
31
|
+
Requires-Dist: yaenv (==1.4.1)
|
|
32
|
+
Project-URL: Documentation, https://leverage.binbash.co/
|
|
33
|
+
Project-URL: Repository, https://github.com/binbashar/leverage
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
<a href="https://github.com/binbashar">
|
|
37
|
+
<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"/>
|
|
38
|
+
</a>
|
|
39
|
+
<br clear="left"/>
|
|
40
|
+
|
|
41
|
+
# Leverage CLI
|
|
42
|
+
|
|
43
|
+
Leverage CLI is the tool used to manage and interact with any Leverage project.
|
|
44
|
+
|
|
45
|
+
It transparently handles the most complex and error prone tasks that arise from working with a state-of-the-art
|
|
46
|
+
infrastructure definition like our Leverage Reference Architecture. Leverage CLI uses a dockerized approach to
|
|
47
|
+
encapsulate the tools needed to perform such tasks and to free the user from having to deal with the configuration and
|
|
48
|
+
management of said tools.
|
|
49
|
+
Provides the means to interact with your Leverage project and allows you to define custom tasks to run.
|
|
50
|
+
|
|
51
|
+
Reviewing and implementing the [Binbash Leverage Landing Zone for AWS](https://leverage.binbash.co/try-leverage/) would
|
|
52
|
+
be a very good place to start!
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
For installation instructions and all documentation regarding Leverage CLI, please refer
|
|
57
|
+
to [this page](https://leverage.binbash.co/user-guide/leverage-cli/installation/).
|
|
58
|
+
|
|
59
|
+
### Note for migration from previous versions
|
|
60
|
+
|
|
61
|
+
If you come from Leverage CLI version <1.8.0 and want to install Leverage CLI version >= 1.8.0 keep into account the
|
|
62
|
+
following.
|
|
63
|
+
|
|
64
|
+
The `build.env` file format has changed. As an example, this is the old format:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
# Project settings
|
|
68
|
+
PROJECT=bb
|
|
69
|
+
|
|
70
|
+
# General
|
|
71
|
+
MFA_ENABLED=false
|
|
72
|
+
|
|
73
|
+
# Terraform
|
|
74
|
+
TERRAFORM_IMAGE_NAME=binbash/terraform-awscli-slim
|
|
75
|
+
TERRAFORM_IMAGE_TAG=1.1.9
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
New version example:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
# Project settings
|
|
82
|
+
PROJECT=bb
|
|
83
|
+
|
|
84
|
+
# General
|
|
85
|
+
MFA_ENABLED=false
|
|
86
|
+
|
|
87
|
+
# Terraform
|
|
88
|
+
TERRAFORM_IMAGE_TAG=1.2.7-0.1.0
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
So, if you have created a project with version <1.8.0 and want to use it with version >=1.8.0 you should:
|
|
92
|
+
|
|
93
|
+
- remove TERRAFORM_IMAGE_NAME line
|
|
94
|
+
- update TERRAFORM_IMAGE_TAG from this form '9.9.9' to this one '9.9.9-9.9.9'.
|
|
95
|
+
|
|
96
|
+
For the second item you can check the version [here](https://hub.docker.com/r/binbash/leverage-toolbox/tags).
|
|
97
|
+
|
|
98
|
+
## System requirements
|
|
99
|
+
|
|
100
|
+
### Supported python versions
|
|
101
|
+
|
|
102
|
+
Leverage CLI explicitly supports the following Python versions:
|
|
103
|
+
|
|
104
|
+
- Python 3.8.x
|
|
105
|
+
- Python 3.9.x
|
|
106
|
+
- Python 3.10.x
|
|
107
|
+
- Python 3.11.x
|
|
108
|
+
|
|
109
|
+
These versions are not only supported but are also the only versions used in our CI/CD pipelines to ensure compatibility
|
|
110
|
+
and performance. This rigorous testing helps prevent compatibility issues and ensures that the Leverage CLI performs as
|
|
111
|
+
expected under these versions.
|
|
112
|
+
|
|
113
|
+
Please ensure that your development and deployment environments are set up with one of these supported versions. Our
|
|
114
|
+
GitHub Actions and other CI workflows are specifically configured to test against these Python versions, which
|
|
115
|
+
reinforces our commitment to maintaining a reliable and stable toolset.
|
|
116
|
+
|
|
117
|
+
### Installing multiple python versions with pyenv
|
|
118
|
+
|
|
119
|
+
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
|
|
120
|
+
Python environments, `pyenv` is a highly recommended tool. Here’s how you can use `pyenv` to install and manage Python
|
|
121
|
+
versions:
|
|
122
|
+
|
|
123
|
+
1. Installing Pyenv:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
curl https://pyenv.run | bash
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
2. Add Pyenv to your shell to automate the setup process (if using bash, otherwise you can find details on how to set it
|
|
130
|
+
up [here](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)):
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
|
134
|
+
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
|
135
|
+
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
|
|
136
|
+
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
|
|
137
|
+
exec "$SHELL"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
3. Installing python versions:
|
|
141
|
+
|
|
142
|
+
Once pyenv is installed, you can install any supported Python version by following these steps:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pyenv install 3.8.10
|
|
146
|
+
pyenv install 3.9.7
|
|
147
|
+
pyenv install 3.10.1
|
|
148
|
+
pyenv install 3.11.8
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
4. Create a virtual environment for the leverage project:
|
|
152
|
+
|
|
153
|
+
Create a virtual environment for your project using Python 3.9.7:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pyenv virtualenv 3.9.7 leverage_py_39_venv
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
5. Set your virtual environment to be used in the project:
|
|
160
|
+
|
|
161
|
+
To set this virtual environment as the local environment for your project, navigate to your project directory and run:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
cd <path_to_leverage_project_root>
|
|
165
|
+
pyenv local leverage_py_39_venv
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This setup commands `pyenv` to use `leverage_py_39_venv` as the local Python version for your project directory,
|
|
169
|
+
ensuring that all Python operations within this directory use this isolated environment.
|
|
170
|
+
|
|
171
|
+
## Setting up development environment
|
|
172
|
+
|
|
173
|
+
Before you begin, ensure you are running Python 3.8, 3.9, or 3.10 as these are the only versions Leverage CLI supports
|
|
174
|
+
and tests against.
|
|
175
|
+
|
|
176
|
+
We now use Poetry for dependency management. Setup your development environment as follows:
|
|
177
|
+
|
|
178
|
+
1. Install Poetry:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
2. Clone the repository and navigate into it:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
git clone https://github.com/binbashar/leverage.git
|
|
188
|
+
cd leverage
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
3. Install dependencies using Poetry:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
poetry install --with=dev --with=main
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
4. To activate the virtual environment and start using the CLI in dev mode, use:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
poetry shell
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Pre-commit hooks
|
|
204
|
+
|
|
205
|
+
In order to run black automatically on every commit, you should install `pre-commit` first:
|
|
206
|
+
|
|
207
|
+
https://pre-commit.com/#installation
|
|
208
|
+
|
|
209
|
+
And then the hooks:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
poetry run pre-commit install
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Running Tests
|
|
216
|
+
|
|
217
|
+
To run unit tests, pytest is the tool of choice, and the required dependencies are available in the
|
|
218
|
+
corresponding `dev-requirements.txt`.
|
|
219
|
+
|
|
220
|
+
Integration tests are implemented using [bats](https://github.com/bats-core/bats-core/). Bear in mind that bats tests
|
|
221
|
+
are meant to be run in a throwaway environment since they perform filesystem manipulations and installation and removal
|
|
222
|
+
of packages, and the cleanup may not be completely thorough. As such, is highly recommended to run these tests using the
|
|
223
|
+
docker image.
|
|
224
|
+
|
|
225
|
+
### Manually
|
|
226
|
+
|
|
227
|
+
1. Unit tests:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
poetry run pytest
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
2. Integration tests:
|
|
234
|
+
|
|
235
|
+
Install dependencies (MacOS):
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
brew install bats-core
|
|
239
|
+
brew tap bats-core/bats-core
|
|
240
|
+
brew install bats-support
|
|
241
|
+
brew install bats-assert
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
bats -r tests/bats
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Using docker image
|
|
249
|
+
|
|
250
|
+
A Docker image suitable for running all tests can be crafted by running `make build-image`. After crafting the image all
|
|
251
|
+
tests can be executed.
|
|
252
|
+
|
|
253
|
+
To run all tests, run `make tests`. Alternatively `make test-unit` or `make test-int` for unit or integration tests
|
|
254
|
+
respectively.
|
|
255
|
+
|
|
256
|
+
## Release Process
|
|
257
|
+
|
|
258
|
+
* On every PR, a Github Action workflow is triggered to create/update a release draft.
|
|
259
|
+
* The version number is determined by the labels of those PRs (major, minor, fix).
|
|
260
|
+
* The release draft has to be manually published. This allows for any number of PR (features, fixes) to make the cut.
|
|
261
|
+
* Once a release is published, another workflow is triggered to create and push the package to PyPi.
|
|
262
|
+
|
|
263
|
+
## Release Candidate Process
|
|
264
|
+
|
|
265
|
+
* There is an Action called "Test Build Package and Push".
|
|
266
|
+
* This Action can be called manually on any branch specifying the version to release to test.
|
|
267
|
+
* The version is a Release Candidate following the Semver: e.g. if the next release is 1.2.3, the test version
|
|
268
|
+
should be 1.2.3-rc.1
|
|
269
|
+
* The package will be published to [PyPi](https://pypi.org/project/leverage/).
|
|
270
|
+
|
|
271
|
+
## Contributors/Contributing
|
|
272
|
+
|
|
273
|
+
* Leverage CLI was initially based on Pynt: https://github.com/rags/pynt
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
Leverage CLI is licensed
|
|
278
|
+
under [MIT license](http://opensource.org/licenses/MIT)[BinBash Inc](https://github.com/binbashar)
|
|
279
|
+
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<a href="https://github.com/binbashar">
|
|
2
|
+
<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"/>
|
|
3
|
+
</a>
|
|
4
|
+
<br clear="left"/>
|
|
5
|
+
|
|
6
|
+
# Leverage CLI
|
|
7
|
+
|
|
8
|
+
Leverage CLI is the tool used to manage and interact with any Leverage project.
|
|
9
|
+
|
|
10
|
+
It transparently handles the most complex and error prone tasks that arise from working with a state-of-the-art
|
|
11
|
+
infrastructure definition like our Leverage Reference Architecture. Leverage CLI uses a dockerized approach to
|
|
12
|
+
encapsulate the tools needed to perform such tasks and to free the user from having to deal with the configuration and
|
|
13
|
+
management of said tools.
|
|
14
|
+
Provides the means to interact with your Leverage project and allows you to define custom tasks to run.
|
|
15
|
+
|
|
16
|
+
Reviewing and implementing the [Binbash Leverage Landing Zone for AWS](https://leverage.binbash.co/try-leverage/) would
|
|
17
|
+
be a very good place to start!
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
For installation instructions and all documentation regarding Leverage CLI, please refer
|
|
22
|
+
to [this page](https://leverage.binbash.co/user-guide/leverage-cli/installation/).
|
|
23
|
+
|
|
24
|
+
### Note for migration from previous versions
|
|
25
|
+
|
|
26
|
+
If you come from Leverage CLI version <1.8.0 and want to install Leverage CLI version >= 1.8.0 keep into account the
|
|
27
|
+
following.
|
|
28
|
+
|
|
29
|
+
The `build.env` file format has changed. As an example, this is the old format:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
# Project settings
|
|
33
|
+
PROJECT=bb
|
|
34
|
+
|
|
35
|
+
# General
|
|
36
|
+
MFA_ENABLED=false
|
|
37
|
+
|
|
38
|
+
# Terraform
|
|
39
|
+
TERRAFORM_IMAGE_NAME=binbash/terraform-awscli-slim
|
|
40
|
+
TERRAFORM_IMAGE_TAG=1.1.9
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
New version example:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
# Project settings
|
|
47
|
+
PROJECT=bb
|
|
48
|
+
|
|
49
|
+
# General
|
|
50
|
+
MFA_ENABLED=false
|
|
51
|
+
|
|
52
|
+
# Terraform
|
|
53
|
+
TERRAFORM_IMAGE_TAG=1.2.7-0.1.0
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
So, if you have created a project with version <1.8.0 and want to use it with version >=1.8.0 you should:
|
|
57
|
+
|
|
58
|
+
- remove TERRAFORM_IMAGE_NAME line
|
|
59
|
+
- update TERRAFORM_IMAGE_TAG from this form '9.9.9' to this one '9.9.9-9.9.9'.
|
|
60
|
+
|
|
61
|
+
For the second item you can check the version [here](https://hub.docker.com/r/binbash/leverage-toolbox/tags).
|
|
62
|
+
|
|
63
|
+
## System requirements
|
|
64
|
+
|
|
65
|
+
### Supported python versions
|
|
66
|
+
|
|
67
|
+
Leverage CLI explicitly supports the following Python versions:
|
|
68
|
+
|
|
69
|
+
- Python 3.8.x
|
|
70
|
+
- Python 3.9.x
|
|
71
|
+
- Python 3.10.x
|
|
72
|
+
- Python 3.11.x
|
|
73
|
+
|
|
74
|
+
These versions are not only supported but are also the only versions used in our CI/CD pipelines to ensure compatibility
|
|
75
|
+
and performance. This rigorous testing helps prevent compatibility issues and ensures that the Leverage CLI performs as
|
|
76
|
+
expected under these versions.
|
|
77
|
+
|
|
78
|
+
Please ensure that your development and deployment environments are set up with one of these supported versions. Our
|
|
79
|
+
GitHub Actions and other CI workflows are specifically configured to test against these Python versions, which
|
|
80
|
+
reinforces our commitment to maintaining a reliable and stable toolset.
|
|
81
|
+
|
|
82
|
+
### Installing multiple python versions with pyenv
|
|
83
|
+
|
|
84
|
+
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
|
|
85
|
+
Python environments, `pyenv` is a highly recommended tool. Here’s how you can use `pyenv` to install and manage Python
|
|
86
|
+
versions:
|
|
87
|
+
|
|
88
|
+
1. Installing Pyenv:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
curl https://pyenv.run | bash
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
2. Add Pyenv to your shell to automate the setup process (if using bash, otherwise you can find details on how to set it
|
|
95
|
+
up [here](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)):
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
|
99
|
+
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
|
100
|
+
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
|
|
101
|
+
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
|
|
102
|
+
exec "$SHELL"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
3. Installing python versions:
|
|
106
|
+
|
|
107
|
+
Once pyenv is installed, you can install any supported Python version by following these steps:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pyenv install 3.8.10
|
|
111
|
+
pyenv install 3.9.7
|
|
112
|
+
pyenv install 3.10.1
|
|
113
|
+
pyenv install 3.11.8
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
4. Create a virtual environment for the leverage project:
|
|
117
|
+
|
|
118
|
+
Create a virtual environment for your project using Python 3.9.7:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pyenv virtualenv 3.9.7 leverage_py_39_venv
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
5. Set your virtual environment to be used in the project:
|
|
125
|
+
|
|
126
|
+
To set this virtual environment as the local environment for your project, navigate to your project directory and run:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
cd <path_to_leverage_project_root>
|
|
130
|
+
pyenv local leverage_py_39_venv
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This setup commands `pyenv` to use `leverage_py_39_venv` as the local Python version for your project directory,
|
|
134
|
+
ensuring that all Python operations within this directory use this isolated environment.
|
|
135
|
+
|
|
136
|
+
## Setting up development environment
|
|
137
|
+
|
|
138
|
+
Before you begin, ensure you are running Python 3.8, 3.9, or 3.10 as these are the only versions Leverage CLI supports
|
|
139
|
+
and tests against.
|
|
140
|
+
|
|
141
|
+
We now use Poetry for dependency management. Setup your development environment as follows:
|
|
142
|
+
|
|
143
|
+
1. Install Poetry:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
2. Clone the repository and navigate into it:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
git clone https://github.com/binbashar/leverage.git
|
|
153
|
+
cd leverage
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
3. Install dependencies using Poetry:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
poetry install --with=dev --with=main
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
4. To activate the virtual environment and start using the CLI in dev mode, use:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
poetry shell
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Pre-commit hooks
|
|
169
|
+
|
|
170
|
+
In order to run black automatically on every commit, you should install `pre-commit` first:
|
|
171
|
+
|
|
172
|
+
https://pre-commit.com/#installation
|
|
173
|
+
|
|
174
|
+
And then the hooks:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
poetry run pre-commit install
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Running Tests
|
|
181
|
+
|
|
182
|
+
To run unit tests, pytest is the tool of choice, and the required dependencies are available in the
|
|
183
|
+
corresponding `dev-requirements.txt`.
|
|
184
|
+
|
|
185
|
+
Integration tests are implemented using [bats](https://github.com/bats-core/bats-core/). Bear in mind that bats tests
|
|
186
|
+
are meant to be run in a throwaway environment since they perform filesystem manipulations and installation and removal
|
|
187
|
+
of packages, and the cleanup may not be completely thorough. As such, is highly recommended to run these tests using the
|
|
188
|
+
docker image.
|
|
189
|
+
|
|
190
|
+
### Manually
|
|
191
|
+
|
|
192
|
+
1. Unit tests:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
poetry run pytest
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
2. Integration tests:
|
|
199
|
+
|
|
200
|
+
Install dependencies (MacOS):
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
brew install bats-core
|
|
204
|
+
brew tap bats-core/bats-core
|
|
205
|
+
brew install bats-support
|
|
206
|
+
brew install bats-assert
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
bats -r tests/bats
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Using docker image
|
|
214
|
+
|
|
215
|
+
A Docker image suitable for running all tests can be crafted by running `make build-image`. After crafting the image all
|
|
216
|
+
tests can be executed.
|
|
217
|
+
|
|
218
|
+
To run all tests, run `make tests`. Alternatively `make test-unit` or `make test-int` for unit or integration tests
|
|
219
|
+
respectively.
|
|
220
|
+
|
|
221
|
+
## Release Process
|
|
222
|
+
|
|
223
|
+
* On every PR, a Github Action workflow is triggered to create/update a release draft.
|
|
224
|
+
* The version number is determined by the labels of those PRs (major, minor, fix).
|
|
225
|
+
* The release draft has to be manually published. This allows for any number of PR (features, fixes) to make the cut.
|
|
226
|
+
* Once a release is published, another workflow is triggered to create and push the package to PyPi.
|
|
227
|
+
|
|
228
|
+
## Release Candidate Process
|
|
229
|
+
|
|
230
|
+
* There is an Action called "Test Build Package and Push".
|
|
231
|
+
* This Action can be called manually on any branch specifying the version to release to test.
|
|
232
|
+
* The version is a Release Candidate following the Semver: e.g. if the next release is 1.2.3, the test version
|
|
233
|
+
should be 1.2.3-rc.1
|
|
234
|
+
* The package will be published to [PyPi](https://pypi.org/project/leverage/).
|
|
235
|
+
|
|
236
|
+
## Contributors/Contributing
|
|
237
|
+
|
|
238
|
+
* Leverage CLI was initially based on Pynt: https://github.com/rags/pynt
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
Leverage CLI is licensed
|
|
243
|
+
under [MIT license](http://opensource.org/licenses/MIT)[BinBash Inc](https://github.com/binbashar)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Binbash Leverage Command-line tool.
|
|
3
3
|
"""
|
|
4
|
-
#pylint: disable=wrong-import-position
|
|
4
|
+
# pylint: disable=wrong-import-position
|
|
5
5
|
|
|
6
|
-
__version__ = "1.9.
|
|
7
|
-
__toolbox_version__ = "1.2.7-0.1.
|
|
6
|
+
__version__ = "1.9.4rc1"
|
|
7
|
+
__toolbox_version__ = "1.2.7-0.1.12"
|
|
8
8
|
|
|
9
9
|
import sys
|
|
10
10
|
from shutil import which
|
|
11
11
|
|
|
12
|
-
if which("git") is None:
|
|
12
|
+
if which("git") is None: # pragma: no cover
|
|
13
13
|
print("No git installation found in the system. Exiting.")
|
|
14
14
|
sys.exit(1)
|
|
15
15
|
|
|
@@ -9,20 +9,20 @@ from leverage.logger import get_verbosity
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class Module:
|
|
12
|
-
"""
|
|
12
|
+
"""Module containing all tasks to be run."""
|
|
13
|
+
|
|
13
14
|
def __init__(self, name="build.py", tasks=None, default_task=None):
|
|
14
15
|
self.name = name
|
|
15
16
|
self.tasks = tasks if tasks is not None else []
|
|
16
17
|
self.default_task = default_task
|
|
17
18
|
|
|
18
19
|
def __eq__(self, other):
|
|
19
|
-
return
|
|
20
|
-
and self.tasks == other.tasks
|
|
21
|
-
and self.default_task == other.default_task)
|
|
20
|
+
return self.name == other.name and self.tasks == other.tasks and self.default_task == other.default_task
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
class State:
|
|
25
|
-
"""
|
|
24
|
+
"""Internal state of the application."""
|
|
25
|
+
|
|
26
26
|
def __init__(self):
|
|
27
27
|
self._verbosity = None
|
|
28
28
|
self.module = Module()
|
|
@@ -37,11 +37,12 @@ class State:
|
|
|
37
37
|
self._verbosity = get_verbosity(verbose=verbose)
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
pass_state =
|
|
40
|
+
pass_state = click.make_pass_decorator(State, ensure=True)
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def pass_container(command):
|
|
44
|
-
"""
|
|
44
|
+
"""Decorator to pass the current container to the command."""
|
|
45
|
+
|
|
45
46
|
@wraps(command)
|
|
46
47
|
def new_command(*args, **kwargs):
|
|
47
48
|
ctx = click.get_current_context()
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Command line arguments and tasks arguments parsing utilities.
|
|
3
3
|
"""
|
|
4
|
+
|
|
5
|
+
|
|
4
6
|
class InvalidArgumentOrderError(RuntimeError):
|
|
5
7
|
pass
|
|
6
8
|
|
|
@@ -10,7 +12,7 @@ class DuplicateKeywordArgumentError(RuntimeError):
|
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
def parse_task_args(arguments):
|
|
13
|
-
"""
|
|
15
|
+
"""Parse the arguments for a task and return args and kwargs appropriately
|
|
14
16
|
|
|
15
17
|
Args:
|
|
16
18
|
arguments (str): Arguments to parse.
|
|
@@ -34,7 +36,9 @@ def parse_task_args(arguments):
|
|
|
34
36
|
for argument in arguments:
|
|
35
37
|
if "=" not in argument:
|
|
36
38
|
if kwargs:
|
|
37
|
-
raise InvalidArgumentOrderError(
|
|
39
|
+
raise InvalidArgumentOrderError(
|
|
40
|
+
f"Positional argument `{argument}` from task `{{task}}` cannot follow a keyword argument."
|
|
41
|
+
)
|
|
38
42
|
|
|
39
43
|
args.append(argument.strip())
|
|
40
44
|
|