steps for launching
This commit is contained in:
Binary file not shown.
@@ -756,6 +756,46 @@ def list_gitea_repos():
|
||||
except Exception as e:
|
||||
return jsonify({'message': f'Failed to list repositories: {str(e)}'}), 400
|
||||
|
||||
@admin_api.route('/list-gitea-branches', methods=['POST'])
|
||||
@csrf.exempt
|
||||
def list_gitea_branches():
|
||||
"""List branches from a Gitea repository"""
|
||||
data = request.get_json()
|
||||
if not data or 'url' not in data or 'token' not in data or 'repo' not in data:
|
||||
return jsonify({'message': 'Missing required fields'}), 400
|
||||
|
||||
try:
|
||||
# Try different authentication methods
|
||||
headers = {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
|
||||
# First try token in Authorization header
|
||||
headers['Authorization'] = f'token {data["token"]}'
|
||||
|
||||
# Get repository branches
|
||||
response = requests.get(
|
||||
f'{data["url"]}/api/v1/repos/{data["repo"]}/branches',
|
||||
headers=headers
|
||||
)
|
||||
|
||||
# If that fails, try token as query parameter
|
||||
if response.status_code != 200:
|
||||
response = requests.get(
|
||||
f'{data["url"]}/api/v1/repos/{data["repo"]}/branches?token={data["token"]}',
|
||||
headers={'Accept': 'application/json'}
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
return jsonify({
|
||||
'branches': response.json()
|
||||
}), 200
|
||||
else:
|
||||
return jsonify({'message': f'Failed to list branches: {response.json().get("message", "Unknown error")}'}), 400
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({'message': f'Failed to list branches: {str(e)}'}), 400
|
||||
|
||||
@admin_api.route('/list-gitlab-repos', methods=['POST'])
|
||||
@csrf.exempt
|
||||
def list_gitlab_repos():
|
||||
|
||||
@@ -379,11 +379,13 @@ def init_routes(main_bp):
|
||||
# Get connection settings
|
||||
portainer_settings = KeyValueSettings.get_value('portainer_settings')
|
||||
nginx_settings = KeyValueSettings.get_value('nginx_settings')
|
||||
git_settings = KeyValueSettings.get_value('git_settings')
|
||||
|
||||
return render_template('main/instances.html',
|
||||
instances=instances,
|
||||
portainer_settings=portainer_settings,
|
||||
nginx_settings=nginx_settings)
|
||||
nginx_settings=nginx_settings,
|
||||
git_settings=git_settings)
|
||||
|
||||
@main_bp.route('/instances/add', methods=['POST'])
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user