Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
add template builder top-level entry point (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsb42-aws authored and lizroth committed May 8, 2019
1 parent 9175267 commit ddce41f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/pipeformer/internal/template_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Logic for transforming a parsed config to one or more CloudFormation templates."""
from pipeformer.internal.templates import codepipeline, core, iam, inputs

from .structures import Config, ProjectTemplates

__all__ = ("config_to_templates",)


def config_to_templates(project: Config) -> ProjectTemplates:
"""Construct all standalone templates from project.
:param project: Source project
:return: Constructed templates
"""
iam_template = iam.build(project)

inputs_template = inputs.build(project)

pipeline_templates = codepipeline.build(project)

core_template = core.build(
project=project,
inputs_template=inputs_template,
iam_template=iam_template,
pipeline_templates=pipeline_templates,
)

return ProjectTemplates(
core=core_template,
inputs=inputs_template,
iam=iam_template,
pipeline=pipeline_templates.template,
codebuild=pipeline_templates.stage_templates,
)
27 changes: 27 additions & 0 deletions test/functional/internal/test_template_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Functional tests for ``pipeformer.internal.template_builder``."""
import pytest

from pipeformer.internal import template_builder

from .. import functional_test_utils

pytestmark = [pytest.mark.local, pytest.mark.functional]


@pytest.mark.parametrize("name", functional_test_utils.vector_names())
def test_parse_config(name: str):
project = functional_test_utils.populated_config(name)

_test = template_builder.config_to_templates(project)

0 comments on commit ddce41f

Please sign in to comment.