Rename symlink to 'include' & add to redeploy

Because redeploy.py already has a 'symlink' option that does
something else.
pull/5090/head
David Baker 2017-09-20 17:22:47 +01:00
parent 6ff91789b2
commit b9b4ac3166
2 changed files with 16 additions and 14 deletions

View File

@ -166,7 +166,7 @@ if __name__ == "__main__":
) )
) )
parser.add_argument( parser.add_argument(
"--symlink", nargs='*', default='./config*.json', help=( "--include", nargs='*', default='./config*.json', help=(
"Symlink these files into the root of the deployed tarball. \ "Symlink these files into the root of the deployed tarball. \
Useful for config files and home pages. Supports glob syntax. \ Useful for config files and home pages. Supports glob syntax. \
(Default: '%(default)s')" (Default: '%(default)s')"
@ -187,8 +187,8 @@ if __name__ == "__main__":
deployer.symlink_paths = {} deployer.symlink_paths = {}
for symlink in args.symlink: for include in args.include:
deployer.symlink_paths.update({ os.path.basename(pth): pth for pth in glob.iglob(symlink) }) deployer.symlink_paths.update({ os.path.basename(pth): pth for pth in glob.iglob(include) })
print("%r", (deployer.symlink_paths,)) print("%r", (deployer.symlink_paths,))

View File

@ -15,6 +15,7 @@ import json, requests, tarfile, argparse, os, errno
import time import time
import traceback import traceback
from urlparse import urljoin from urlparse import urljoin
import glob
from flask import Flask, jsonify, request, abort from flask import Flask, jsonify, request, abort
@ -188,15 +189,12 @@ if __name__ == "__main__":
) )
) )
def _raise(ex): # --include ../../config.json ./localhost.json homepages/*
raise ex
# --config config.json=../../config.json --config config.localhost.json=./localhost.json
parser.add_argument( parser.add_argument(
"--config", action="append", dest="configs", "--include", nargs='*', default='./config*.json', help=(
type=lambda kv: kv.split("=", 1) if "=" in kv else _raise(Exception("Missing =")), help=( "Symlink these files into the root of the deployed tarball. \
"A list of configs to symlink into the extracted tarball. \ Useful for config files and home pages. Supports glob syntax. \
For example, --config config.json=../config.json config2.json=../test/config.json" (Default: '%(default)s')"
) )
) )
parser.add_argument( parser.add_argument(
@ -220,7 +218,11 @@ if __name__ == "__main__":
deployer = Deployer() deployer = Deployer()
deployer.bundles_path = args.bundles_dir deployer.bundles_path = args.bundles_dir
deployer.should_clean = args.clean deployer.should_clean = args.clean
deployer.config_locations = dict(args.configs) if args.configs else {}
deployer.symlink_paths = {}
for include in args.include:
deployer.symlink_paths.update({ os.path.basename(pth): pth for pth in glob.iglob(include) })
# we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to # we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to
@ -234,13 +236,13 @@ if __name__ == "__main__":
deploy_tarball(args.tarball_uri, build_dir) deploy_tarball(args.tarball_uri, build_dir)
else: else:
print( print(
"Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Config locations: %s" % "Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Include patterns: %s" %
(args.port, (args.port,
arg_extract_path, arg_extract_path,
" (clean after)" if deployer.should_clean else "", " (clean after)" if deployer.should_clean else "",
arg_symlink, arg_symlink,
arg_jenkins_url, arg_jenkins_url,
deployer.config_locations, deployer.symlink_paths,
) )
) )
app.run(host="0.0.0.0", port=args.port, debug=True) app.run(host="0.0.0.0", port=args.port, debug=True)