Pushed by: unknown_user
Timestamp: 2026-01-24T23:24:56.039745
masterdev
Splunk Git Pusher 3 months ago
parent e7be2c8f38
commit 043ca8b008

@ -98,10 +98,11 @@ class GitPusherRequestHandler(BaseHTTPRequestHandler):
logger.info(f"Created temp directory: {temp_dir}")
try:
# Préparer l'URL Git
# Préparer l'URL Git avec le token
git_url_with_token = self.prepare_git_url(git_url, git_token)
# Cloner
logger.info(f"Git URL prepared (token inserted)")
logger.debug(f"Git URL with token: {git_url_with_token}")
logger.info("Cloning repository...")
self.clone_repository(temp_dir, git_url_with_token, git_branch)
@ -122,6 +123,11 @@ class GitPusherRequestHandler(BaseHTTPRequestHandler):
if os.path.exists(app_path):
logger.info(f"Copying app {app_name} from {app_path}")
# Supprimer le dossier s'il existe déjà
if os.path.exists(dest_path):
logger.info(f"Removing existing app directory: {dest_path}")
shutil.rmtree(dest_path)
# Copier le dossier
shutil.copytree(app_path, dest_path)
logger.info(f"Copied app: {app_name}")
else:
@ -179,10 +185,25 @@ class GitPusherRequestHandler(BaseHTTPRequestHandler):
@staticmethod
def prepare_git_url(git_url, token):
"""Préparer l'URL Git avec le token"""
if git_url.startswith('https://'):
parts = git_url.replace('https://', '').split('/')
return f"https://{token}@{'/'.join(parts)}"
"""Préparer l'URL Git avec le token inséré"""
logger.info(f"Preparing git URL with token")
# Si l'URL contient déjà un token (format: https://user:token@host/repo)
# on le remplace
if '@' in git_url:
# Extraire la partie sans le token
protocol = git_url.split('://')[0]
rest = git_url.split('://', 1)[1]
host_and_path = rest.split('@', 1)[1] if '@' in rest else rest
return f"{protocol}://{token}@{host_and_path}"
# Si l'URL est juste https://host/repo (sans credentials)
if git_url.startswith('https://') or git_url.startswith('http://'):
protocol = git_url.split('://')[0]
host_and_path = git_url.split('://', 1)[1]
# Insérer le token au format user:token@host ou juste token@host
return f"{protocol}://{token}@{host_and_path}"
return git_url
@staticmethod

@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<dashboard version="1.1" script="git_pusher.js">
<dashboard version="1.2" script="git_pusher.js" theme="light">
<label>Git Pusher - Push Applications to Git</label>
<description>Push Splunk applications to Git repository</description>
<!-- Recherche cachée (non utilisée, mais gardée pour compatibilité) -->
<search id="dsearch">
<query>| rest /services/apps/local | search disabled=0 | fields name, label, description | sort label</query>
<earliest>-4h@h</earliest>
<latest>now</latest>
</search>
<row>
<panel>
<title>Configuration &amp; Application Selection</title>
@ -180,24 +178,24 @@
<div class="form-group">
<label for="git-url">Git Repository URL:</label>
<input type="text" id="git-url" placeholder="https://github.com/username/repo.git" />
<input type="text" id="git-url" placeholder="https://github.com/username/repo.git"/>
</div>
<div class="form-group">
<label for="git-branch">Target Branch:</label>
<input type="text" id="git-branch" placeholder="main" value="main" />
<input type="text" id="git-branch" placeholder="main" value="main"/>
</div>
<div class="form-group">
<label for="git-token">Git Token/Password:</label>
<input type="password" id="git-token" placeholder="Enter your Git token or password" />
<input type="password" id="git-token" placeholder="Enter your Git token or password"/>
</div>
<div class="form-group">
<label>Available Applications:</label>
<div class="dashboard-list" id="dashboard-list">
<div class="dashboard-loading">
<div class="spinner"></div>
<div class="spinner"/>
<span>Loading applications...</span>
</div>
</div>
@ -206,7 +204,7 @@
<div class="form-group">
<label for="commit-message">Commit Message:</label>
<textarea id="commit-message" placeholder="Describe your changes... e.g., 'Update applications with new dashboards'"></textarea>
<textarea id="commit-message" placeholder="Describe your changes... e.g., 'Update applications with new dashboards'"/>
</div>
<div class="button-group">
@ -219,7 +217,7 @@
</div>
<div class="loading" id="loading">
<div class="spinner"></div>
<div class="spinner"/>
<span id="loading-text">Pushing applications to Git...</span>
</div>
@ -234,7 +232,6 @@
</html>
</panel>
</row>
<row>
<panel>
<title>Push History</title>
@ -251,5 +248,4 @@
</table>
</panel>
</row>
</dashboard>

@ -16,4 +16,4 @@ modtime = 1769276443.812957000
[views/git_pusher_-_push_applications_to_git]
owner = admin
version = 10.0.2
modtime = 1769283309.402236000
modtime = 1769292908.163699000

Loading…
Cancel
Save