Ejemplo n.º 1
0
 def test_invalid_version_syntax(self):
     c = config_template().render()
     suffixed_schema = f"{Version(c['schema']).truncate()}mysuffix0"
     c["schema"] = suffixed_schema
     with self.assertRaisesRegex(
             ValueError, f"Invalid version string: '{suffixed_schema}'"):
         config_loader(c)
Ejemplo n.º 2
0
    def test_managed_nodegroup_extra_args(self):
        test_group = {
            "disk_size": 20,
            "min_size": 1,
            "max_size": 1,
            "instance_types": ["t2.micro"],
            "labels": {},
            "tags": {},
            "spot": False,
            "desired_size": 1,
        }

        with patch("domino_cdk.config.util.log.warning") as warn:
            c = config_template().render()
            c["eks"]["managed_nodegroups"] = {"test_group": dict(test_group)}
            config_loader(dict(c))
            warn.assert_not_called()

        with patch("domino_cdk.config.util.log.warning") as warn:
            c = config_template().render()
            c["eks"]["managed_nodegroups"] = {"test_group": dict(test_group)}
            c["eks"]["managed_nodegroups"]["test_group"]["extra_arg"] = "boing"
            config_loader(dict(c))
            warn.assert_called_with(
                "Warning: Unused/unsupported managed nodegroup attribute in config.eks.unmanaged_nodegroups: ['extra_arg']"
            )
Ejemplo n.º 3
0
def main():
    app = core.App()

    with open(app.node.try_get_context("config") or "config.yaml") as f:
        cfg = config_loader(yaml_load(f, Loader=SafeLoader))

    nest = app.node.try_get_context("nest") or False

    DominoStack(
        app,
        f"{cfg.name}-eks-stack",
        # If you don't specify 'env', this stack will be environment-agnostic.
        # Account/Region-dependent features and context lookups will not work,
        # but a single synthesized template can be deployed anywhere.
        # Uncomment the next line to specialize this stack for the AWS Account
        # and Region that are implied by the current CLI configuration.
        # env=core.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')),
        # Uncomment the next line if you know exactly what Account and Region you
        # want to deploy the stack to. */
        # env=core.Environment(account='123456789012', region='us-east-1'),
        # For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
        env=core.Environment(region=cfg.aws_region,
                             account=cfg.aws_account_id),
        cfg=cfg,
        nest=nest,
    )

    app.synth()
Ejemplo n.º 4
0
    def test_legacy_template(self):
        with patch("domino_cdk.config.util.log.warning") as warn:
            c = config_loader(legacy_template)
            self.assertEqual(c, legacy_config)
            warn.assert_called_with(
                "Warning: Unused/unsupported config entries in config.vpc: {'bastion': {'enabled': False, 'instance_type': None, 'ingress_ports': None}}"
            )

        with patch("domino_cdk.config.util.log.warning") as warn:
            rendered_template = c.render()
            rendered_template["schema"] = "0.0.0"
            rendered_template["eks"]["nodegroups"] = rendered_template["eks"][
                "unmanaged_nodegroups"]
            del rendered_template["eks"]["unmanaged_nodegroups"]
            del rendered_template["vpc"]["bastion"]
            d = config_loader(rendered_template)
            warn.assert_not_called()
            self.assertEqual(c, d)
Ejemplo n.º 5
0
 def test_version_with_suffix(self):
     c = config_template().render()
     suffixed_schema = f"{Version(__version__).truncate()}-mysuffix0"
     c["schema"] = suffixed_schema
     d = config_loader(c)
     self.assertEqual(d.schema, __version__)
Ejemplo n.º 6
0
 def test_unspported_schema_version(self):
     with self.assertRaisesRegex(ValueError,
                                 "Unsupported schema version: 9.9.9"):
         config_loader({"schema": "9.9.9"})
Ejemplo n.º 7
0
 def test_round_trip_template(self):
     c = config_template()
     d = config_loader(c.render())
     self.assertEqual(c, d)