How to use the taskcat._amiupdater.EC2FilterValue function in taskcat

To help you get started, we’ve selected a few taskcat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
"global": {
                "AMIs": {
                    "AMZNLINUXHVM": {
                        "name": "amzn-ami-hvm-????.??.?.*-x86_64-gp2",
                        "owner-alias": "amazon",
                    }
                }
            }
        }
        expected = [
            RegionalCodename(
                region="us-east-1",
                cn="AMZNLINUXHVM",
                filters=[
                    EC2FilterValue("name", ["amzn-ami-hvm-????.??.?.*-x86_64-gp2"]),
                    EC2FilterValue("owner-alias", ["amazon"]),
                    EC2FilterValue("state", ["available"]),
                ],
            )
        ]
        actual = build_codenames(au_template, example_config_obj)
        _mocked_dt = datetime.now()
        for r1 in expected:
            r1._creation_dt = _mocked_dt
        for r2 in actual:
            r2._creation_dt = _mocked_dt
        self.assertEqual(expected, actual)
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_regional_codename__hash__(self):
        rc = RegionalCodename(
            region="us-east-1",
            cn="AMZNLINUXHVM",
            filters=[
                EC2FilterValue("name", ["amzn-ami-hvm-????.??.?.*-x86_64-gp2"]),
                EC2FilterValue("owner-alias", ["amazon"]),
                EC2FilterValue("state", ["available"]),
            ],
        )
        self.assertTrue(isinstance(rc.__hash__(), int))
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_regional_codename__hash__(self):
        rc = RegionalCodename(
            region="us-east-1",
            cn="AMZNLINUXHVM",
            filters=[
                EC2FilterValue("name", ["amzn-ami-hvm-????.??.?.*-x86_64-gp2"]),
                EC2FilterValue("owner-alias", ["amazon"]),
                EC2FilterValue("state", ["available"]),
            ],
        )
        self.assertTrue(isinstance(rc.__hash__(), int))
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_construct_filters(self):
        example_config_obj = AUConfig
        example_config_obj.raw_dict = {
            "global": {
                "AMIs": {
                    "FOOBAR": {
                        "name": "amzn-ami-hvm-????.??.?.*-x86_64-gp2",
                        "owner-alias": "amazon",
                    }
                }
            }
        }
        expected = [
            EC2FilterValue("name", ["amzn-ami-hvm-????.??.?.*-x86_64-gp2"]),
            EC2FilterValue("owner-alias", ["amazon"]),
            EC2FilterValue("state", ["available"]),
        ]
        actual = _construct_filters("FOOBAR", example_config_obj)
        self.assertEqual(expected, actual)
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
"AMIs": {
                    "AMZNLINUXHVM": {
                        "name": "amzn-ami-hvm-????.??.?.*-x86_64-gp2",
                        "owner-alias": "amazon",
                    }
                }
            }
        }
        expected = [
            RegionalCodename(
                region="us-east-1",
                cn="AMZNLINUXHVM",
                filters=[
                    EC2FilterValue("name", ["amzn-ami-hvm-????.??.?.*-x86_64-gp2"]),
                    EC2FilterValue("owner-alias", ["amazon"]),
                    EC2FilterValue("state", ["available"]),
                ],
            )
        ]
        actual = build_codenames(au_template, example_config_obj)
        _mocked_dt = datetime.now()
        for r1 in expected:
            r1._creation_dt = _mocked_dt
        for r2 in actual:
            r2._creation_dt = _mocked_dt
        self.assertEqual(expected, actual)
github aws-quickstart / taskcat / taskcat / _amiupdater.py View on Github external
def _construct_filters(cname: str, config: Config) -> List[EC2FilterValue]:
    formatted_filters: List[EC2FilterValue] = []
    fetched_filters = config.get_filter(cname)
    formatted_filters = [EC2FilterValue(k, [v]) for k, v in fetched_filters.items()]
    if formatted_filters:
        formatted_filters.append(EC2FilterValue("state", ["available"]))
    return formatted_filters
github aws-quickstart / taskcat / taskcat / _amiupdater.py View on Github external
def _construct_filters(cname: str, config: Config) -> List[EC2FilterValue]:
    formatted_filters: List[EC2FilterValue] = []
    fetched_filters = config.get_filter(cname)
    formatted_filters = [EC2FilterValue(k, [v]) for k, v in fetched_filters.items()]
    if formatted_filters:
        formatted_filters.append(EC2FilterValue("state", ["available"]))
    return formatted_filters