kubernetes-watch 0.1.13__tar.gz → 0.1.14__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.
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/PKG-INFO +1 -1
- kubernetes_watch-0.1.14/kube_watch/modules/database/model.py +13 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/database/postgre.py +45 -12
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/standalone/metarecogen/ckan_to_gn.py +1 -1
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/pyproject.toml +1 -1
- kubernetes_watch-0.1.13/kube_watch/modules/database/model.py +0 -12
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/LICENSE +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/README.md +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/enums/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/enums/kube.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/enums/logic.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/enums/providers.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/enums/workflow.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/models/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/models/common.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/models/workflow.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/clusters/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/clusters/kube.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/database/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/logic/actions.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/logic/checks.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/logic/load.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/logic/merge.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/logic/scheduler.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/logic/trasnform.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/mock/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/mock/mock_generator.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/providers/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/providers/aws.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/providers/git.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/providers/github.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/providers/vault.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/watch/__init__.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/watch/helpers.py +0 -0
- {kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/watch/workflow.py +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from typing import Union, Optional
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
|
|
4
|
+
class TableQuery(BaseModel):
|
|
5
|
+
table_name: str
|
|
6
|
+
column_name: str
|
|
7
|
+
db_url: Optional[str] = None
|
|
8
|
+
db_host: Optional[str] = None
|
|
9
|
+
db_port: Optional[int] = None
|
|
10
|
+
db_name: Optional[str] = None
|
|
11
|
+
db_user: Optional[str] = None
|
|
12
|
+
db_pass: Optional[str] = None
|
|
13
|
+
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import psycopg2
|
|
2
2
|
import psycopg2.extras
|
|
3
3
|
from prefect import get_run_logger
|
|
4
|
+
from urllib.parse import urlparse, unquote
|
|
4
5
|
|
|
5
6
|
from .model import TableQuery
|
|
6
7
|
|
|
7
8
|
logger = get_run_logger()
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
def execute_query(db_user, db_pass,
|
|
11
|
+
def execute_query(db_query, db_url=None, db_user=None, db_pass=None, db_host="localhost", db_port=5432, db_name="postgres"):
|
|
11
12
|
"""
|
|
12
13
|
Connect to PostgreSQL database, execute a query, and return status message.
|
|
13
14
|
|
|
14
15
|
Args:
|
|
15
|
-
db_user (str): Database username
|
|
16
|
-
db_pass (str): Database password
|
|
17
16
|
db_query (str): SQL query to execute
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
db_url (str, optional): Database connection URL (e.g., postgresql://user:pass@host:port/dbname)
|
|
18
|
+
Supports postgresql+asyncpg:// format as well
|
|
19
|
+
db_user (str, optional): Database username (used if db_url is not provided)
|
|
20
|
+
db_pass (str, optional): Database password (used if db_url is not provided)
|
|
21
|
+
db_host (str): Database host (default: localhost, used if db_url is not provided)
|
|
22
|
+
db_port (int): Database port (default: 5432, used if db_url is not provided)
|
|
23
|
+
db_name (str): Database name (default: postgres, used if db_url is not provided)
|
|
21
24
|
|
|
22
25
|
Returns:
|
|
23
26
|
dict: Status message with success/failure information
|
|
@@ -26,6 +29,18 @@ def execute_query(db_user, db_pass, db_query, db_host="localhost", db_port=5432,
|
|
|
26
29
|
cursor = None
|
|
27
30
|
|
|
28
31
|
try:
|
|
32
|
+
# Parse connection URL if provided
|
|
33
|
+
if db_url:
|
|
34
|
+
# Handle SQLAlchemy-style URLs (postgresql+asyncpg://)
|
|
35
|
+
url = db_url.replace('postgresql+asyncpg://', 'postgresql://')
|
|
36
|
+
parsed = urlparse(url)
|
|
37
|
+
|
|
38
|
+
db_host = parsed.hostname
|
|
39
|
+
db_port = parsed.port or 5432
|
|
40
|
+
db_name = parsed.path.lstrip('/')
|
|
41
|
+
db_user = unquote(parsed.username) if parsed.username else None
|
|
42
|
+
db_pass = unquote(parsed.password) if parsed.password else None
|
|
43
|
+
|
|
29
44
|
# Establish database connection
|
|
30
45
|
connection = psycopg2.connect(
|
|
31
46
|
host=db_host,
|
|
@@ -125,19 +140,37 @@ def delete_on_retention_period(table_delete: dict, batch_size: int = 100000, int
|
|
|
125
140
|
table_query = TableQuery(**table_delete)
|
|
126
141
|
except Exception as e:
|
|
127
142
|
logger.error(f"Error creating TableQuery object: {str(e)}")
|
|
128
|
-
raise ValueError("Invalid table_delete data format. Expected a dictionary with '
|
|
143
|
+
raise ValueError("Invalid table_delete data format. Expected a dictionary with 'table_name', 'column_name', and either 'db_url' or ('db_host', 'db_port', 'db_name', 'db_user', 'db_pass') keys.")
|
|
129
144
|
|
|
130
145
|
connection = None
|
|
131
146
|
cursor = None
|
|
132
147
|
|
|
133
148
|
try:
|
|
149
|
+
# Parse connection URL if provided
|
|
150
|
+
if table_query.db_url:
|
|
151
|
+
# Handle SQLAlchemy-style URLs (postgresql+asyncpg://)
|
|
152
|
+
url = table_query.db_url.replace('postgresql+asyncpg://', 'postgresql://')
|
|
153
|
+
parsed = urlparse(url)
|
|
154
|
+
|
|
155
|
+
db_host = parsed.hostname
|
|
156
|
+
db_port = parsed.port or 5432
|
|
157
|
+
db_name = parsed.path.lstrip('/')
|
|
158
|
+
db_user = unquote(parsed.username) if parsed.username else None
|
|
159
|
+
db_pass = unquote(parsed.password) if parsed.password else None
|
|
160
|
+
else:
|
|
161
|
+
db_host = table_query.db_host
|
|
162
|
+
db_port = table_query.db_port
|
|
163
|
+
db_name = table_query.db_name
|
|
164
|
+
db_user = table_query.db_user
|
|
165
|
+
db_pass = table_query.db_pass
|
|
166
|
+
|
|
134
167
|
# Establish database connection
|
|
135
168
|
connection = psycopg2.connect(
|
|
136
|
-
host=
|
|
137
|
-
port=
|
|
138
|
-
database=
|
|
139
|
-
user=
|
|
140
|
-
password=
|
|
169
|
+
host=db_host,
|
|
170
|
+
port=db_port,
|
|
171
|
+
database=db_name,
|
|
172
|
+
user=db_user,
|
|
173
|
+
password=db_pass
|
|
141
174
|
)
|
|
142
175
|
|
|
143
176
|
cursor = connection.cursor()
|
{kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/standalone/metarecogen/ckan_to_gn.py
RENAMED
|
@@ -92,7 +92,7 @@ def insert_gn_record(session, xsrf_token, xml_string):
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
# Send a put request to the endpoint to create record
|
|
95
|
-
response = session.put(GN_URL + '/geonetwork/srv/api/
|
|
95
|
+
response = session.put(GN_URL + '/geonetwork/srv/api/records',
|
|
96
96
|
data=xml_string,
|
|
97
97
|
params=params,
|
|
98
98
|
auth=(GN_USERNAME, GN_PASSWORD),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/mock/mock_generator.py
RENAMED
|
File without changes
|
{kubernetes_watch-0.1.13 → kubernetes_watch-0.1.14}/kube_watch/modules/providers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|