mirror of
https://github.com/Hopiu/portainer-cli.git
synced 2026-04-28 10:24:42 +00:00
Add documentation
This commit is contained in:
parent
159a2f72da
commit
be95a415c0
2 changed files with 118 additions and 10 deletions
121
README.md
121
README.md
|
|
@ -47,25 +47,47 @@ portainer-cli login username password
|
|||
portainer-cli login douglas d1234
|
||||
```
|
||||
|
||||
### create_or_update_stack command
|
||||
### create_stack command
|
||||
|
||||
Either create or update stack based on whether or not it exists already.
|
||||
Create a stack.
|
||||
|
||||
```bash
|
||||
portainer-cli create_or_update_stack endpoint_id [stack_file] stack_name [-env-file]
|
||||
portainer-cli create_stack -n stack_name -e endpoint_id -f stack_file
|
||||
```
|
||||
stack_file is mandatory when creating
|
||||
|
||||
**E.g:**
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack 1 stack-test docker-compose.yml
|
||||
portainer-cli create_stack -n stack_name -e 1 stack-test -f docker-compose.yml
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Description |
|
||||
|--|--|
|
||||
| `-n` or `-stack-name` | Stack name |
|
||||
| `-e` or `-endpoint-id` | Endpoint id (required) |
|
||||
| `-f` or `-stack-file` |Stack file |
|
||||
| `-ef` or `-env-file` | Pass env file path, usually `.env` |
|
||||
|
||||
### update_stack command
|
||||
|
||||
Update a stack.
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack -s stack_id -e endpoint_id -f stack_file
|
||||
```
|
||||
|
||||
**E.g:**
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack -s 18 -e 1 -f docker-compose.yml
|
||||
```
|
||||
|
||||
#### Environment variables arguments
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack id endpoint_id [stack_file] --env.var=value
|
||||
portainer-cli update_stack id -s stack_id -e endpoint_id -f stack_file --env.var=value
|
||||
```
|
||||
|
||||
Where `var` is the environment variable name and `value` is the environment variable value.
|
||||
|
|
@ -74,10 +96,95 @@ Where `var` is the environment variable name and `value` is the environment vari
|
|||
|
||||
| Flag | Description |
|
||||
|--|--|
|
||||
| `-env-file` | Pass env file path, usually `.env` |
|
||||
| `-s` or `-stack-id` | Stack id |
|
||||
| `-e` or `-endpoint-id` | Endpoint id (required) |
|
||||
| `-f` or `-stack-file` |Stack file |
|
||||
| `-ef` or `-env-file` | Pass env file path, usually `.env` |
|
||||
| `-p` or `--prune` | Prune services |
|
||||
| `-c` or `--clear-env` | Clear all environment variables |
|
||||
|
||||
### create_or_update_stack command
|
||||
|
||||
Create or update a stack based on it's name.
|
||||
|
||||
```bash
|
||||
portainer-cli create_or_update_stack -n stack_name -e endpoint_id -f stack_file [`-ef` or `-env-file`]
|
||||
```
|
||||
|
||||
**E.g:**
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack -s 18 -e 1 -f docker-compose.yml
|
||||
```
|
||||
|
||||
#### Environment variables arguments
|
||||
|
||||
```bash
|
||||
portainer-cli create_or_update_stack -n stack_name -e endpoint_id -f stack_file [`-ef` or `-env-file`]--env.var=value
|
||||
```
|
||||
|
||||
Where `var` is the environment variable name and `value` is the environment variable value.
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Description |
|
||||
|--|--|
|
||||
| `-n` or `-stack-name` | Stack name |
|
||||
| `-e` or `-endpoint-id` | Endpoint id (required) |
|
||||
| `-f` or `-stack-file` |Stack file |
|
||||
| `-ef` or `-env-file` | Pass env file path, usually `.env` |
|
||||
| `-p` or `--prune` | Prune services |
|
||||
| `-c` or `--clear-env` | Clear all environment variables |
|
||||
|
||||
### update_stack_acl command
|
||||
|
||||
Update acl associated to a stack
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack_acl -s stack_id -e endpoint_id -o ownership_type
|
||||
```
|
||||
|
||||
Remark : you can either update by stack_id or stack_name (`-s` or `-n`)
|
||||
|
||||
**E.g:**
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack_acl -n stack-test -e 1 -o restricted -u user1,user2 -t team1,team2
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Description |
|
||||
|--|--|
|
||||
| `-s` or `-stack-id` | Stack id |
|
||||
| `-n` or `-stack-name` | Stack name |
|
||||
| `-e` or `-endpoint-id` | Endpoint id (required) |
|
||||
| `-o` or `-ownership-type` | Ownership type (`admin`|`restricted`,`public`) (required) |
|
||||
| `-u` or `users` | Comma separated list of user names (when `restricted`) |
|
||||
| `-t` or `team` | Comma separated list of team names (when `restricted`) |
|
||||
| `-c` or `clear` | Clear users and teams before updateing them (when `restricted`) |
|
||||
|
||||
### get_stack_id command
|
||||
|
||||
Get stack id by it's name. return -1 if the stack does not exist
|
||||
|
||||
```bash
|
||||
portainer-cli get_stack_id -n stack_name -e endpoint_id
|
||||
```
|
||||
|
||||
**E.g:**
|
||||
|
||||
```bash
|
||||
portainer-cli get_stack_id -n stack-test -e 1
|
||||
```
|
||||
|
||||
#### Flags
|
||||
|
||||
| Flag | Description |
|
||||
|--|--|
|
||||
| `-n` or `-stack-name` | Stack name |
|
||||
| `-e` or `-endpoint-id` | Endpoint id (required) |
|
||||
|
||||
### update_registry command
|
||||
|
||||
Update registry.
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class PortainerCLI(object):
|
|||
stack_name=('Stack name', 'option', 'n', str),
|
||||
endpoint_id=('Endpoint id', 'option', 'e', int),
|
||||
stack_file=('Stack file', 'option', 'f'),
|
||||
env_file=('Environment Variable file', 'option'),
|
||||
env_file=('Environment Variable file', 'option', 'ef'),
|
||||
prune=('Prune services', 'flag', 'p'),
|
||||
clear_env=('Clear all env vars', 'flag', 'c'),
|
||||
)
|
||||
|
|
@ -289,7 +289,8 @@ class PortainerCLI(object):
|
|||
@plac.annotations(
|
||||
stack_name=('Stack name', 'option', 'n'),
|
||||
endpoint_id=('Endpoint id', 'option', 'e', int),
|
||||
env_file=('Environment Variable file', 'option', 'f')
|
||||
stack_file=('Environment Variable file', 'option', 'f')
|
||||
env_file=('Environment Variable file', 'option', 'ef')
|
||||
)
|
||||
def create_stack(self, stack_name, endpoint_id, stack_file, env_file='', *args):
|
||||
logger.info('Creating stack name={}'.format(stack_name))
|
||||
|
|
@ -392,7 +393,7 @@ class PortainerCLI(object):
|
|||
stack_id=('Stack id', 'option', 's', int),
|
||||
endpoint_id=('Endpoint id', 'option', 'e', int),
|
||||
stack_file=('Stack file', 'option', 'f'),
|
||||
env_file=('Environment Variable file', 'option'),
|
||||
env_file=('Environment Variable file', 'option', 'ef'),
|
||||
prune=('Prune services', 'flag', 'p'),
|
||||
clear_env=('Clear all env vars', 'flag', 'c'),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue