mirror of
https://github.com/Hopiu/portainer-cli.git
synced 2026-03-16 22:10:34 +00:00
Add update_registry command
This commit is contained in:
parent
4b7ff1e1f7
commit
89f5c1244e
2 changed files with 52 additions and 1 deletions
24
README.md
24
README.md
|
|
@ -61,7 +61,7 @@ portainer-cli update_stack id endpoint_id [stack_file]
|
|||
portainer-cli update_stack 2 1 docker-compose.yml
|
||||
```
|
||||
|
||||
#### update_stack command environment variables arguments
|
||||
#### Environment variables arguments
|
||||
|
||||
```bash
|
||||
portainer-cli update_stack id endpoint_id [stack_file] --env.var=value
|
||||
|
|
@ -76,6 +76,28 @@ Where `var` is environment variable name and `value` is the environment variable
|
|||
| `-p` or `--prune` | Prune services |
|
||||
| `-c` or `--clear-env` | Clear all environment variables |
|
||||
|
||||
### update_registry command
|
||||
|
||||
Update registry.
|
||||
|
||||
```bash
|
||||
portainer-cli update_registry id [-name] [-url]
|
||||
```
|
||||
|
||||
**E.g:**
|
||||
|
||||
```bash
|
||||
portainer-cli update_registry 1 -name="Some registry" -url="some.url.com/r"
|
||||
```
|
||||
|
||||
#### Authentication
|
||||
|
||||
You can use authentication passing `-a` or `--authentication` flag, but you must pass the `-username` and `-password` options.
|
||||
|
||||
```bash
|
||||
portainer-cli update_registry 1 -a -username=douglas -password=d1234
|
||||
```
|
||||
|
||||
### request command
|
||||
|
||||
Make a request.
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@ class PortainerCLI:
|
|||
COMMAND_LOGIN = 'login'
|
||||
COMMAND_REQUEST = 'request'
|
||||
COMMAND_UPDATE_STACK = 'update_stack'
|
||||
COMMAND_UPDATE_REGISTRY = 'update_registry'
|
||||
COMMANDS = [
|
||||
COMMAND_CONFIGURE,
|
||||
COMMAND_LOGIN,
|
||||
COMMAND_REQUEST,
|
||||
COMMAND_UPDATE_STACK,
|
||||
COMMAND_UPDATE_REGISTRY,
|
||||
]
|
||||
|
||||
METHOD_GET = 'GET'
|
||||
|
|
@ -141,6 +143,31 @@ class PortainerCLI:
|
|||
data,
|
||||
)
|
||||
|
||||
@plac.annotations(
|
||||
name=('Name', 'option'),
|
||||
url=('URL', 'option'),
|
||||
authentication=('Use authentication', 'flag', 'a'),
|
||||
username=('Username', 'option'),
|
||||
password=('Password', 'option'),
|
||||
)
|
||||
def update_registry(self, id, name='', url='', authentication=False,
|
||||
username='', password=''):
|
||||
assert not authentication or (authentication and username and password)
|
||||
registry_url = f'registries/{id}'
|
||||
current = self.request(registry_url).json()
|
||||
data = {
|
||||
'Name': name or current.get('Name'),
|
||||
'URL': url or current.get('URL'),
|
||||
'Authentication': authentication,
|
||||
'Username': username or current.get('Username'),
|
||||
'Password': password,
|
||||
}
|
||||
self.request(
|
||||
registry_url,
|
||||
self.METHOD_PUT,
|
||||
data,
|
||||
)
|
||||
|
||||
@plac.annotations(
|
||||
printc=('Print response content', 'flag', 'p'),
|
||||
)
|
||||
|
|
@ -188,5 +215,7 @@ class PortainerCLI:
|
|||
plac.call(self.login, args)
|
||||
elif command == self.COMMAND_UPDATE_STACK:
|
||||
plac.call(self.update_stack, args)
|
||||
elif command == self.COMMAND_UPDATE_REGISTRY:
|
||||
plac.call(self.update_registry, args)
|
||||
elif command == self.COMMAND_REQUEST:
|
||||
plac.call(self.request, args)
|
||||
|
|
|
|||
Loading…
Reference in a new issue