Skip to content

Commit

Permalink
Merge pull request #14 from remind101/gh-12
Browse files Browse the repository at this point in the history
Work on subset of stacks
  • Loading branch information
phobologic committed Mar 15, 2015
2 parents 8cef857 + c55ba3a commit f84aa9b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion scripts/stacker
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import copy
import yaml
from stacker.builder import StackBuilder

logger = logging.getLogger()

DEBUG_FORMAT = ('[%(asctime)s] %(levelname)s %(name)s:%(lineno)d'
'(%(funcName)s) - %(message)s')
Expand All @@ -19,6 +20,16 @@ INFO_FORMAT = ('[%(asctime)s] %(message)s')
ISO_8601 = '%Y-%m-%dT%H:%M:%S'


def get_stack_config(config, stack_list):
""" If given a stack list, extract the stack config for each in config.
If no stack list given, return stack config as is.
"""
if not stack_list:
return config['stacks']
return {k: v for k, v in config['stacks'] if k in stack_list}


class KeyValueAction(argparse.Action):
def __init__(self, option_strings, dest, nargs=None, **kwargs):
if nargs:
Expand Down Expand Up @@ -66,6 +77,12 @@ def parse_args():
help="Adds parameters from the command line "
"that can be used inside any of the stacks "
"being built. Can be specified more than once.")
parser.add_argument("--stacks", action="append",
metavar="STACKNAME", type=str,
help="Only work on the stacks given. Can be "
"specified more than once. If not specified "
"then stacker will work on all stacks in the "
"config file.")
parser.add_argument("--prompt", action="store_true",
help="Drop to python prompt rather than kicking off "
"build of the stack.")
Expand Down Expand Up @@ -103,4 +120,6 @@ if __name__ == '__main__':
print "Dropping into interactive console..."
code.InteractiveConsole(locals()).interact()
else:
builder.build(config['stacks'])
stacks = get_stack_config(config, args.stacks)
logger.info("Working on stacks: %s", ', '.join(stacks))
builder.build(stacks)

0 comments on commit f84aa9b

Please sign in to comment.