feat(itim): Ability to add configuration to cluster type

ref: #247 closes #71
This commit is contained in:
2024-08-19 14:49:39 +09:30
parent bfb20dab0f
commit 66b8bd5a74
6 changed files with 90 additions and 2 deletions

View File

@ -39,6 +39,16 @@ class ClusterType(TenancyObject):
slug = AutoSlugField()
config = models.JSONField(
blank = True,
default = None,
help_text = 'Cluster Type Configuration that is applied to all clusters of this type',
null = True,
verbose_name = 'Configuration',
)
created = AutoCreatedField()
modified = AutoLastModifiedField()
@ -131,6 +141,28 @@ class Cluster(TenancyObject):
modified = AutoLastModifiedField()
@property
def rendered_config(self):
rendered_config: dict = {}
if self.cluster_type.config:
rendered_config.update(
self.cluster_type.config
)
if self.config:
rendered_config.update(
self.config
)
return rendered_config
def __str__(self):
return self.name