This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add template builder top-level entry point (#20)
- Loading branch information
1 parent
9175267
commit ddce41f
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |