Prune empty data from instance updates aswell
All checks were successful
Tests / test (push) Successful in 29s
All checks were successful
Tests / test (push) Successful in 29s
Closes #124
This commit is contained in:
parent
6c6fb06a01
commit
3236fc7b21
1 changed files with 13 additions and 2 deletions
|
@ -593,6 +593,16 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
||||||
if key in attrs:
|
if key in attrs:
|
||||||
delattr(self, key)
|
delattr(self, key)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _prepare_spec_data(cls, spec_data):
|
||||||
|
"""
|
||||||
|
Prepare spec data by pruning empty values and ensuring required fields.
|
||||||
|
This method centralizes spec data processing to ensure consistency.
|
||||||
|
"""
|
||||||
|
spec_data = spec_data or {}
|
||||||
|
spec_data = prune_empty_data(spec_data)
|
||||||
|
return spec_data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_instance(cls, name, organization, context, created_by, spec_data):
|
def create_instance(cls, name, organization, context, created_by, spec_data):
|
||||||
# Ensure the namespace exists
|
# Ensure the namespace exists
|
||||||
|
@ -612,8 +622,8 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
spec_data = spec_data or {}
|
spec_data = cls._prepare_spec_data(spec_data)
|
||||||
spec_data = prune_empty_data(spec_data)
|
|
||||||
if "writeConnectionSecretToRef" not in spec_data:
|
if "writeConnectionSecretToRef" not in spec_data:
|
||||||
spec_data["writeConnectionSecretToRef"] = {}
|
spec_data["writeConnectionSecretToRef"] = {}
|
||||||
|
|
||||||
|
@ -655,6 +665,7 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
||||||
|
|
||||||
def update_spec(self, spec_data, updated_by):
|
def update_spec(self, spec_data, updated_by):
|
||||||
try:
|
try:
|
||||||
|
spec_data = self._prepare_spec_data(spec_data)
|
||||||
api_instance = self.context.control_plane.custom_objects_api
|
api_instance = self.context.control_plane.custom_objects_api
|
||||||
patch_body = {"spec": spec_data}
|
patch_body = {"spec": spec_data}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue