Skip to content

Commit 9864ce5

Browse files
authored
Support multiple config.json symlinks in redeploy.py (element-hq#4644)
* Support multiple config.json symlinks in redeploy.py * Review comments
1 parent f7d282f commit 9864ce5

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

scripts/deploy.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def __init__(self):
6363
self.packages_path = "."
6464
self.bundles_path = None
6565
self.should_clean = False
66-
self.config_location = None
66+
# filename -> symlink path e.g 'config.localhost.json' => '../localhost/config.json'
67+
self.config_locations = {}
6768
self.verify_signature = True
6869

6970
def deploy(self, tarball, extract_path):
@@ -95,11 +96,12 @@ def deploy(self, tarball, extract_path):
9596

9697
print ("Extracted into: %s" % extracted_dir)
9798

98-
if self.config_location:
99-
create_relative_symlink(
100-
target=self.config_location,
101-
linkname=os.path.join(extracted_dir, 'config.json')
102-
)
99+
if self.config_locations:
100+
for config_filename, config_loc in self.config_locations.iteritems():
101+
create_relative_symlink(
102+
target=config_loc,
103+
linkname=os.path.join(extracted_dir, config_filename)
104+
)
103105

104106
if self.bundles_path:
105107
extracted_bundles = os.path.join(extracted_dir, 'bundles')
@@ -178,6 +180,8 @@ def download_file(self, url):
178180
deployer.packages_path = args.packages_dir
179181
deployer.bundles_path = args.bundles_dir
180182
deployer.should_clean = args.clean
181-
deployer.config_location = args.config
183+
deployer.config_locations = {
184+
"config.json": args.config,
185+
}
182186

183187
deployer.deploy(args.tarball, args.extract_path)

scripts/redeploy.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,16 @@ def deploy_tarball(tar_gz_url, build_dir):
185185
to the /vector directory INSIDE the tarball."
186186
)
187187
)
188+
189+
def _raise(ex):
190+
raise ex
191+
192+
# --config config.json=../../config.json --config config.localhost.json=./localhost.json
188193
parser.add_argument(
189-
"--config", dest="config", help=(
190-
"Write a symlink to config.json in the extracted tarball. \
191-
To this location."
194+
"--config", action="append", dest="configs",
195+
type=lambda kv: kv.split("=", 1) if "=" in kv else _raise(Exception("Missing =")), help=(
196+
"A list of configs to symlink into the extracted tarball. \
197+
For example, --config config.json=../config.json config2.json=../test/config.json"
192198
)
193199
)
194200
parser.add_argument(
@@ -212,7 +218,8 @@ def deploy_tarball(tar_gz_url, build_dir):
212218
deployer = Deployer()
213219
deployer.bundles_path = args.bundles_dir
214220
deployer.should_clean = args.clean
215-
deployer.config_location = args.config
221+
deployer.config_locations = dict(args.configs) if args.configs else {}
222+
216223

217224
# we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to
218225
# the jenkins server (and the jenkins server not being compromised and/or
@@ -225,13 +232,13 @@ def deploy_tarball(tar_gz_url, build_dir):
225232
deploy_tarball(args.tarball_uri, build_dir)
226233
else:
227234
print(
228-
"Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Config location: %s" %
235+
"Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Config locations: %s" %
229236
(args.port,
230237
arg_extract_path,
231238
" (clean after)" if deployer.should_clean else "",
232239
arg_symlink,
233240
arg_jenkins_url,
234-
deployer.config_location,
241+
deployer.config_locations,
235242
)
236243
)
237244
app.run(host="0.0.0.0", port=args.port, debug=True)

0 commit comments

Comments
 (0)