mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
deploy: find rclone.conf in the root of the repo
This enables the same way of managing the config as existed with s3cmd's s3cfg file.
This commit is contained in:
parent
0a87deff1c
commit
1f9fb16844
2 changed files with 41 additions and 0 deletions
|
|
@ -49,6 +49,8 @@ BINARY_TRANSPARENCY_DIR = 'binary_transparency'
|
|||
|
||||
REMOTE_HOSTNAME_REGEX = re.compile(r'\W*\w+\W+(\w+).*')
|
||||
|
||||
EMBEDDED_RCLONE_CONF = 'rclone.conf'
|
||||
|
||||
|
||||
def _get_index_file_paths(base_dir):
|
||||
"""Return the list of files to be synced last, since they finalize the deploy.
|
||||
|
|
@ -131,6 +133,9 @@ def update_remote_storage_with_rclone(
|
|||
"--include" implies "--exclude **" at the end of an rclone internal
|
||||
filter list.
|
||||
|
||||
If rclone.conf is in the root of the repo, then it will be preferred
|
||||
over the rclone default config paths.
|
||||
|
||||
"""
|
||||
logging.debug(_('Using rclone to sync to "{name}"').format(name=awsbucket))
|
||||
|
||||
|
|
@ -148,6 +153,9 @@ def update_remote_storage_with_rclone(
|
|||
)
|
||||
sys.exit(1)
|
||||
configfilename = path
|
||||
elif os.path.exists(EMBEDDED_RCLONE_CONF):
|
||||
path = EMBEDDED_RCLONE_CONF # in this case, only for display
|
||||
configfilename = EMBEDDED_RCLONE_CONF
|
||||
else:
|
||||
configfilename = None
|
||||
output = subprocess.check_output(['rclone', 'config', 'file'], text=True)
|
||||
|
|
|
|||
|
|
@ -288,6 +288,39 @@ class DeployTest(unittest.TestCase):
|
|||
],
|
||||
)
|
||||
|
||||
@mock.patch('subprocess.check_output', _mock_rclone_config_file)
|
||||
@mock.patch('subprocess.call')
|
||||
def test_update_remote_storage_with_rclone_mock_default_user_path(self, mock_call):
|
||||
self.last_cmd = None
|
||||
|
||||
def _mock_subprocess_call(cmd):
|
||||
self.last_cmd = cmd
|
||||
return 0
|
||||
|
||||
mock_call.side_effect = _mock_subprocess_call
|
||||
|
||||
os.chdir(self.testdir)
|
||||
config_name = 'test_local_config'
|
||||
Path('rclone.conf').write_text('placeholder, contents ignored')
|
||||
|
||||
awsbucket = 'test_bucket_folder'
|
||||
fdroidserver.deploy.config['awsbucket'] = awsbucket
|
||||
fdroidserver.deploy.config['rclone_config'] = config_name
|
||||
fdroidserver.deploy.update_remote_storage_with_rclone('repo', awsbucket)
|
||||
self.maxDiff = None
|
||||
self.assertEqual(
|
||||
self.last_cmd,
|
||||
[
|
||||
'rclone',
|
||||
'sync',
|
||||
'--delete-after',
|
||||
'--config',
|
||||
fdroidserver.deploy.EMBEDDED_RCLONE_CONF,
|
||||
'repo',
|
||||
f'{config_name}:{awsbucket}/fdroid/repo',
|
||||
],
|
||||
)
|
||||
|
||||
def test_update_serverwebroot(self):
|
||||
"""rsync works with file paths, so this test uses paths for the URLs"""
|
||||
os.chdir(self.testdir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue