mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge branch 'dev' of https://github.com/YunoHost/moulinette into dev
This commit is contained in:
commit
ee3de972ea
2 changed files with 5 additions and 18 deletions
|
@ -7,21 +7,22 @@ We decided to regroup all YunoHost related operations into a single program call
|
|||
|
||||
### Important files
|
||||
* `` parse_args `` File executed on function calling - i.e `` ./parse_args user create ``. Will be renamed `` yunohost `` when packaged.
|
||||
* `` action_map.yml `` Defines all CLI actions and links arguments.
|
||||
* `` yunohost.py `` Contains all YunoHost functions likely to be shared between moulinette files. Also contains service connections classes (erk). Refers to "Service connections" paragraph.
|
||||
* `` yunohost_*.py `` Files containing action functions. `` * `` is the category: user, domain, firewall, etc.
|
||||
|
||||
### How to add a function ?
|
||||
1. Check if the action is already in the `` action_map `` dictionary in the `` parse_args `` file. If not, follow the dict documentation to add it.
|
||||
1. Check if the action is already in the `` action_map.yml `` file. If not, follow the file documentation to add it.
|
||||
2. Also check if the file `` yunohost_category.py `` is created in the working tree. If not, just create it (you may take example of `` yunohost_user.py `` file).
|
||||
3. Add your function `` category_action() `` in this file - i.e `` user_create() ``
|
||||
|
||||
**Note:** `` category_action() `` takes one parameter plus an optional one : `` args `` and `` connections `` if connections were set. `` args `` contains the arguments passed to the command. Refers to `` action_map `` documentation for more informations.
|
||||
**Note:** `` category_action() `` takes one parameter plus an optional one : `` args `` and `` connections `` if connections were set. `` args `` contains the arguments passed to the command. Refers to `` action_map.yml `` documentation for more informations.
|
||||
|
||||
### Service connections
|
||||
The so called 'service connection' could actually be multiple things. It just is the resource used for a specific action: a file opening, a SQL or a LDAP connection. For example, I need to access LDAP base for YunoHost's user manipulations, so I have to declare it. It could be a file opening (for repositories for example).
|
||||
|
||||
Because of potential complexity of its operations, the moulinette has a specific way to handle connections. A connection is initialized once if the action is requiring it.
|
||||
If you want to add a new connection (not yet implemented), you just have to put the connect and the disconnect method in `` connect_service() `` and `` disconnect_services() `` in the `` yunohost.py `` file. Then add your connection name to the action in the `` action_map `` dictionary.
|
||||
If you want to add a new connection (not yet implemented), you just have to put the connect and the disconnect method in `` connect_service() `` and `` disconnect_services() `` in the `` yunohost.py `` file. Then add your connection name to the action in the `` action_map.yml `` file.
|
||||
|
||||
We chose to make a class for some connections (i.e LDAP), in order to simplify some operations. Feel free to do the same.
|
||||
|
||||
|
|
16
README.md
16
README.md
|
@ -76,18 +76,4 @@ Contribute
|
|||
----------
|
||||
|
||||
|
||||
Only few functions are implemented yet. If you want to contribute, just pick one action above (i.e. `yunohost app addaccess`) and make the function (here `app_addaccess()`) into the right file (here `yunohost_app.py`).
|
||||
|
||||
If you need LDAP connections or openned configuration files, take a look at the connection documentation in the `yunohost.py` file.
|
||||
|
||||
|
||||
Dev self-notes
|
||||
--------------
|
||||
|
||||
* A big dictionary of categories/actions/arguments is translated to parsers and subparsers with argument handling (argparse python library)
|
||||
* One single action function is called after the parsing, named like `category_action()`
|
||||
* Connection to LDAP and/or config file openning is made before the action function
|
||||
* Parsed arguments and connection dictionary are the only parameters passed to the action function :
|
||||
`category_action(args, connections)`
|
||||
* 'connections' is optionnal
|
||||
* Connections are closed just before the sys.exit calling
|
||||
See CONTRIBUTE.md file
|
Loading…
Reference in a new issue