Skip to content

Commit

Permalink
Added --nocache to cli to force updates to stacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwater committed Jul 12, 2019
1 parent e1e5e93 commit 93e04a2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog for aim

### Added

- Added --nocache to cli to force updates to stacks.

- CLI reports human readable validation errors from AIM project configuration files

- "aim ftest" command added to run functional tests on the "aim init project"
Expand Down
9 changes: 8 additions & 1 deletion src/aim/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
default=False,
help='Enables verbose mode.'
)
@click.option(
'-n', '--nocache',
is_flag=True,
default=False,
help='Disables the CloudFormation stack cache.'
)

@pass_aim_context
def cli(ctx, verbose):
def cli(ctx, verbose, nocache):
"""AIM: Application Infrastructure Manager"""
ctx.verbose = verbose
ctx.nocache = nocache

cli.add_command(provision_command)
cli.add_command(init_command)
Expand Down
16 changes: 10 additions & 6 deletions src/aim/config/aim_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class AimContext(object):
def __init__(self, home=None):
self.home = home
self.verbose = False
self.nocache = False
self.aim_path = os.getcwd()
self.build_folder = None
self.aws_name = "AIM"
Expand All @@ -96,10 +97,15 @@ def __init__(self, home=None):
self.master_account = None
self.aim_ref = references.AimReference()

def get_account_context(self, account_ref=None, account_name=None):
def get_account_context(self, account_ref=None, account_name=None, netenv_ref=None):
if account_ref != None:
ref_dict = self.aim_ref.parse_ref(account_ref)
account_name = ref_dict['ref_parts'][1]
elif netenv_ref != None:
account_ref = netenv_ref.split(' ')[1]
account_ref = 'netenv.ref '+'.'.join(account_ref.split('.', 4)[:-1])+".network.aws_account"
account_ref = self.get_ref(account_ref)
return self.get_account_context(account_ref=account_ref)
elif account_name == None:
raise StackException(AimErrorCode.Unknown)

Expand Down Expand Up @@ -133,7 +139,6 @@ def init_project(self):
}
for plugin_name, plugin_module in service_plugins.items():
service = plugin_module.instantiate_class(self, self.project[plugin_name.lower()])
#service = plugin_func(config, self.project, read_file_path=services_dir + fname)
self.services[plugin_name.lower()] = service

# Initialize Service Controllers so they can initiaize their
Expand All @@ -152,16 +157,15 @@ def get_controller(self, controller_type, config_arg=None):
if controller == None:
controller = aim.controllers.klass[controller_type](self)
self.controllers[controller_type] = controller
controller.init(config_arg)
else:
service_name = config_arg['name']
if service_name not in self.services:
if service_name.lower() not in self.services:
print("Could not find Service: %s" % (service_name))
raise StackException(AimErrorCode.Unknown)

controller = self.services[service_name]
controller.init()
controller = self.services[service_name.lower()]

controller.init(config_arg)
return controller

def log(self, msg, *args):
Expand Down
8 changes: 4 additions & 4 deletions src/aim/doc/docschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,10 @@ def aim_schema_generate():
'environment': convert_schema_to_list_table(schemas.IEnvironment),
'environmentdefault': convert_schema_to_list_table(schemas.IEnvironmentDefault),
'environmentregion': convert_schema_to_list_table(schemas.IEnvironmentRegion),
'resourcegroups': convert_schema_to_list_table(schemas.IAppResourceGroups),
'resourcegroup': convert_schema_to_list_table(schemas.IAppResourceGroup),
'resources': convert_schema_to_list_table(schemas.IAppResources),
'resource': convert_schema_to_list_table(schemas.IAppResource),
'resourcegroups': convert_schema_to_list_table(schemas.IResourceGroups),
'resourcegroup': convert_schema_to_list_table(schemas.IResourceGroup),
'resources': convert_schema_to_list_table(schemas.IResources),
'resource': convert_schema_to_list_table(schemas.IResource),
'alarmset': convert_schema_to_list_table(schemas.IAlarmSet),
'alarm': convert_schema_to_list_table(schemas.ICloudWatchAlarm),
'logsource': convert_schema_to_list_table(schemas.ICWAgentLogSource),
Expand Down
5 changes: 4 additions & 1 deletion src/aim/stack_group/stack_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def gen_cache_id(self):
return new_cache_id

def is_stack_cached(self):
if self.do_not_cache == True:
if self.aim_ctx.nocache or self.do_not_cache:
return False
try:
new_cache_id = self.gen_cache_id()
Expand Down Expand Up @@ -446,6 +446,9 @@ def delete(self):
self.delete_stack()
try:
os.remove(self.cache_filename)
except FileNotFoundError:
pass
try:
os.remove(self.output_filename)
except FileNotFoundError:
pass
Expand Down

0 comments on commit 93e04a2

Please sign in to comment.