mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2025-12-14 18:44:53 +01:00
build
This commit is contained in:
12
port.py
12
port.py
@@ -10,7 +10,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
from git import Repo # pip install gitpython
|
from git import Repo # pip install gitpython
|
||||||
|
import base64
|
||||||
class Portainer:
|
class Portainer:
|
||||||
"""
|
"""
|
||||||
Simple wrapper around the module-level Portainer helper functions.
|
Simple wrapper around the module-level Portainer helper functions.
|
||||||
@@ -694,3 +694,13 @@ class Portainer:
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def create_secret(self, name, value, endpoint_id=None, timeout=None):
|
||||||
|
endpoint_id = int(self.endpoints["by_name"][endpoint_id])
|
||||||
|
path = f"/endpoints/{endpoint_id}/docker/secrets/create"
|
||||||
|
encoded = base64.b64encode(value.encode()).decode()
|
||||||
|
data = {
|
||||||
|
"Name": name,
|
||||||
|
"Data": encoded
|
||||||
|
}
|
||||||
|
self.api_post(path, data, timeout=timeout)
|
||||||
@@ -30,6 +30,7 @@ parser.add_argument("--get-stack", metavar="NAME_OR_ID", help="Get stack by name
|
|||||||
parser.add_argument("--autostart", "-a", action="store_true", help="Auto-start created stacks")
|
parser.add_argument("--autostart", "-a", action="store_true", help="Auto-start created stacks")
|
||||||
parser.add_argument("--start-stack", "-x", action='store_true')
|
parser.add_argument("--start-stack", "-x", action='store_true')
|
||||||
parser.add_argument("--stop-stack", "-o", action='store_true')
|
parser.add_argument("--stop-stack", "-o", action='store_true')
|
||||||
|
parser.add_argument("--secrets", "-q", action='store_true')
|
||||||
parser.add_argument("--debug", "-D", action='store_true')
|
parser.add_argument("--debug", "-D", action='store_true')
|
||||||
parser.add_argument("--create-stack","-n", action='store_true')
|
parser.add_argument("--create-stack","-n", action='store_true')
|
||||||
parser.add_argument("--create-stack_new2","-N", action='store_true')
|
parser.add_argument("--create-stack_new2","-N", action='store_true')
|
||||||
@@ -104,6 +105,14 @@ if __name__ == "__main__":
|
|||||||
token = portainer_api_key
|
token = portainer_api_key
|
||||||
# Example: list endpoints
|
# Example: list endpoints
|
||||||
por = Portainer(base, token)
|
por = Portainer(base, token)
|
||||||
|
if args.secrets:
|
||||||
|
secrets = {
|
||||||
|
"gitea_runner_registration_token": "8nmKqJhkvYwltmNfF2o9vs0tzo70ufHSQpVg6ymb",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in secrets.items():
|
||||||
|
por.create_secret(key, value, args.endpoint_id, args.timeout)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
if args.delete_stack:
|
if args.delete_stack:
|
||||||
por.delete_stack(args.endpoint_id, args.stack,)
|
por.delete_stack(args.endpoint_id, args.stack,)
|
||||||
|
|||||||
Reference in New Issue
Block a user