Skip to content

Commit

Permalink
Merge pull request #333 from DontShaveTheYak/develop
Browse files Browse the repository at this point in the history
Release v0.12.1
  • Loading branch information
shadycuz authored Oct 31, 2024
2 parents 4fb3eec + 41f83e5 commit 5c0f599
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 123 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
steps:

- name: Checkout Code
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.1
with:
fetch-depth: 0

- name: Setup Python 3.9
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.2.0
with:
python-version: '3.9'
architecture: x64
Expand Down Expand Up @@ -72,10 +72,10 @@ jobs:
needs: tag
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.1

- name: Setup Python 3.9
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.2.0
with:
python-version: '3.9'
architecture: x64
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
name: Pre-commit
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.1

- name: Setup Latest Python
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.2.0
with:
python-version: 3.9
architecture: x64
Expand All @@ -38,7 +38,7 @@ jobs:
run: coverage xml --fail-under=0

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.6
uses: codecov/codecov-action@v4.6.0
with:
flags: unit
fail_ci_if_error: false
Expand All @@ -53,10 +53,10 @@ jobs:
name: Python ${{ matrix.python-version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.1

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.2.0
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand Down
2 changes: 1 addition & 1 deletion .scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.31.0
requests==2.32.3
semver==3.0.2
233 changes: 129 additions & 104 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ cfn-flip = "^1.3.0"
[tool.poetry.group.dev.dependencies]
pytest = "^7.0.0"
coverage = {extras = ["toml"], version = "^7.0.0"}
pytest-cov = "^4.0.0"
pytest-cov = "^5.0.0"
pytest-mock = "^3.6.1"
isort = "^5.12.0"
black = "^23.0.0"
flake8 = "^6.0.0"
flake8 = "^7.0.0"
flake8-black = "^0.3.0"
flake8-isort = "^6.1.0"
flake8-bugbear = "^23.0.0"
Expand Down
18 changes: 11 additions & 7 deletions src/cloud_radar/cf/unit/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,21 @@ def ref(template: "Template", var_name: str) -> Any:

if "Parameters" in template.template:
if var_name in template.template["Parameters"]:
# This is a reference to a parameter

param_def = template.template["Parameters"][var_name]
if "Type" in param_def and param_def["Type"].startswith(
"AWS::SSM::Parameter::Value<"
):
param_type = param_def.get("Type", "")
param_value = param_def["Value"]

if param_type.startswith("AWS::SSM::Parameter::Value<"):
# This is an SSM parameter value, look it up from our dynamic references
return template._get_dynamic_reference_value(
"ssm", template.template["Parameters"][var_name]["Value"]
)
return template._get_dynamic_reference_value("ssm", param_value)
if param_type == "CommaDelimitedList" or param_type.startswith("List<"):
# Return the value split into a list of strings
return param_value.split(",")

# If we get this far, regular parameter value to lookup & return
return template.template["Parameters"][var_name]["Value"]
return param_value

if var_name in template.template["Resources"]:
return var_name
Expand Down
22 changes: 22 additions & 0 deletions tests/templates/test_params_list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AWSTemplateFormatVersion: 2010-09-09
Description: "Basic template to check List Ref behaviours"

Parameters:
AllowedWriters:
Type: CommaDelimitedList
Description: Principals allowed to write

AllowedImages:
Type: List<AWS::EC2::Image::Id>
Description: AMIs that are allowed


Outputs:

JoinedWriters:
Description: When the values are joined together
Value: !Join ["", !Ref AllowedWriters]

JoinedImages:
Description: When the values are joined together
Value: !Join ["", !Ref AllowedImages]
28 changes: 28 additions & 0 deletions tests/test_cf/test_unit/test_functions_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from pathlib import Path

import pytest

from cloud_radar.cf.unit._template import Template

"""Tests the functionality of the functions with a List type parameter."""


@pytest.fixture
def template():
template_path = Path(__file__).parent / "../../templates/test_params_list.yaml"

return Template.from_yaml(template_path.resolve(), {})


def test_join(template: Template):
stack = template.create_stack(
{
"AllowedWriters": "One,Two,Three",
"AllowedImages": "ami-0ff8a91507f77f867,ami-0a584ac55a7631c0c",
}
)

stack.get_output("JoinedWriters").assert_value_is("OneTwoThree")
stack.get_output("JoinedImages").assert_value_is(
"ami-0ff8a91507f77f867ami-0a584ac55a7631c0c"
)

0 comments on commit 5c0f599

Please sign in to comment.