dokku-wrapper 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: dokku-wrapper
3
+ Version: 0.1.0
4
+ Summary: Um wrapper em Python para gerenciar aplicações Dokku
5
+ Author-email: Jonatan Rodrigues da Silva <jonatanjrss@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://gitlab.com/jonatanjrss/dokku-wrapper
8
+ Project-URL: Issues, https://gitlab.com/jonatanjrss/dokku-wrapper/issues
9
+ Keywords: dokku,deploy,automation,wrapper
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pytest
17
+ Requires-Dist: pytest-mock
18
+ Dynamic: license-file
19
+
20
+ # dokku-wrapper
21
+
22
+ Wrapper em Python para gerenciar aplicações Dokku.
23
+
24
+ ## Instalação
25
+
26
+ ```bash
27
+
28
+ pip install dokku-wrapper
29
+ ```
30
+
31
+ ## Uso
32
+
33
+ ```python
34
+ from dokku_wrapper.dokku import Dokku
35
+
36
+ dokku = Dokku()
37
+ dokku.apps.create("meu-app")
38
+ ```
@@ -0,0 +1,19 @@
1
+ # dokku-wrapper
2
+
3
+ Wrapper em Python para gerenciar aplicações Dokku.
4
+
5
+ ## Instalação
6
+
7
+ ```bash
8
+
9
+ pip install dokku-wrapper
10
+ ```
11
+
12
+ ## Uso
13
+
14
+ ```python
15
+ from dokku_wrapper.dokku import Dokku
16
+
17
+ dokku = Dokku()
18
+ dokku.apps.create("meu-app")
19
+ ```
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dokku-wrapper"
7
+ version = "0.1.0"
8
+ description = "Um wrapper em Python para gerenciar aplicações Dokku"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Jonatan Rodrigues da Silva", email = "jonatanjrss@gmail.com" }
14
+ ]
15
+ keywords = ["dokku", "deploy", "automation", "wrapper"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: POSIX :: Linux",
20
+ ]
21
+
22
+ dependencies = [
23
+ # Adicione aqui suas dependências, se houver
24
+ "pytest",
25
+ "pytest-mock"
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://gitlab.com/jonatanjrss/dokku-wrapper"
30
+ Issues = "https://gitlab.com/jonatanjrss/dokku-wrapper/issues"
31
+
32
+ #[tool.setuptools.packages.find]
33
+ #where = ["."]
34
+ #include = ["dokku_wrapper*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ class DokkuError(Exception):
2
+ """Erro base para o wrapper Dokku."""
3
+
4
+
5
+ class DokkuCommandError(DokkuError):
6
+ def __init__(self, command, message):
7
+ super().__init__(f"Erro executando {' '.join(command)}: {message}")
8
+ self.command = command
9
+ self.message = message
10
+
11
+
12
+ class AppAlreadyExists(DokkuError):
13
+ def __init__(self, name: str):
14
+ super().__init__(f"O app '{name}' já existe.")
15
+
16
+
17
+ class AppNotFound(DokkuError):
18
+ def __init__(self, name: str):
19
+ super().__init__(f"O app '{name}' não foi encontrado.")
@@ -0,0 +1,15 @@
1
+ import subprocess
2
+ from typing import List
3
+ from .exceptions import DokkuCommandError
4
+
5
+
6
+ def run_command(command: List[str], capture_output: bool = True) -> str:
7
+ """Executa um comando Dokku com segurança."""
8
+ result = subprocess.run(
9
+ command,
10
+ capture_output=capture_output,
11
+ text=True
12
+ )
13
+ if result.returncode != 0:
14
+ raise DokkuCommandError(command, result.stderr.strip())
15
+ return result.stdout.strip()
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ from .services.apps import Apps
2
+
3
+
4
+ class Dokku:
5
+ """Interface principal para interação com o Dokku."""
6
+
7
+ def __init__(self):
8
+ self.apps = Apps()
File without changes
@@ -0,0 +1,35 @@
1
+ from ..core.executor import run_command
2
+ from ..core.exceptions import AppAlreadyExists, AppNotFound, DokkuCommandError
3
+ from typing import List, Dict
4
+
5
+
6
+ class Apps:
7
+ """Gerencia aplicações Dokku."""
8
+
9
+ @staticmethod
10
+ def create(name: str) -> Dict[str, str]:
11
+ try:
12
+ output = run_command(["dokku", "apps:create", name])
13
+ return {"name": name, "message": output}
14
+ except DokkuCommandError as e:
15
+ if "already exists" in e.message:
16
+ raise AppAlreadyExists(name)
17
+ raise
18
+
19
+ @staticmethod
20
+ def destroy(name: str, force: bool = True) -> str:
21
+ cmd = ["dokku", "apps:destroy", name]
22
+ if force:
23
+ cmd.append("--force")
24
+ try:
25
+ return run_command(cmd)
26
+ except DokkuCommandError as e:
27
+ if "is not deployed" in e.message or "does not exist" in e.message:
28
+ raise AppNotFound(name)
29
+ raise
30
+
31
+ @staticmethod
32
+ def list() -> List[str]:
33
+ """Retorna uma lista de apps Dokku existentes."""
34
+ output = run_command(["dokku", "apps:list"])
35
+ return [line.strip() for line in output.splitlines() if line.strip()]
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: dokku-wrapper
3
+ Version: 0.1.0
4
+ Summary: Um wrapper em Python para gerenciar aplicações Dokku
5
+ Author-email: Jonatan Rodrigues da Silva <jonatanjrss@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://gitlab.com/jonatanjrss/dokku-wrapper
8
+ Project-URL: Issues, https://gitlab.com/jonatanjrss/dokku-wrapper/issues
9
+ Keywords: dokku,deploy,automation,wrapper
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pytest
17
+ Requires-Dist: pytest-mock
18
+ Dynamic: license-file
19
+
20
+ # dokku-wrapper
21
+
22
+ Wrapper em Python para gerenciar aplicações Dokku.
23
+
24
+ ## Instalação
25
+
26
+ ```bash
27
+
28
+ pip install dokku-wrapper
29
+ ```
30
+
31
+ ## Uso
32
+
33
+ ```python
34
+ from dokku_wrapper.dokku import Dokku
35
+
36
+ dokku = Dokku()
37
+ dokku.apps.create("meu-app")
38
+ ```
@@ -0,0 +1,20 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/dokku_wrapper/__init__.py
5
+ src/dokku_wrapper/dokku.py
6
+ src/dokku_wrapper.egg-info/PKG-INFO
7
+ src/dokku_wrapper.egg-info/SOURCES.txt
8
+ src/dokku_wrapper.egg-info/dependency_links.txt
9
+ src/dokku_wrapper.egg-info/requires.txt
10
+ src/dokku_wrapper.egg-info/top_level.txt
11
+ src/dokku_wrapper/core/__init__.py
12
+ src/dokku_wrapper/core/exceptions.py
13
+ src/dokku_wrapper/core/executor.py
14
+ src/dokku_wrapper/core/parser.py
15
+ src/dokku_wrapper/core/types.py
16
+ src/dokku_wrapper/models/__init__.py
17
+ src/dokku_wrapper/models/app.py
18
+ src/dokku_wrapper/services/__init__.py
19
+ src/dokku_wrapper/services/apps.py
20
+ tests/test_apps.py
@@ -0,0 +1,2 @@
1
+ pytest
2
+ pytest-mock
@@ -0,0 +1 @@
1
+ dokku_wrapper
@@ -0,0 +1,24 @@
1
+ import pytest
2
+
3
+
4
+ def test_create_app(mocker, dokku):
5
+ mocker.patch("dokku_wrapper.services.apps.run_command", return_value="App created")
6
+ result = dokku.apps.create("myapp")
7
+ assert result["name"] == "myapp"
8
+
9
+
10
+ def test_create_app_already_exists(mocker, dokku):
11
+ mocker.patch(
12
+ "dokku_wrapper.services.apps.run_command",
13
+ side_effect=Exception("App already exists")
14
+ )
15
+ with pytest.raises(Exception):
16
+ dokku.apps.create("myapp")
17
+
18
+
19
+ def test_destroy_app(mocker, dokku):
20
+ mocker.patch(
21
+ "dokku_wrapper.services.apps.run_command",
22
+ return_value="App Destroyed")
23
+ result = dokku.apps.destroy("myapp")
24
+ assert result == "App Destroyed"