Skip to content

Commit

Permalink
renamed cache tokens, implemented imported-portfolios and cleaned up …
Browse files Browse the repository at this point in the history
…task class inheritance
  • Loading branch information
eamonnfaherty committed Mar 1, 2023
1 parent dba3a7c commit e78af81
Show file tree
Hide file tree
Showing 94 changed files with 1,711 additions and 701 deletions.
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.225.0"
version = "0.226.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
37 changes: 14 additions & 23 deletions servicecatalog_puppet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
constants,
environmental_variables,
remote_config,
serialisation_utils,
)
from servicecatalog_puppet.commands import (
bootstrap as bootstrap_commands,
Expand Down Expand Up @@ -445,36 +444,28 @@ def setup_config(
if regions != ""
else remote_config.get_regions(puppet_account_id_to_use, home_region_to_use)
)
if os.environ.get(environmental_variables.TASK_IDEMPOTENCY_TOKEN):
if os.environ.get(environmental_variables.DRIFT_TOKEN):
click.echo(
f"Found existing {environmental_variables.TASK_IDEMPOTENCY_TOKEN}: {os.environ.get(environmental_variables.TASK_IDEMPOTENCY_TOKEN)}"
f"Found existing {environmental_variables.DRIFT_TOKEN}: {os.environ.get(environmental_variables.DRIFT_TOKEN)}"
)
else:
task_idempotency_token = remote_config.get_task_idempotency_token(
drift_token = remote_config.get_drift_token(
puppet_account_id_to_use, home_region_to_use
)
if task_idempotency_token is None:
task_idempotency_token = str(datetime.now())
click.echo(f"Created new task_idempotency_token: {task_idempotency_token}")
if drift_token is None:
drift_token = str(datetime.now())
click.echo(f"Created new drift_token: {drift_token}")
else:
click.echo(
f"Found existing task_idempotency_token: {task_idempotency_token}"
)
os.environ[
environmental_variables.TASK_IDEMPOTENCY_TOKEN
] = task_idempotency_token
click.echo(f"Found existing drift_token: {drift_token}")
os.environ[environmental_variables.DRIFT_TOKEN] = drift_token

run_idempotency_token = os.environ.get(
environmental_variables.RUN_IDEMPOTENCY_TOKEN
)
if run_idempotency_token:
click.echo(f"Found existing run_idempotency_token: {run_idempotency_token}")
run_token = os.environ.get(environmental_variables.RUN_TOKEN)
if run_token:
click.echo(f"Found existing run_token: {run_token}")
else:
run_idempotency_token = str(datetime.now())
os.environ[
environmental_variables.RUN_IDEMPOTENCY_TOKEN
] = run_idempotency_token
click.echo(f"Created new run_idempotency_token: {run_idempotency_token}")
run_token = str(datetime.now())
os.environ[environmental_variables.RUN_TOKEN] = run_token
click.echo(f"Created new run_token: {run_token}")

os.environ[environmental_variables.SHOULD_USE_SNS] = (
str(remote_config.get_should_use_sns(puppet_account_id_to_use, home_region))
Expand Down
1 change: 0 additions & 1 deletion servicecatalog_puppet/commands/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0

import io
import json
import os
import zipfile
from threading import Thread
Expand Down
1 change: 0 additions & 1 deletion servicecatalog_puppet/commands/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ def export_traces(codebuild_execution_id, puppet_account_id):
with betterboto_client.ClientContextManager("s3") as s3:
paginator = s3.get_paginator("list_objects_v2")
for page in paginator.paginate(Bucket=bucket, Prefix=key_prefix,):
print("new page", len(page.get("Contents", [])))
for obj in page.get("Contents", []):
key = obj.get("Key")
results.append(
Expand Down
2 changes: 1 addition & 1 deletion servicecatalog_puppet/commands/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import click
from betterboto import client as betterboto_client

from servicecatalog_puppet import aws, config, constants, serialisation_utils
from servicecatalog_puppet import aws, config, constants


logger = logging.getLogger(constants.PUPPET_LOGGER_NAME)
Expand Down
2 changes: 1 addition & 1 deletion servicecatalog_puppet/commands/show_codebuilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import click
from betterboto import client as betterboto_client

from servicecatalog_puppet import constants, serialisation_utils
from servicecatalog_puppet import constants


logger = logging.getLogger(constants.PUPPET_LOGGER_NAME)
Expand Down
2 changes: 1 addition & 1 deletion servicecatalog_puppet/commands/show_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import terminaltables
from betterboto import client as betterboto_client

from servicecatalog_puppet import constants, serialisation_utils, utils
from servicecatalog_puppet import constants, utils


result_look_up = dict(Failed="red", Succeeded="green")
Expand Down
2 changes: 1 addition & 1 deletion servicecatalog_puppet/commands/task_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
complete_generator,
hub_generator,
)
from servicecatalog_puppet.workflow import runner, workflow_utils
from servicecatalog_puppet.workflow import runner


logger = logging.getLogger(constants.PUPPET_LOGGER_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
from servicecatalog_puppet import constants
from servicecatalog_puppet.commands.task_reference_helpers.generators import (
imported_portfolios,
launches,
organizational_units,
service_control_policies,
Expand Down Expand Up @@ -44,6 +45,17 @@ def generate(
task_to_add,
)

if section_name == constants.IMPORTED_PORTFOLIOS:
imported_portfolios.handle_imported_portfolios(
all_tasks,
all_tasks_task_reference,
item_name,
puppet_account_id,
section_name,
task_reference,
task_to_add,
)

if section_name == constants.WORKSPACES:
workspaces.handle_workspaces(
all_tasks,
Expand Down

0 comments on commit e78af81

Please sign in to comment.