Fix cli, add minimal README
This commit is contained in:
parent
4fa00e0f92
commit
ce14bd212f
32
README.md
32
README.md
@ -1 +1,31 @@
|
|||||||
Toolset to render and manage AWS Cloudformation
|
# CloudBender
|
||||||
|
|
||||||
|
# About
|
||||||
|
|
||||||
|
Toolset to render and manage [AWS CloudFormation](https://aws.amazon.com/cloudformation).
|
||||||
|
|
||||||
|
|
||||||
|
# Install
|
||||||
|
|
||||||
|
`$ pip install cloudbender`
|
||||||
|
|
||||||
|
|
||||||
|
# CLI
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage: cloudbender [OPTIONS] COMMAND [ARGS]...
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--version Show the version and exit.
|
||||||
|
--debug Turn on debug logging.
|
||||||
|
--dir TEXT Specify cloudbender project directory.
|
||||||
|
--help Show this message and exit.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
clean Deletes all previously rendered files locally
|
||||||
|
create-change-set Creates a change set for an existing stack
|
||||||
|
delete Deletes stacks or stack groups
|
||||||
|
provision Creates or updates stacks or stack groups
|
||||||
|
render Renders template and its parameters
|
||||||
|
validate Validates already rendered templates using cfn-lint
|
||||||
|
```
|
||||||
|
@ -2,7 +2,7 @@ import logging
|
|||||||
|
|
||||||
__author__ = 'Stefan Reimer'
|
__author__ = 'Stefan Reimer'
|
||||||
__email__ = 'stefan@zero-downtimet.net'
|
__email__ = 'stefan@zero-downtimet.net'
|
||||||
__version__ = '0.3.2'
|
__version__ = '0.3.3'
|
||||||
|
|
||||||
|
|
||||||
# Set up logging to ``/dev/null`` like a library is supposed to.
|
# Set up logging to ``/dev/null`` like a library is supposed to.
|
||||||
|
@ -25,17 +25,17 @@ def cli(ctx, debug, directory):
|
|||||||
cb.read_config()
|
cb.read_config()
|
||||||
cb.dump_config()
|
cb.dump_config()
|
||||||
|
|
||||||
ctx.obj['cb'] = cb
|
ctx.obj = cb
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_names", nargs=-1)
|
@click.argument("stack_names", nargs=-1)
|
||||||
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
||||||
@click.pass_context
|
@click.pass_obj
|
||||||
def render(ctx, stack_names, multi):
|
def render(cb, stack_names, multi):
|
||||||
""" Renders template and its parameters """
|
""" Renders template and its parameters """
|
||||||
|
|
||||||
stacks = _find_stacks(ctx, stack_names, multi)
|
stacks = _find_stacks(cb, stack_names, multi)
|
||||||
|
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
s.render()
|
s.render()
|
||||||
@ -45,10 +45,10 @@ def render(ctx, stack_names, multi):
|
|||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_names", nargs=-1)
|
@click.argument("stack_names", nargs=-1)
|
||||||
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
||||||
@click.pass_context
|
@click.pass_obj
|
||||||
def validate(ctx, stack_names, multi):
|
def validate(cb, stack_names, multi):
|
||||||
""" Validates already rendered templates using cfn-lint """
|
""" Validates already rendered templates using cfn-lint """
|
||||||
stacks = _find_stacks(ctx, stack_names, multi)
|
stacks = _find_stacks(cb, stack_names, multi)
|
||||||
|
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
s.validate()
|
s.validate()
|
||||||
@ -57,10 +57,10 @@ def validate(ctx, stack_names, multi):
|
|||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_name")
|
@click.argument("stack_name")
|
||||||
@click.argument("change_set_name")
|
@click.argument("change_set_name")
|
||||||
@click.pass_context
|
@click.pass_obj
|
||||||
def create_change_set(ctx, stack_name, change_set_name):
|
def create_change_set(cb, stack_name, change_set_name):
|
||||||
""" Creates a change set for an existing stack """
|
""" Creates a change set for an existing stack """
|
||||||
stacks = _find_stacks(ctx, [stack_name])
|
stacks = _find_stacks(cb, [stack_name])
|
||||||
|
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
s.create_change_set(change_set_name)
|
s.create_change_set(change_set_name)
|
||||||
@ -69,13 +69,13 @@ def create_change_set(ctx, stack_name, change_set_name):
|
|||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_names", nargs=-1)
|
@click.argument("stack_names", nargs=-1)
|
||||||
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
||||||
@click.pass_context
|
@click.pass_obj
|
||||||
def provision(ctx, stack_names, multi):
|
def provision(cb, stack_names, multi):
|
||||||
""" Creates or updates stacks or stack groups """
|
""" Creates or updates stacks or stack groups """
|
||||||
|
|
||||||
stacks = _find_stacks(ctx, stack_names, multi)
|
stacks = _find_stacks(cb, stack_names, multi)
|
||||||
|
|
||||||
for step in sort_stacks(ctx, stacks):
|
for step in sort_stacks(cb, stacks):
|
||||||
if step:
|
if step:
|
||||||
with ThreadPoolExecutor(max_workers=len(step)) as group:
|
with ThreadPoolExecutor(max_workers=len(step)) as group:
|
||||||
futures = []
|
futures = []
|
||||||
@ -93,13 +93,13 @@ def provision(ctx, stack_names, multi):
|
|||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_names", nargs=-1)
|
@click.argument("stack_names", nargs=-1)
|
||||||
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
@click.option("--multi", is_flag=True, help="Allow more than one stack to match")
|
||||||
@click.pass_context
|
@click.pass_obj
|
||||||
def delete(ctx, stack_names, multi):
|
def delete(cb, stack_names, multi):
|
||||||
""" Deletes stacks or stack groups """
|
""" Deletes stacks or stack groups """
|
||||||
stacks = _find_stacks(ctx, stack_names, multi)
|
stacks = _find_stacks(cb, stack_names, multi)
|
||||||
|
|
||||||
# Reverse steps
|
# Reverse steps
|
||||||
steps = [s for s in sort_stacks(ctx, stacks)]
|
steps = [s for s in sort_stacks(cb, stacks)]
|
||||||
delete_steps = steps[::-1]
|
delete_steps = steps[::-1]
|
||||||
for step in delete_steps:
|
for step in delete_steps:
|
||||||
if step:
|
if step:
|
||||||
@ -114,16 +114,14 @@ def delete(ctx, stack_names, multi):
|
|||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.pass_context
|
@click.pass_obj
|
||||||
def clean(ctx):
|
def clean(cb):
|
||||||
""" Deletes all previously rendered files locally """
|
""" Deletes all previously rendered files locally """
|
||||||
cb = ctx.obj['cb']
|
|
||||||
cb.clean()
|
cb.clean()
|
||||||
|
|
||||||
|
|
||||||
def sort_stacks(ctx, stacks):
|
def sort_stacks(cb, stacks):
|
||||||
""" Sort stacks by dependencies """
|
""" Sort stacks by dependencies """
|
||||||
cb = ctx.obj['cb']
|
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
@ -165,8 +163,8 @@ def sort_stacks(ctx, stacks):
|
|||||||
assert not data, "A cyclic dependency exists amongst %r" % data
|
assert not data, "A cyclic dependency exists amongst %r" % data
|
||||||
|
|
||||||
|
|
||||||
def _find_stacks(ctx, stack_names, multi=False):
|
def _find_stacks(cb, stack_names, multi=False):
|
||||||
cb = ctx.obj['cb']
|
""" search stacks by name """
|
||||||
|
|
||||||
stacks = []
|
stacks = []
|
||||||
for s in stack_names:
|
for s in stack_names:
|
||||||
@ -189,6 +187,3 @@ cli.add_command(provision)
|
|||||||
cli.add_command(delete)
|
cli.add_command(delete)
|
||||||
cli.add_command(clean)
|
cli.add_command(clean)
|
||||||
cli.add_command(create_change_set)
|
cli.add_command(create_change_set)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
cli(obj={})
|
|
||||||
|
Loading…
Reference in New Issue
Block a user