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

Simplify conditionals #101

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions cdk/domino_cdk/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ 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)
if route53 is not None:
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(
Expand All @@ -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(
Expand Down
16 changes: 7 additions & 9 deletions cdk/domino_cdk/domino_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -56,18 +56,16 @@ 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
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:
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",
Expand Down Expand Up @@ -110,15 +108,15 @@ 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,
"efs-output",
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(
Expand All @@ -132,7 +130,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,
Expand Down