Skip to content

Commit

Permalink
Updating poetry to 1.42 (maintenance), Updating requests to 2.31.0 (C…
Browse files Browse the repository at this point in the history
…VE), fixing issue #653, increasing unit test coverage.

* chore: adding unit tests

* chore: setting sensible default

* chore: updating codecov

* chore: updating requests

* chore: preparing for release

* chore: preparing for release

* chore: removing magic string

* chore: removing magic string

* fix: generated boto3 tasks for cloudformation_stack_output parameters were not inheriting the execution mode

* fix: adding dependencies for cloudformation_stack_output
  • Loading branch information
eamonnfaherty committed May 24, 2023
1 parent 7f9f96d commit dae40fe
Show file tree
Hide file tree
Showing 12 changed files with 662 additions and 635 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.9]
poetry-version: [1.2.0]
poetry-version: [1.4.2]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions Makefile.Project
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ clean:

## @Project_setup Generates a setup.py so you can test bootstrapped branches in AWS Codecommit
prepare-for-testing: build
tar -zxvf dist/$$(poetry version | sed 's/ /-/g').tar.gz -C dist $$(poetry version | sed 's/ /-/g')/setup.py
mv dist/aws-service-catalog-puppet-*/setup.py setup.py
tar -zxvf dist/aws_service_catalog_puppet-$$(poetry version -s).tar.gz -C dist aws_service_catalog_puppet-$$(poetry version -s)/setup.py
cp dist/aws_service_catalog_puppet-$$(poetry version -s)/setup.py setup.py
1,225 changes: 612 additions & 613 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tool.poetry]
name = "aws-service-catalog-puppet"
version = "0.227.0"
version = "0.228.0"
description = "Making it easier to deploy ServiceCatalog products"
classifiers = ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Natural Language :: English"]
homepage = "https://service-catalog-tools-workshop.com/"
Expand Down Expand Up @@ -32,6 +32,7 @@ nose2 = "^0.10.0"
[tool.poetry.group.dev.dependencies]
viztracer = "^0.15.4"
importanize = "^0.7.0"
codecov = "^2.1.13"

[tool.dephell.main]
versioning = "semver"
Expand All @@ -41,7 +42,7 @@ to = {format = "poetry", path = "pyproject.toml"}

[tool.poetry.dependencies]
python = "^3.9"
requests = "2.26.0"
requests = "2.31.0"
pyyaml = "==5.4"
jinja2 = "==2.11.3"
click = "==7.0"
Expand All @@ -61,3 +62,6 @@ yamale = "^3.0.8"
colorama = "^0.4.5"
orjson = "^3.8.0"
MarkupSafe = "2.0.1"

[tool.poetry.build]
generate-setup-file = true
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,24 @@ def generate(puppet_account_id, manifest, output_file_path):
item_name_to_use = stack_ref_stack

boto3_parameter_task_reference = f"{constants.BOTO3_PARAMETERS}-{section_name_to_use}-{item_name_to_use}-{parameter_name}-{account_id_to_use_for_boto3_call}-{region_to_use_for_boto3_call}"
task_execution = task.get(
"execution", constants.EXECUTION_MODE_DEFAULT
)
if task.get(task_execution) in [
constants.EXECUTION_MODE_HUB,
constants.EXECUTION_MODE_ASYNC,
]:
if account_id_to_use_for_boto3_call != puppet_account_id:
raise Exception(
f"Cannot use {task_execution} for a task that is not in the puppet account"
)
if not new_tasks.get(boto3_parameter_task_reference):
new_tasks[boto3_parameter_task_reference] = dict(
status=task.get("status"),
execution=task_execution,
task_reference=boto3_parameter_task_reference,
dependencies_by_reference=dependencies,
dependencies=list(),
manifest_section_names=dict(),
manifest_item_names=dict(),
manifest_account_ids=dict(),
Expand All @@ -340,15 +353,17 @@ def generate(puppet_account_id, manifest, output_file_path):
section_name=constants.BOTO3_PARAMETERS,
)

new_tasks[boto3_parameter_task_reference][
"manifest_section_names"
].update(task.get("manifest_section_names"))
new_tasks[boto3_parameter_task_reference][
"manifest_item_names"
].update(task.get("manifest_item_names"))
new_tasks[boto3_parameter_task_reference][
"manifest_account_ids"
].update(task.get("manifest_account_ids"))
boto3_task = new_tasks[boto3_parameter_task_reference]
boto3_task["manifest_section_names"].update(
task.get("manifest_section_names")
)
boto3_task["manifest_item_names"].update(
task.get("manifest_item_names")
)
boto3_task["manifest_account_ids"].update(
task.get("manifest_account_ids")
)
boto3_task["dependencies"].extend(task.get("dependencies"))

task["dependencies_by_reference"].append(
boto3_parameter_task_reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def generate(puppet_account_id, all_tasks, output_file_path):
tasks_to_include = dict()
generate_manifest_ref = "generate-manifest"
generate_manifest_ref = constants.GENERATE_MANIFEST
for task_name, task in all_tasks.get("all_tasks").items():
execution = task.get("execution", constants.EXECUTION_MODE_DEFAULT)
if execution in [constants.EXECUTION_MODE_HUB, constants.EXECUTION_MODE_ASYNC]:
Expand Down
5 changes: 4 additions & 1 deletion servicecatalog_puppet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def get_output_cache_starting_point():


def is_caching_enabled():
return os.environ.get(environmental_variables.IS_CACHING_ENABLED).lower() == "true"
return (
os.environ.get(environmental_variables.IS_CACHING_ENABLED, "false").lower()
== "true"
)


def get_initialiser_stack_tags():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
QUEUE_STATUS,
)

from servicecatalog_puppet import constants


task_to_run_reference = "task_to_run"
dependency_task_reference = "dependency"
Expand Down Expand Up @@ -389,14 +391,14 @@ def generate_spoke_execution(self):
],
QUEUE_STATUS: COMPLETED,
},
"generate-manifest": {
"task_reference": "generate-manifest",
constants.GENERATE_MANIFEST: {
"task_reference": constants.GENERATE_MANIFEST,
"dependencies_by_reference": ["create-policies"],
QUEUE_STATUS: COMPLETED,
},
"run-deploy-in-spoke_YYYYY": {
"task_reference": "run-deploy-in-spoke_YYYYY",
"dependencies_by_reference": ["generate-manifest"],
"dependencies_by_reference": [constants.GENERATE_MANIFEST],
QUEUE_STATUS: IN_PROGRESS,
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions servicecatalog_puppet/workflow/ssm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SSMOutputsTasksTest(tasks_unit_tests_helper.PuppetTaskUnitTest):
param_name = "param_name"
stack_output = "stack_output"
task_generating_output = "task_generating_output"
force_operation = False

def setUp(self) -> None:
from servicecatalog_puppet.workflow.ssm import ssm_outputs_task
Expand Down Expand Up @@ -69,7 +70,6 @@ def setUp(self) -> None:

self.sut = self.module.TerminateSSMOutputsTasks(
**self.get_common_args(),
puppet_account_id=self.puppet_account_id,
account_id=self.account_id,
region=self.region,
param_name=self.param_name
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'networkx==2.6.3',
'orjson>=3.8.0,<4.0.0',
'pyyaml==5.4',
'requests==2.26.0',
'requests==2.31.0',
'terminaltables==3.1.0',
'troposphere==3.1.0',
'yamale>=3.0.8,<4.0.0']
Expand All @@ -74,7 +74,7 @@

setup_kwargs = {
'name': 'aws-service-catalog-puppet',
'version': '0.227.0',
'version': '0.228.0',
'description': 'Making it easier to deploy ServiceCatalog products',
'long_description': '# aws-service-catalog-puppet\n\n![logo](./docs/logo.png) \n\n## Badges\n\n[![codecov](https://codecov.io/gh/awslabs/aws-service-catalog-puppet/branch/master/graph/badge.svg?token=e8M7mdsmy0)](https://codecov.io/gh/awslabs/aws-service-catalog-puppet)\n\n\n## What is it?\nThis is a python3 framework that makes it easier to share multi region AWS Service Catalog portfolios and makes it \npossible to provision products into accounts declaratively using a metadata based rules engine.\n\nWith this framework you define your accounts in a YAML file. You give each account a set of tags, a default region and \na set of enabled regions.\n\nOnce you have done this you can define portfolios should be shared with each set of accounts using the tags and you \ncan specify which regions the shares occur in.\n\nIn addition to this, you can also define products that should be provisioned into accounts using the same tag based \napproach. The framework will assume role into the target account and provision the product on your behalf.\n\n\n## Getting started\n\nYou can read the [installation how to](https://service-catalog-tools-workshop.com/30-how-tos/10-installation/30-service-catalog-puppet.html)\nor you can read through the [every day use](https://service-catalog-tools-workshop.com/30-how-tos/50-every-day-use.html)\nguides.\n\nYou can read the [documentation](https://aws-service-catalog-puppet.readthedocs.io/en/latest/) to understand the inner \nworkings. \n\n\n## Going further\n\nThe framework is one of a pair. The other is [aws-service-catalog-factory](https://github.com/awslabs/aws-service-catalog-factory).\nWith Service Catalog Factory you can create pipelines that deploy multi region portfolios very easily. \n\n## License\n\nThis library is licensed under the Apache 2.0 License. \n \n',
'author': 'Eamonn Faherty',
Expand Down

0 comments on commit dae40fe

Please sign in to comment.