Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not add duplicate inputs #446

Merged
merged 6 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Contributing Guidelines

Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
documentation, we greatly value feedback and contributions from our community.

Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
information to effectively respond to your bug report or contribution.


## Reporting Bugs/Feature Requests

We welcome you to use the GitHub issue tracker to report bugs or suggest features.

When filing an issue, please check [existing open](https://github.com/awslabs/aws-deployment-framework/issues), or [recently closed](https://github.com/awslabs/aws-deployment-framework/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
When filing an issue, please check [existing open](https://github.com/awslabs/aws-deployment-framework/issues), or [recently closed](https://github.com/awslabs/aws-deployment-framework/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:

* A reproducible test case or series of steps
Expand All @@ -20,6 +20,15 @@ reported the issue. Please try to include as much information as you can. Detail
* Anything unusual about your environment or deployment


## Running tests locally

In order to run the tests locally you need a virtual environment that is used by [tox](https://pypi.org/project/tox/).

1. Create a virtual environment: `virtualenv .tox/env`
2. Activate the virtual environment: `source .tox/env/bin/activate`
3. Install dependencies: `make init`
4. To run the tests, execute: `tox`

## Contributing via Pull Requests

Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
Expand All @@ -37,13 +46,13 @@ To send us a pull request, please:
5. Send us a pull request, answering any default questions in the pull request interface.
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).


## Finding contributions to work on

Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-deployment-framework/labels/help%20wanted) issues is a great place to start.
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-deployment-framework/labels/help%20wanted) issues is a great place to start.


## Use of examples
Expand Down Expand Up @@ -76,8 +85,8 @@ following account ids may be used:

## Code of Conduct

This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
[email protected] with any additional questions or comments.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,9 @@ def _get_input_artifacts(self):
]
if self.category == 'Deploy':
for override in self.target.get('properties', {}).get('param_overrides', []):
if self.provider == "CloudFormation" and override.get('inputs') and self.action_mode != "CHANGE_SET_EXECUTE":
input_artifacts.append(
_codepipeline.CfnPipeline.InputArtifactProperty(
name=override.get('inputs')
)
)
_input = _codepipeline.CfnPipeline.InputArtifactProperty(name=override.get('inputs', ''))
if self.provider == "CloudFormation" and override.get('inputs') and self.action_mode != "CHANGE_SET_EXECUTE" and _input not in input_artifacts:
input_artifacts.append(_input)
return input_artifacts

def _get_base_output_artifact_name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,87 @@ def test_get_input_artifacts_deploy_with_cb_param_overrides(base_input_name_mock
)
]

@patch('cdk_constructs.adf_codepipeline._codepipeline.CfnPipeline.ActionDeclarationProperty')
@patch('cdk_constructs.adf_codepipeline.Action._get_base_input_artifact_name')
def test_get_input_artifacts_deploy_with_cfn_multiple_param_overrides(base_input_name_mock, action_decl_mock):
action_decl_mock.side_effect = lambda **x: x
base_input_name_mocked_value = 'BaseInputName'
base_input_name_mock.return_value = base_input_name_mocked_value
override_mocked_value = 'OverrideName'
action = Action(
map_params=BASE_MAP_PARAMS,
category='Deploy',
provider='CloudFormation',
target={
'name': 'targetname',
'id': 'someid',
'properties': {
'param_overrides': [
{
'param': 'SomeParam',
'inputs': override_mocked_value,
'key_name': 'SomeKeyName',
},
{
'param': 'SomeOtherParam',
'inputs': override_mocked_value,
'key_name': 'SomeOtherKeyName',
},
],
},
},
)
assert action.config['input_artifacts'] == [
aws_codepipeline.CfnPipeline.InputArtifactProperty(
name=base_input_name_mocked_value,
),
aws_codepipeline.CfnPipeline.InputArtifactProperty(
name=override_mocked_value,
)
]

@patch('cdk_constructs.adf_codepipeline._codepipeline.CfnPipeline.ActionDeclarationProperty')
@patch('cdk_constructs.adf_codepipeline.Action._get_base_input_artifact_name')
def test_get_input_artifacts_deploy_with_cfn_param_overrides_different_input(base_input_name_mock, action_decl_mock):
action_decl_mock.side_effect = lambda **x: x
base_input_name_mocked_value = 'BaseInputName'
base_input_name_mock.return_value = base_input_name_mocked_value
override1_mocked_value = 'OverrideName1'
override2_mocked_value = 'OverrideName2'
action = Action(
map_params=BASE_MAP_PARAMS,
category='Deploy',
provider='CloudFormation',
target={
'name': 'targetname',
'id': 'someid',
'properties': {
'param_overrides': [
{
'param': 'SomeParam',
'inputs': override1_mocked_value,
'key_name': 'SomeKeyName',
},
{
'param': 'SomeOtherParam',
'inputs': override2_mocked_value,
'key_name': 'SomeOtherKeyName',
},
],
},
},
)
assert action.config['input_artifacts'] == [
aws_codepipeline.CfnPipeline.InputArtifactProperty(
name=base_input_name_mocked_value,
),
aws_codepipeline.CfnPipeline.InputArtifactProperty(
name=override1_mocked_value,
),
aws_codepipeline.CfnPipeline.InputArtifactProperty(
name=override2_mocked_value,
)
]

@patch('cdk_constructs.adf_codepipeline._codepipeline.CfnPipeline.ActionDeclarationProperty')
@patch('cdk_constructs.adf_codepipeline.Action._get_base_input_artifact_name')
Expand Down