Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnfaherty committed Aug 8, 2023
1 parent 87218b2 commit 760dec6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
5 changes: 3 additions & 2 deletions servicecatalog_factory/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,13 @@ def update_provisioned_product(region, name, product_id, description, template_u
@click.argument("product_name")
@click.argument("product_version")
@click.argument("p", type=click.Path(exists=True))
@click.argument("configuration", type=click.File())
def generate_template(
provisioner_name, provisioner_version, product_name, product_version, p
provisioner_name, provisioner_version, product_name, product_version, p, configuration
):
click.echo(
portfolios.generate_template(
provisioner_name, provisioner_version, product_name, product_version, p
provisioner_name, provisioner_version, product_name, product_version, p, configuration
)
)

Expand Down
34 changes: 13 additions & 21 deletions servicecatalog_factory/commands/portfolios.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,25 +578,17 @@ def nuke_product_version(portfolio_name, product, version):


def generate_template(
provisioner_name, provisioner_version, product_name, product_version, p
provisioner_name, provisioner_version, product_name, product_version, p, configuration
) -> str:
with betterboto_client.ClientContextManager("s3") as s3:
body = (
s3.get_object(
Bucket=f"sc-factory-artifacts-{os.environ.get('ACCOUNT_ID')}-{os.environ.get('REGION')}",
Key=f"{provisioner_name}/{provisioner_version}/{product_name}/{product_version}/template.json",
)
.get("Body")
.read()
)
template = json.loads(body)
if provisioner_name == "CDK" and provisioner_version == "1.0.0":
return cdk_product_template.create_cdk_pipeline(
provisioner_name,
provisioner_version,
product_name,
product_version,
template,
p,
).to_yaml(clean_up=True)
raise Exception(f"Unknown {provisioner_name} and {provisioner_version}")
template = json.loads(configuration.read())

if provisioner_name == "CDK" and provisioner_version == "1.0.0":
return cdk_product_template.create_cdk_pipeline(
provisioner_name,
provisioner_version,
product_name,
product_version,
template,
p,
).to_yaml(clean_up=True)
raise Exception(f"Unknown {provisioner_name} and {provisioner_version}")
6 changes: 5 additions & 1 deletion servicecatalog_factory/commands/task_reference.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import glob
import json
import os

import yaml
Expand Down Expand Up @@ -160,6 +161,8 @@ def extrapolate_version(input, product_name):

extra_commands = list(configuration.get("install", {}).get("commands", []))

configuration = json.dumps(input.get("Template").get("Configuration"))

if not stages.get("Build"):
stages["Build"] = dict(
BuildSpecImage=constants.CODE_BUILD_PROJECT_ENVIRONMENT_IMAGE_CDK_TEMPLATE_DEFAULT_VALUE,
Expand All @@ -179,11 +182,12 @@ def extrapolate_version(input, product_name):
},
pre_build={
"commands": [
"cdk synth -- --output sct-synth-output",
"cdk synth --output sct-synth-output",
],
},
build={
"commands": [
f"echo '{configuration}' > configuration.json",
f'servicecatalog-factory generate-template "CDK" "1.0.0" "{product_name}" "{version_name}" . > product.template.yaml',
]
},
Expand Down

0 comments on commit 760dec6

Please sign in to comment.