Skip to content

Commit

Permalink
added -h/--hooks-only flag for updaing EC2 configuration without affe…
Browse files Browse the repository at this point in the history
…cting the stack.
  • Loading branch information
gitwater committed Jun 25, 2021
1 parent 739ce37 commit bf6cc24
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/paco/commands/cmd_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def delete_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home='.'
):
Expand All @@ -36,6 +37,7 @@ def delete_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
)
Expand Down
4 changes: 4 additions & 0 deletions src/paco/commands/cmd_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def lambda_deploy(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home='.',
):
Expand All @@ -49,6 +50,7 @@ def lambda_deploy(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
)
Expand Down Expand Up @@ -80,6 +82,7 @@ def lambda_invoke(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home='.',
event='',
Expand Down Expand Up @@ -122,6 +125,7 @@ def lambda_invoke(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
)
Expand Down
2 changes: 2 additions & 0 deletions src/paco/commands/cmd_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def provision_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home='.',
auto_publish_code=False,
Expand All @@ -41,6 +42,7 @@ def provision_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
)
Expand Down
2 changes: 2 additions & 0 deletions src/paco/commands/cmd_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def set_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home='.',
):
Expand All @@ -36,6 +37,7 @@ def set_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
)
Expand Down
2 changes: 2 additions & 0 deletions src/paco/commands/cmd_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def validate_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home='.'
):
Expand All @@ -35,6 +36,7 @@ def validate_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
)
Expand Down
8 changes: 8 additions & 0 deletions src/paco/commands/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def init_cloud_command(
warn,
disable_validation,
quiet_changes_only,
hooks_only,
config_scope,
home
):
Expand All @@ -74,6 +75,7 @@ def init_cloud_command(
paco_ctx.warn = warn
paco_ctx.disable_validation = disable_validation
paco_ctx.quiet_changes_only = quiet_changes_only
paco_ctx.hooks_only = hooks_only
paco_ctx.command = command_name
paco_ctx.config_scope = config_scope
init_paco_home_option(paco_ctx, home)
Expand Down Expand Up @@ -280,6 +282,12 @@ def cloud_options(func):
default=False,
help='Supresses Cache, Protected, and Disabled messages.'
)(func)
func = click.option(
'-h', '--hooks-only',
is_flag=True,
default=False,
help='When updating a stack, only run the hooks and skip the stack update.'
)(func)
return func

def cloud_args(func):
Expand Down
1 change: 1 addition & 0 deletions src/paco/config/paco_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def __init__(self, home=None):
self.yes = False
self.warn = False
self.quiet_changes_only = False
self.hooks_only = False
self.paco_path = os.getcwd()
self.aws_name = "Paco"
self.controllers = {}
Expand Down
7 changes: 7 additions & 0 deletions src/paco/stack/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ def create_stack_name(self, name):

def stack_success(self):
"Actions to perform when a stack action has been successfully finished"
# If the --h/--hooks-only flag is set, avoid saving the cache
if self.action == "update" and self.paco_ctx.hooks_only == True:
return
if self.action != "delete":
# Create cache file
new_cache_id = self.gen_cache_id()
Expand Down Expand Up @@ -1359,6 +1362,10 @@ def update_stack(self):
return
self.action = "update"
self.hooks.run("update", "pre", self)
if self.paco_ctx.hooks_only == True:
self.log_action("Update", "Supressed")
return

self.log_action("Provision", "Update")
stack_parameters = self.generate_stack_parameters(action=self.action)
self.confirm_stack_parameter_changes(stack_parameters)
Expand Down

0 comments on commit bf6cc24

Please sign in to comment.