salla-gitpuller 1.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salla_gitpuller
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables
5
5
  Author-email: Muhammad Zahid <zahidmuhammad127@gmail.com>
6
6
  License: MIT
@@ -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:
@@ -135,7 +135,8 @@ class GitPullExecutor:
135
135
  pipeline_uuid: str = "auto_git_pull",
136
136
  suppression_hours: int = 1,
137
137
  key_filename: Optional[str] = None,
138
- ssh_dir: str = "/home/src/.ssh"
138
+ ssh_dir: str = "/home/src/.ssh",
139
+ webhook_url: Optional[str] = None
139
140
  ) -> Dict[str, Any]:
140
141
  repo_name = git_url.split('/')[-1].replace('.git', '')
141
142
 
@@ -168,7 +169,17 @@ class GitPullExecutor:
168
169
 
169
170
  if should_alert:
170
171
  # Send alert
171
- self.slack_notifier.send_alert(repo_name, git_output[:1500])
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])
172
183
 
173
184
  # Save alert state
174
185
  self.alert_manager.save_alert_state(
@@ -4,12 +4,13 @@ from typing import Optional, Dict, Any
4
4
 
5
5
  class SlackNotifier:
6
6
 
7
- def __init__(self, webhook_url: Optional[str] = None):
7
+ def __init__(self, webhook_url: Optional[str] = None, timeout: int = 10):
8
8
  if not webhook_url:
9
9
  raise ValueError(
10
10
  "Slack webhook URL is required. Provide it as parameter."
11
11
  )
12
12
  self.webhook_url = webhook_url
13
+ self.timeout = timeout
13
14
 
14
15
  def create_failure_payload(self, repo_name: str, error_output: str) -> Dict[str, Any]:
15
16
  payload = {
@@ -49,7 +50,7 @@ class SlackNotifier:
49
50
  def send_alert(self, repo_name: str, error_output: str = "") -> bool:
50
51
  try:
51
52
  payload = self.create_failure_payload(repo_name, error_output)
52
- response = requests.post(self.webhook_url, json=payload, timeout=10)
53
+ response = requests.post(self.webhook_url, json=payload, timeout=self.timeout)
53
54
  response.raise_for_status()
54
55
  print("✅ Alert sent to Slack")
55
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.2"
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 = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salla_gitpuller
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables
5
5
  Author-email: Muhammad Zahid <zahidmuhammad127@gmail.com>
6
6
  License: MIT
File without changes