salla-gitpuller 1.2.1__tar.gz → 1.2.2__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.2.1
3
+ Version: 1.2.2
4
4
  Summary: A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables
5
5
  Author-email: Mohammed Junaid <safijunaid.ss@gmail.com>, Muhammad Zahid <zahidmuhammad127@gmail.com>
6
6
  License: MIT
@@ -5,7 +5,7 @@ from .slack_notifier import SlackNotifier
5
5
  from .utils import transform_custom, get_repo_path, get_env_base_path
6
6
 
7
7
 
8
- __version__ = "1.2.1"
8
+ __version__ = "1.2.2"
9
9
  __all__ = [
10
10
  "GitPullExecutor",
11
11
  "AlertManager",
@@ -270,8 +270,8 @@ class GitPullExecutor:
270
270
  ``suppression_hours`` caps how often the *same* error is alerted on,
271
271
  avoiding Slack spam when a broken state persists across many runs.
272
272
  """
273
- # webhook_url is a fallback only; CDM_PROD_SLACK_BOT_TOKEN still wins
274
- # so Mage callers that pass CDM_SLACK_WEBHOOK_URL stay on the daily thread.
273
+ # webhook_url is a fallback only; WP_SLACK_DB_ALERTS_TOKEN still wins
274
+ # so Mage callers that pass a webhook stay on the daily thread.
275
275
  if webhook_url and not self.slack_notifier.bot_token:
276
276
  notifier = SlackNotifier(webhook_url=webhook_url)
277
277
  else:
@@ -10,6 +10,10 @@ import requests
10
10
  SLACK_POST_MESSAGE_URL = "https://slack.com/api/chat.postMessage"
11
11
  SLACK_CONVERSATIONS_HISTORY_URL = "https://slack.com/api/conversations.history"
12
12
  DEFAULT_SLACK_CHANNEL = "C05MLHR55JT"
13
+ SLACK_WEBHOOK_MAP_KEY = "db-ops-log"
14
+
15
+ # Unified across every Mage deployment — do not prefix with MAGE_WORKSPACE_NAME.
16
+ # One hash per channel per day; field = gitpuller workspace, value = Slack thread_ts.
13
17
  REDIS_THREAD_KEY_PREFIX = "gitpuller:slack_thread"
14
18
  REDIS_CREATE_LOCK_TTL_SECONDS = 120
15
19
  REDIS_ERROR_MAX_CHARS = 1500
@@ -27,6 +31,23 @@ def _env(*names: str, default: str = "") -> str:
27
31
  return default
28
32
 
29
33
 
34
+ def _resolve_slack_webhook(explicit: Optional[str] = None) -> Optional[str]:
35
+ """Prefer an explicit URL, then CDM_SLACK_WEBHOOKS['db-ops-log']."""
36
+ if explicit and str(explicit).strip():
37
+ return str(explicit).strip()
38
+ raw = os.environ.get("CDM_SLACK_WEBHOOKS")
39
+ if raw and str(raw).strip():
40
+ try:
41
+ webhooks = json.loads(str(raw).strip())
42
+ if isinstance(webhooks, dict):
43
+ entry = webhooks.get(SLACK_WEBHOOK_MAP_KEY)
44
+ if entry and str(entry).strip():
45
+ return str(entry).strip()
46
+ except json.JSONDecodeError as exc:
47
+ print(f"⚠️ CDM_SLACK_WEBHOOKS is not valid JSON ({exc})")
48
+ return _env("CDM_SLACK_WEBHOOK_URL") or None
49
+
50
+
30
51
  def _get_redis_client():
31
52
  """WP_REDIS_* env vars first, then Mage io_config.yaml, then REDIS_*."""
32
53
  global _redis_client, _redis_init_attempted
@@ -113,13 +134,13 @@ class SlackNotifier:
113
134
  (channel or os.environ.get("CDM_PROD_DB_SLACK_CHANNEL") or "").strip()
114
135
  or DEFAULT_SLACK_CHANNEL
115
136
  )
116
- self.webhook_url = (webhook_url or os.environ.get("CDM_SLACK_WEBHOOK_URL") or "").strip() or None
137
+ self.webhook_url = _resolve_slack_webhook(webhook_url)
117
138
  self._thread_ts_cache: Dict[str, str] = {}
118
139
 
119
140
  if not self.bot_token and not self.webhook_url:
120
141
  print(
121
142
  "⚠️ Slack not configured; skipping alerts "
122
- "(set WP_SLACK_DB_ALERTS_TOKEN, or CDM_SLACK_WEBHOOK_URL as fallback)"
143
+ "(set WP_SLACK_DB_ALERTS_TOKEN, or CDM_SLACK_WEBHOOKS['db-ops-log'])"
123
144
  )
124
145
  elif not self.bot_token:
125
146
  print(
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "salla_gitpuller"
7
- version = "1.2.1"
7
+ version = "1.2.2"
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.2.1
3
+ Version: 1.2.2
4
4
  Summary: A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables
5
5
  Author-email: Mohammed Junaid <safijunaid.ss@gmail.com>, Muhammad Zahid <zahidmuhammad127@gmail.com>
6
6
  License: MIT
File without changes