Skip to content

Commit

Permalink
Merge pull request #38 from kalleeh/fix--update-tag-naming
Browse files Browse the repository at this point in the history
fix: solve update tag bug
  • Loading branch information
SandraPico authored Feb 12, 2020
2 parents 6d7535c + 081f520 commit 74f0627
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lambda_layers/dependencies/python/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def validate_permissions(self, tags):
def _tags_are_valid(self, tags, stack_type):
stack_tags = transform_utils.kv_to_dict(tags, 'Key', 'Value')

if not platform_config.PLATFORM_TAGS['TYPE'] in stack_tags:
if not platform_config.PLATFORM_TAGS['PRODUCT_TYPE'] in stack_tags:
return False

if not stack_type == platform_config.PLATFORM_TAGS['TYPE']:
if not stack_type == platform_config.PLATFORM_TAGS['PRODUCT_TYPE']:
return False

if stack_tags[platform_config.PLATFORM_TAGS['GROUPS']] == self._groups:
Expand Down
8 changes: 4 additions & 4 deletions lambda_layers/dependencies/python/managers/stack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ def _is_requested_type(self, tags):
"""
LOGGER.debug(
'Validating type %s is %s:',
tags[platform_config.PLATFORM_TAGS['TYPE']],
tags[platform_config.PLATFORM_TAGS['PRODUCT_TYPE']],
self._stack_type)
return self._stack_type == 'any' or \
tags[platform_config.PLATFORM_TAGS['TYPE']] == self._stack_type
tags[platform_config.PLATFORM_TAGS['PRODUCT_TYPE']] == self._stack_type

@abstractmethod
def _generate_params(self, payload):
Expand Down Expand Up @@ -446,8 +446,8 @@ def _generate_tags(self, payload):
LOGGER.debug(
'Fetching platform Tags.')

tags[platform_config.PLATFORM_TAGS['TYPE']] = self._stack_type
tags[platform_config.PLATFORM_TAGS['SUBTYPE']] = payload['subtype']
tags[platform_config.PLATFORM_TAGS['PRODUCT_TYPE']] = self._stack_type
tags[platform_config.PLATFORM_TAGS['PRODUCT_FLAVOR']] = payload['product_flavor']
tags[platform_config.PLATFORM_TAGS['VERSION']] = payload['version']
tags[platform_config.PLATFORM_TAGS['GROUPS']] = self._groups
tags[platform_config.PLATFORM_TAGS['REGION']] = platform_config.PLATFORM_REGION
Expand Down
4 changes: 2 additions & 2 deletions lambda_layers/dependencies/python/platform_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

# Tags for the platform
PLATFORM_TAGS = {}
PLATFORM_TAGS['TYPE'] = os.getenv('PLATFORM_TAGS_TYPE', '{}-{}'.format(PLATFORM_PREFIX, 'platform-type'))
PLATFORM_TAGS['SUBTYPE'] = os.getenv('PLATFORM_TAGS_SUBTYPE', '{}-{}'.format(PLATFORM_PREFIX, 'platform-subtype'))
PLATFORM_TAGS['PRODUCT_TYPE'] = os.getenv('PLATFORM_TAGS_PRODUCT_TYPE', '{}-{}'.format(PLATFORM_PREFIX, 'product-type'))
PLATFORM_TAGS['PRODUCT_FLAVOR'] = os.getenv('PLATFORM_TAGS_PRODUCT_FLAVOR', '{}-{}'.format(PLATFORM_PREFIX, 'product-flavor'))
PLATFORM_TAGS['VERSION'] = os.getenv('PLATFORM_TAGS_VERSION', '{}-{}'.format(PLATFORM_PREFIX, 'platform-version'))
PLATFORM_TAGS['OWNER'] = os.getenv('PLATFORM_TAGS_OWNER', '{}-{}'.format(PLATFORM_PREFIX, 'owner'))
PLATFORM_TAGS['REGION'] = os.getenv('PLATFORM_TAGS_REGION', '{}-{}'.format(PLATFORM_PREFIX, 'region'))
Expand Down
2 changes: 1 addition & 1 deletion lambda_layers/dependencies/python/template_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def generate_template_url(stack_type, payload):
template_url = 'https://s3.amazonaws.com/{}/{}/{}/{}.yaml'.format(
platform_config.PLATFORM_BUCKET,
prefix_path,
payload['subtype'],
payload['product_flavor'],
payload['version']
)

Expand Down
4 changes: 2 additions & 2 deletions src/apps/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def post(event, _context):

name = transform_utils.add_prefix(payload['name'])

if 'subtype' not in payload:
payload['subtype'] = 'ecs-fargate'
if 'product_flavor' not in payload:
payload['product_flavor'] = 'ecs-fargate'
if 'version' not in payload:
payload['version'] = 'latest'

Expand Down
4 changes: 2 additions & 2 deletions src/apps/name/update_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def patch(event, _context):
payload = json.loads(event['body-json'][0])

# Configure default values if not present
if 'subtype' not in payload:
payload['subtype'] = 'shared-lb'
if 'product_flavor' not in payload:
payload['product_flavor'] = 'shared-lb'
if 'version' not in payload:
payload['version'] = 'latest'

Expand Down
4 changes: 2 additions & 2 deletions src/pipelines/create_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def post(event, _context):
name = transform_utils.add_prefix(payload['name'])

# Configure default values if not present
if 'subtype' not in payload:
payload['subtype'] = 'github/cfn'
if 'product_flavor' not in payload:
payload['product_flavor'] = 'github/cfn'
if 'version' not in payload:
payload['version'] = 'latest'

Expand Down
4 changes: 2 additions & 2 deletions src/pipelines/name/update_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def patch(event, _context):
payload = json.loads(event['body-json'][0])

# Configure default values if not present
if 'subtype' not in payload:
payload['subtype'] = 'github'
if 'product_flavor' not in payload:
payload['product_flavor'] = 'github'
if 'version' not in payload:
payload['version'] = 'latest'

Expand Down
4 changes: 2 additions & 2 deletions src/services/create_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def post(event, _context):

name = transform_utils.add_prefix(payload['name'])

if 'subtype' not in payload:
payload['subtype'] = 's3'
if 'product_flavor' not in payload:
payload['product_flavor'] = 's3'
if 'version' not in payload:
payload['version'] = 'latest'

Expand Down
4 changes: 2 additions & 2 deletions src/services/name/update_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def patch(event, _context):
payload = json.loads(event['body-json'][0])

# Configure default values if not present
if 'subtype' not in payload:
payload['subtype'] = 's3'
if 'product_flavor' not in payload:
payload['product_flavor'] = 's3'
if 'version' not in payload:
payload['version'] = 'latest'

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ setenv=
PLATFORM_ECS_CLUSTER = cluster
PLATFORM_DEPLOYMENT_ROLE = deployment_role
PLATFORM_BUCKET = None
PLATFORM_TAGS_TYPE = platform-type
PLATFORM_TAGS_SUBTYPE = platform-subtype
PLATFORM_TAGS_PRODUCT_TYPE = product-type
PLATFORM_TAGS_PRODUCT_FLAVOR = product-flavor
PLATFORM_TAGS_VERSION = platform-version
PLATFORM_TAGS_OWNER = owner
PLATFORM_TAGS_REGION = region
Expand Down

0 comments on commit 74f0627

Please sign in to comment.