From 081f5209c410b03cb80639b5ba76fa291ac9dfd7 Mon Sep 17 00:00:00 2001 From: Karl Wallbom Date: Wed, 12 Feb 2020 15:15:00 +0100 Subject: [PATCH] fix: solve update tag bug --- lambda_layers/dependencies/python/auth.py | 4 ++-- .../dependencies/python/managers/stack_manager.py | 8 ++++---- lambda_layers/dependencies/python/platform_config.py | 4 ++-- lambda_layers/dependencies/python/template_generator.py | 2 +- src/apps/create_app.py | 4 ++-- src/apps/name/update_app.py | 4 ++-- src/pipelines/create_pipeline.py | 4 ++-- src/pipelines/name/update_pipeline.py | 4 ++-- src/services/create_service.py | 4 ++-- src/services/name/update_service.py | 4 ++-- tox.ini | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lambda_layers/dependencies/python/auth.py b/lambda_layers/dependencies/python/auth.py index fe451aa..e48449e 100644 --- a/lambda_layers/dependencies/python/auth.py +++ b/lambda_layers/dependencies/python/auth.py @@ -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: diff --git a/lambda_layers/dependencies/python/managers/stack_manager.py b/lambda_layers/dependencies/python/managers/stack_manager.py index 904a1df..768c8d8 100644 --- a/lambda_layers/dependencies/python/managers/stack_manager.py +++ b/lambda_layers/dependencies/python/managers/stack_manager.py @@ -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): @@ -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 diff --git a/lambda_layers/dependencies/python/platform_config.py b/lambda_layers/dependencies/python/platform_config.py index fcb5a53..713a971 100644 --- a/lambda_layers/dependencies/python/platform_config.py +++ b/lambda_layers/dependencies/python/platform_config.py @@ -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')) diff --git a/lambda_layers/dependencies/python/template_generator.py b/lambda_layers/dependencies/python/template_generator.py index b606520..b9b8c12 100644 --- a/lambda_layers/dependencies/python/template_generator.py +++ b/lambda_layers/dependencies/python/template_generator.py @@ -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'] ) diff --git a/src/apps/create_app.py b/src/apps/create_app.py index eafb651..c8c9fe0 100644 --- a/src/apps/create_app.py +++ b/src/apps/create_app.py @@ -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' diff --git a/src/apps/name/update_app.py b/src/apps/name/update_app.py index a3fe74b..5d93fc6 100644 --- a/src/apps/name/update_app.py +++ b/src/apps/name/update_app.py @@ -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' diff --git a/src/pipelines/create_pipeline.py b/src/pipelines/create_pipeline.py index 2d3708f..65d5e24 100644 --- a/src/pipelines/create_pipeline.py +++ b/src/pipelines/create_pipeline.py @@ -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' diff --git a/src/pipelines/name/update_pipeline.py b/src/pipelines/name/update_pipeline.py index 4140f3b..7128274 100644 --- a/src/pipelines/name/update_pipeline.py +++ b/src/pipelines/name/update_pipeline.py @@ -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' diff --git a/src/services/create_service.py b/src/services/create_service.py index ef2f94f..420acc4 100644 --- a/src/services/create_service.py +++ b/src/services/create_service.py @@ -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' diff --git a/src/services/name/update_service.py b/src/services/name/update_service.py index 814b310..a43a111 100644 --- a/src/services/name/update_service.py +++ b/src/services/name/update_service.py @@ -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' diff --git a/tox.ini b/tox.ini index c217154..f3ef9f4 100644 --- a/tox.ini +++ b/tox.ini @@ -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