From f4c4d2991439a8b5a602c7d30c9605c308edbb4f Mon Sep 17 00:00:00 2001 From: Joaquin Lopez Date: Wed, 8 Jun 2022 12:04:34 -0700 Subject: [PATCH 1/2] Simplify conditionals --- cdk/domino_cdk/config/base.py | 14 +++++++------- cdk/domino_cdk/domino_stack.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cdk/domino_cdk/config/base.py b/cdk/domino_cdk/config/base.py index fb124b21..266cb4b2 100644 --- a/cdk/domino_cdk/config/base.py +++ b/cdk/domino_cdk/config/base.py @@ -55,7 +55,7 @@ def set_tags(self, tags: int): @staticmethod def from_0_0_0(c: dict): s3 = c.pop("s3", None) - if s3 is not None: + if s3: s3 = S3.from_0_0_0(s3) route53 = c.pop("route53", None) @@ -63,11 +63,11 @@ def from_0_0_0(c: dict): route53 = Route53.from_0_0_0(route53) efs = c.pop("efs", None) - if efs is not None: + if efs: efs = EFS.from_0_0_0(efs) install = c.pop("install", None) - if install is not None: + if install: install = Install.from_0_0_0(install) return from_loader( @@ -92,19 +92,19 @@ def from_0_0_0(c: dict): @staticmethod def from_0_0_1(c: dict): s3 = c.pop("s3", None) - if s3 is not None: + if s3: s3 = S3.from_0_0_0(s3) route53 = c.pop("route53", None) - if route53 is not None: + if route53: route53 = Route53.from_0_0_0(route53) efs = c.pop("efs", None) - if efs is not None: + if efs: efs = EFS.from_0_0_0(efs) install = c.pop("install", None) - if install is not None: + if install: install = Install.from_0_0_1(install) return from_loader( diff --git a/cdk/domino_cdk/domino_stack.py b/cdk/domino_cdk/domino_stack.py index 33f26bbb..95c1c35f 100644 --- a/cdk/domino_cdk/domino_stack.py +++ b/cdk/domino_cdk/domino_stack.py @@ -40,7 +40,7 @@ def __init__( for k, v in self.cfg.tags.items(): cdk.Tags.of(self).add(str(k), str(v)) - if self.cfg.s3 is not None: + if self.cfg.s3: self.s3_stack = DominoS3Provisioner(self, "S3Stack", self.name, self.cfg.s3, nest) self.monitoring_bucket = self.s3_stack.monitoring_bucket @@ -56,18 +56,18 @@ def __init__( self.vpc_stack.vpc, self.vpc_stack.private_subnet_name, self.vpc_stack.bastion_sg, - self.cfg.route53.zone_ids if self.cfg.route53 is not None else [], + self.cfg.route53.zone_ids if self.cfg.route53 else [], nest, # Do not pass list of buckets to Eks provisioner if we are not using S3 access per node self.s3_stack.buckets - if self.s3_stack is not None and cfg.create_iam_roles_for_service_accounts is False + if self.s3_stack and cfg.create_iam_roles_for_service_accounts is False else [], ) if cfg.create_iam_roles_for_service_accounts: DominoEksK8sIamRolesProvisioner(self).provision(self.name, self.eks_stack.cluster, self.s3_stack.buckets) - if self.cfg.efs is not None: + if self.cfg.efs: self.efs_stack = DominoEfsProvisioner( self, "EfsStack", @@ -110,7 +110,7 @@ def __init__( self.generate_outputs() def generate_outputs(self): - if self.efs_stack is not None: + if self.efs_stack: efs_fs_ap_id = f"{self.efs_stack.efs.file_system_id}::{self.efs_stack.efs_access_point.access_point_id}" cdk.CfnOutput( self, @@ -118,7 +118,7 @@ def generate_outputs(self): value=efs_fs_ap_id, ) - if self.cfg.route53 is not None: + if self.cfg.route53: r53_zone_ids = self.cfg.route53.zone_ids r53_owner_id = f"{self.name}CDK" cdk.CfnOutput( @@ -132,7 +132,7 @@ def generate_outputs(self): value=r53_owner_id, ) - if self.cfg.install is not None: + if self.cfg.install: agent_cfg = generate_install_config( name=self.name, install=self.cfg.install, From 166fd4a7e34e3a4fec32462c63e4fd89825a954b Mon Sep 17 00:00:00 2001 From: Joaquin Lopez Date: Wed, 8 Jun 2022 12:07:52 -0700 Subject: [PATCH 2/2] Black --- cdk/domino_cdk/domino_stack.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cdk/domino_cdk/domino_stack.py b/cdk/domino_cdk/domino_stack.py index 95c1c35f..40b60935 100644 --- a/cdk/domino_cdk/domino_stack.py +++ b/cdk/domino_cdk/domino_stack.py @@ -59,9 +59,7 @@ def __init__( self.cfg.route53.zone_ids if self.cfg.route53 else [], nest, # Do not pass list of buckets to Eks provisioner if we are not using S3 access per node - self.s3_stack.buckets - if self.s3_stack and cfg.create_iam_roles_for_service_accounts is False - else [], + self.s3_stack.buckets if self.s3_stack and cfg.create_iam_roles_for_service_accounts is False else [], ) if cfg.create_iam_roles_for_service_accounts: