ssh: allow customizing the base_url for running application.
Allows proper URLs inside events when executing on SSH calls.
This commit is contained in:
parent
d394c2653a
commit
38c78cd493
5 changed files with 61 additions and 5 deletions
|
|
@ -162,6 +162,11 @@ startup.import_repos = false
|
|||
## the repository.
|
||||
#archive_cache_dir = /tmp/tarballcache
|
||||
|
||||
## URL at which the application is running. This is used for bootstraping
|
||||
## requests in context when no web request is available. Used in ishell, or
|
||||
## SSH calls. Set this for events to receive proper url for SSH calls.
|
||||
app.base_url = http://rhodecode.local
|
||||
|
||||
## change this to unique ID for security
|
||||
app_instance_uuid = rc-production
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,11 @@ startup.import_repos = false
|
|||
## the repository.
|
||||
#archive_cache_dir = /tmp/tarballcache
|
||||
|
||||
## URL at which the application is running. This is used for bootstraping
|
||||
## requests in context when no web request is available. Used in ishell, or
|
||||
## SSH calls. Set this for events to receive proper url for SSH calls.
|
||||
app.base_url = http://rhodecode.local
|
||||
|
||||
## change this to unique ID for security
|
||||
app_instance_uuid = rc-production
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import logging
|
|||
|
||||
import click
|
||||
|
||||
from pyramid.paster import bootstrap, setup_logging
|
||||
from pyramid.request import Request
|
||||
from pyramid.paster import setup_logging
|
||||
|
||||
from rhodecode.lib.pyramid_utils import bootstrap
|
||||
from .backends import SshWrapper
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -68,9 +68,7 @@ def main(ini_path, mode, user, user_id, key_id, shell, debug):
|
|||
'of this script.')
|
||||
connection_info = os.environ.get('SSH_CONNECTION', '')
|
||||
|
||||
# TODO(marcink): configure the running host...
|
||||
request = Request.blank('/', base_url='http://localhost:8080')
|
||||
with bootstrap(ini_path, request=request) as env:
|
||||
with bootstrap(ini_path) as env:
|
||||
try:
|
||||
ssh_wrapper = SshWrapper(
|
||||
command, connection_info, mode,
|
||||
|
|
|
|||
43
rhodecode/lib/pyramid_utils.py
Normal file
43
rhodecode/lib/pyramid_utils.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2016-2017 RhodeCode GmbH
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License, version 3
|
||||
# (only), as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import ConfigParser
|
||||
from pyramid.paster import bootstrap as pyramid_bootstrap
|
||||
from pyramid.request import Request
|
||||
|
||||
|
||||
def get_config(ini_path):
|
||||
parser = ConfigParser.ConfigParser()
|
||||
parser.read(ini_path)
|
||||
return parser
|
||||
|
||||
|
||||
def bootstrap(config_uri, request=None, options=None):
|
||||
|
||||
config = get_config(config_uri)
|
||||
base_url = 'http://rhodecode.local'
|
||||
try:
|
||||
base_url = config.get('app:main', 'app.base_url')
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||
pass
|
||||
|
||||
request = request or Request.blank('/', base_url=base_url)
|
||||
|
||||
return pyramid_bootstrap(config_uri, request=request, options=options)
|
||||
|
|
@ -207,6 +207,11 @@ startup.import_repos = true
|
|||
## the repository.
|
||||
#archive_cache_dir = /tmp/tarballcache
|
||||
|
||||
## URL at which the application is running. This is used for bootstraping
|
||||
## requests in context when no web request is available. Used in ishell, or
|
||||
## SSH calls. Set this for events to receive proper url for SSH calls.
|
||||
app.base_url = http://rhodecode.local
|
||||
|
||||
## change this to unique ID for security
|
||||
app_instance_uuid = rc-production
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue