mirror of
https://github.com/kennethreitz/bob-builder-1.git
synced 2026-06-05 23:10:17 +00:00
bda46256d9
all output from the formula build is on stdout already this allows easy separating of the two into e.g. raw compile logs without bob's messages
70 lines
1.5 KiB
Python
70 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
"""Usage: bob build <formula> [--name=FILE]
|
|
bob deploy <formula> [--overwrite] [--name=<FILE>]
|
|
|
|
Build formula and optionally deploy it.
|
|
|
|
Options:
|
|
-h --help
|
|
--overwrite allow overwriting of deployed archives.
|
|
--name=<path> allow separate name for the archived output
|
|
|
|
Configuration:
|
|
Environment Variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET, S3_PREFIX (optional), UPSTREAM_S3_BUCKET (optional), UPSTREAM_S3_PREFIX (optional)
|
|
"""
|
|
import sys
|
|
|
|
from docopt import docopt
|
|
from .models import Formula
|
|
from .utils import print_stderr
|
|
|
|
|
|
def build(formula, name=None):
|
|
f = Formula(path=formula, override_path=name)
|
|
|
|
try:
|
|
assert f.exists
|
|
except AssertionError:
|
|
print_stderr("Formula {} doesn't exist.".format(formula), title='ERROR')
|
|
sys.exit(1)
|
|
|
|
# CLI lies ahead.
|
|
f.build()
|
|
|
|
return f
|
|
|
|
|
|
def deploy(formula, overwrite, name):
|
|
f = build(formula, name)
|
|
|
|
print_stderr('Archiving.')
|
|
f.archive()
|
|
|
|
print_stderr('Deploying.')
|
|
f.deploy(allow_overwrite=overwrite)
|
|
|
|
|
|
def main():
|
|
args = docopt(__doc__)
|
|
|
|
formula = args['<formula>']
|
|
do_build = args['build']
|
|
do_deploy = args['deploy']
|
|
do_overwrite = args['--overwrite']
|
|
do_name = args['--name']
|
|
|
|
if do_build:
|
|
build(formula, name=do_name)
|
|
|
|
if do_deploy:
|
|
deploy(formula, overwrite=do_overwrite, name=do_name)
|
|
|
|
|
|
def dispatch():
|
|
try:
|
|
main()
|
|
except KeyboardInterrupt:
|
|
print('ool.')
|
|
sys.exit(130)
|