Skip to content

Commit

Permalink
fixing single account run (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnfaherty committed Feb 20, 2023
1 parent b2801ef commit 6b6dc9b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile.CodeQuality
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ importanize:
pycodestyle:
poetry run pycodestyle --statistics -qq servicecatalog_puppet

pre-commit: importanize black unit-tests
pre-commit: importanize black unit-tests prepare-for-testing
2 changes: 1 addition & 1 deletion 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.223.0"
version = "0.224.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
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def has_dependencies_remaining(task_to_run, all_tasks):
is_currently_blocked = False
is_permanently_blocked = False
for dependency in task_to_run.get("dependencies_by_reference"):
dependency_status = all_tasks[dependency].get(QUEUE_STATUS, NOT_SET)
if dependency_status in [ERRORED, BLOCKED]:
is_currently_blocked = is_permanently_blocked = True
return is_currently_blocked, is_permanently_blocked
else:
if dependency_status != COMPLETED:
is_currently_blocked = True
if all_tasks.get(dependency):
dependency_status = all_tasks[dependency].get(QUEUE_STATUS, NOT_SET)
if dependency_status in [ERRORED, BLOCKED]:
is_currently_blocked = is_permanently_blocked = True
return is_currently_blocked, is_permanently_blocked
else:
if dependency_status != COMPLETED:
is_currently_blocked = True
return is_currently_blocked, is_permanently_blocked
return is_currently_blocked, is_permanently_blocked


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,49 @@ def test_get_next_task_to_run_with_spoke_execution(self,):
# verify
self.assertEqual(expected_should_shutdown, actual_should_shutdown)
self.assertEqual(expected_next_task, actual_next_task)

def generate_missing_generate_policies(self):
all_tasks = {
"non-specific-task": {
"task_reference": "non-specific-task",
"dependencies_by_reference": ["create-policies"],
},
}

task_to_run = all_tasks.get("non-specific-task")

return task_to_run, all_tasks, list(all_tasks.keys())

def test_has_dependencies_remaining_with_missing_generate_policies(self,):
# setup
(task_to_run, all_tasks, _,) = self.generate_missing_generate_policies()

expected_is_currently_blocked = False
expected_is_permanently_blocked = False

# exercise
(
actual_is_currently_blocked,
actual_is_permanently_blocked,
) = self.sut.has_dependencies_remaining(task_to_run, all_tasks)

# verify
self.assertEqual(expected_is_currently_blocked, actual_is_currently_blocked)
self.assertEqual(expected_is_permanently_blocked, actual_is_permanently_blocked)

def test_get_next_task_to_run_with_missing_generate_policies(self,):
# setup
(_, all_tasks, tasks_to_run,) = self.generate_missing_generate_policies()
resources = dict()

expected_next_task = all_tasks.get("non-specific-task")
expected_should_shutdown = False

# execute
actual_next_task, actual_should_shutdown = self.sut.get_next_task_to_run(
tasks_to_run, resources, all_tasks
)

# verify
self.assertEqual(expected_should_shutdown, actual_should_shutdown)
self.assertEqual(expected_next_task, actual_next_task)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

setup_kwargs = {
'name': 'aws-service-catalog-puppet',
'version': '0.223.0',
'version': '0.224.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 6b6dc9b

Please sign in to comment.