Fixes typos and enhances CONTRIBUTING.md

Signed-off-by: Jean-Baptiste Perez <jbaptperez@gmail.com>
This commit is contained in:
Jean-Baptiste Perez 2023-09-21 23:32:21 +02:00
parent 078ee7b649
commit b263dc1a7d

View File

@ -1,32 +1,32 @@
# Contributing to podman-compose # Contributing to podman-compose
## Who can contribute? ## Who can contribute?
- Users that found a bug - Users that found a bug
- Users that wants to propose new functionalities or enhancements - Users that want to propose new functionalities or enhancements
- Users that want to help other users to troubleshoot their environments - Users that want to help other users to troubleshoot their environments
- Developers that want to fix bugs - Developers that want to fix bugs
- Developers that want to implement new functionalities or enhancements - Developers that want to implement new functionalities or enhancements
## Branches ## Branches
Please request your PR to be merged into the `devel` branch. Please request your pull request to be merged into the `devel` branch.
Changes to the `stable` branch are managed by the repository maintainers. Changes to the `stable` branch are managed by the repository maintainers.
## Development environment setup ## Development environment setup
Note: Some steps are OPTIONAL but all are RECOMMENDED. Note: Some steps are OPTIONAL but all are RECOMMENDED.
1. Fork the project repo and clone it 1. Fork the project repository and clone it
```shell ```shell
$ git clone https://github.com/USERNAME/podman-compose.git $ git clone https://github.com/USERNAME/podman-compose.git
$ cd podman-compose $ cd podman-compose
``` ```
1. (OPTIONAL) Create a python virtual environment. Example using [virtualenv wrapper](https://virtualenvwrapper.readthedocs.io/en/latest/): 1. (OPTIONAL) Create a Python virtual environment. Example using [virtualenv wrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```shell ```shell
mkvirtualenv podman-compose mkvirtualenv podman-compose
``` ```
2. Install the project runtime and development requirements 2. Install the project runtime and development requirements
```shell ```shell
$ pip install '.[devel]' $ pip install '.[devel]'
``` ```
@ -35,7 +35,7 @@ $ pip install '.[devel]'
$ pre-commit install $ pre-commit install
``` ```
4. Create a new branch, develop and add tests when possible 4. Create a new branch, develop and add tests when possible
5. Run linting & testing before committing code. Ensure all the hooks are passing. 5. Run linting and testing before committing code. Ensure all the hooks are passing.
```shell ```shell
$ pre-commit run --all-files $ pre-commit run --all-files
``` ```
@ -47,22 +47,22 @@ coverage combine
coverage report coverage report
coverage html coverage html
``` ```
7. Commit your code to your fork's branch. 7. Commit your code to your fork's branch.
- Make sure you include a `Signed-off-by` message in your commits. Read [this guide](https://github.com/containers/common/blob/main/CONTRIBUTING.md#sign-your-prs) to learn how to sign your commits - Make sure you include a `Signed-off-by` message in your commits. Read [this guide](https://github.com/containers/common/blob/main/CONTRIBUTING.md#sign-your-prs) to learn how to sign your commits
- In the commit message reference the Issue ID that your code fixes and a brief description of the changes. Example: `Fixes #516: allow empty network` - In the commit message reference the Issue ID that your code fixes and a brief description of the changes. Example: `Fixes #516: Allow empty network`
7. Open a PR to `containers/podman-compose:devel` and wait for a maintainer to review your work. 8. Open a pull request to `containers/podman-compose:devel` and wait for a maintainer to review your work.
## Adding new commands ## Adding new commands
To add a command you need to add a function that is decorated To add a command, you need to add a function that is decorated with `@cmd_run`.
with `@cmd_run` passing the compose instance, command name and
description. This function must be declared `async` the wrapped The decorated function must be declared `async` and should accept two arguments: The compose instance and the
function should accept two arguments the compose instance and command-specific arguments (resulted from the Python's `argparse` package).
the command-specific arguments (resulted from python's `argparse`
package) inside that command you can run PodMan like this In this function, you can run Podman (e.g. `await compose.podman.run(['inspect', 'something'])`), access `compose.pods`,
`await compose.podman.run(['inspect', 'something'])`and inside `compose.containers` etc.
that function you can access `compose.pods` and `compose.containers`
...etc. Here is an example Here is an example:
``` ```
@cmd_run(podman_compose, 'build', 'build images defined in the stack') @cmd_run(podman_compose, 'build', 'build images defined in the stack')
@ -72,13 +72,16 @@ async def compose_build(compose, args):
## Command arguments parsing ## Command arguments parsing
Add a function that accept `parser` which is an instance from `argparse`. To add arguments to be parsed by a command, you need to add a function that is decorated with `@cmd_parse` which accepts
In side that function you can call `parser.add_argument()`. the compose instance and the command's name (as a string list or as a single string).
The function decorated with `@cmd_parse` accepting the compose instance,
and command names (as a list or as a string).
You can do this multiple times.
Here is an example The decorated function should accept a single argument: An instance of `argparse`.
In this function, you can call `parser.add_argument()` to add a new argument to the command.
Note you can add such a function multiple times.
Here is an example:
``` ```
@cmd_parse(podman_compose, 'build') @cmd_parse(podman_compose, 'build')
@ -91,9 +94,9 @@ def compose_build_parse(parser):
NOTE: `@cmd_parse` should be after `@cmd_run` NOTE: `@cmd_parse` should be after `@cmd_run`
## Calling a command from inside another ## Calling a command from another one
If you need to call `podman-compose down` from inside `podman-compose up` If you need to call `podman-compose down` from `podman-compose up`
do something like: do something like:
``` ```