salla-gitpuller 1.0.1__tar.gz → 1.0.3__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.
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/PKG-INFO +1 -1
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/gitpuller/gitpull.py +17 -13
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/gitpuller/slack_notifier.py +6 -7
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/pyproject.toml +1 -1
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/salla_gitpuller.egg-info/PKG-INFO +1 -1
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/LICENSE +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/README.md +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/gitpuller/__init__.py +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/gitpuller/alert_manager.py +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/gitpuller/state_manager.py +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/gitpuller/utils.py +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/salla_gitpuller.egg-info/SOURCES.txt +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/salla_gitpuller.egg-info/dependency_links.txt +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/salla_gitpuller.egg-info/top_level.txt +0 -0
- {salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ class GitPullExecutor:
|
|
|
12
12
|
use_mage_ai: bool = False,
|
|
13
13
|
state_manager: Optional[Any] = None
|
|
14
14
|
):
|
|
15
|
-
self.slack_notifier = SlackNotifier(webhook_url=slack_webhook_url)
|
|
15
|
+
self.slack_notifier = SlackNotifier(webhook_url=slack_webhook_url) if slack_webhook_url else None
|
|
16
16
|
self.alert_manager = AlertManager(state_manager=state_manager, use_mage_ai=use_mage_ai)
|
|
17
17
|
|
|
18
18
|
def normalize_ssh_key(self, key_material: str) -> str:
|
|
@@ -63,14 +63,9 @@ class GitPullExecutor:
|
|
|
63
63
|
if not os.path.exists(repo_path):
|
|
64
64
|
raise ValueError(f"Repo path does not exist: {repo_path}")
|
|
65
65
|
|
|
66
|
-
#
|
|
67
|
-
if not ssh_key
|
|
68
|
-
|
|
69
|
-
ssh_key = os.environ.get(key_env_name)
|
|
70
|
-
if not ssh_key:
|
|
71
|
-
raise ValueError(f"Missing env var {key_env_name} with the PRIVATE deploy key")
|
|
72
|
-
elif not ssh_key:
|
|
73
|
-
raise ValueError("SSH key is required. Provide it directly or set workspace_name.")
|
|
66
|
+
# Validate SSH key
|
|
67
|
+
if not ssh_key:
|
|
68
|
+
raise ValueError("SSH key is required. Provide it directly as a parameter.")
|
|
74
69
|
|
|
75
70
|
# Normalize key
|
|
76
71
|
ssh_key = self.normalize_ssh_key(ssh_key)
|
|
@@ -93,7 +88,6 @@ class GitPullExecutor:
|
|
|
93
88
|
|
|
94
89
|
git_output = ""
|
|
95
90
|
git_status = "success"
|
|
96
|
-
key_env_var_used = f"{workspace_name}_SSHKEY" if workspace_name else "N/A"
|
|
97
91
|
|
|
98
92
|
original_dir = None
|
|
99
93
|
try:
|
|
@@ -129,7 +123,6 @@ class GitPullExecutor:
|
|
|
129
123
|
"repo_path": repo_path,
|
|
130
124
|
"git_pull_status": git_status,
|
|
131
125
|
"git_pull_output": git_output.strip(),
|
|
132
|
-
"key_env_var_used": key_env_var_used,
|
|
133
126
|
}
|
|
134
127
|
|
|
135
128
|
def execute_with_alerting(
|
|
@@ -142,7 +135,8 @@ class GitPullExecutor:
|
|
|
142
135
|
pipeline_uuid: str = "auto_git_pull",
|
|
143
136
|
suppression_hours: int = 1,
|
|
144
137
|
key_filename: Optional[str] = None,
|
|
145
|
-
ssh_dir: str = "/home/src/.ssh"
|
|
138
|
+
ssh_dir: str = "/home/src/.ssh",
|
|
139
|
+
webhook_url: Optional[str] = None
|
|
146
140
|
) -> Dict[str, Any]:
|
|
147
141
|
repo_name = git_url.split('/')[-1].replace('.git', '')
|
|
148
142
|
|
|
@@ -175,7 +169,17 @@ class GitPullExecutor:
|
|
|
175
169
|
|
|
176
170
|
if should_alert:
|
|
177
171
|
# Send alert
|
|
178
|
-
|
|
172
|
+
# Use provided webhook_url if given, otherwise use the one from __init__
|
|
173
|
+
if webhook_url:
|
|
174
|
+
notifier = SlackNotifier(webhook_url=webhook_url)
|
|
175
|
+
elif self.slack_notifier:
|
|
176
|
+
notifier = self.slack_notifier
|
|
177
|
+
else:
|
|
178
|
+
print("⚠️ No webhook URL provided, skipping Slack alert")
|
|
179
|
+
notifier = None
|
|
180
|
+
|
|
181
|
+
if notifier:
|
|
182
|
+
notifier.send_alert(repo_name, git_output[:1500])
|
|
179
183
|
|
|
180
184
|
# Save alert state
|
|
181
185
|
self.alert_manager.save_alert_state(
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import requests
|
|
3
2
|
from typing import Optional, Dict, Any
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
class SlackNotifier:
|
|
7
6
|
|
|
8
|
-
def __init__(self, webhook_url: Optional[str] = None):
|
|
9
|
-
|
|
10
|
-
if not self.webhook_url:
|
|
7
|
+
def __init__(self, webhook_url: Optional[str] = None, timeout: int = 10):
|
|
8
|
+
if not webhook_url:
|
|
11
9
|
raise ValueError(
|
|
12
|
-
"Slack webhook URL is required. "
|
|
13
|
-
"Provide it as parameter or set CDM_SLACK_WEBHOOK_URL environment variable."
|
|
10
|
+
"Slack webhook URL is required. Provide it as parameter."
|
|
14
11
|
)
|
|
12
|
+
self.webhook_url = webhook_url
|
|
13
|
+
self.timeout = timeout
|
|
15
14
|
|
|
16
15
|
def create_failure_payload(self, repo_name: str, error_output: str) -> Dict[str, Any]:
|
|
17
16
|
payload = {
|
|
@@ -51,7 +50,7 @@ class SlackNotifier:
|
|
|
51
50
|
def send_alert(self, repo_name: str, error_output: str = "") -> bool:
|
|
52
51
|
try:
|
|
53
52
|
payload = self.create_failure_payload(repo_name, error_output)
|
|
54
|
-
response = requests.post(self.webhook_url, json=payload, timeout=
|
|
53
|
+
response = requests.post(self.webhook_url, json=payload, timeout=self.timeout)
|
|
55
54
|
response.raise_for_status()
|
|
56
55
|
print("✅ Alert sent to Slack")
|
|
57
56
|
return True
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "salla_gitpuller"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.3"
|
|
8
8
|
description = "A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{salla_gitpuller-1.0.1 → salla_gitpuller-1.0.3}/salla_gitpuller.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|