Fix update action
This patch fixes patch creation for updating. Also, for that, the model for update request from UI should have server_type attribute. Change-Id: I9b2cabb42036077236374c839e854d5357302684
This commit is contained in:
parent
39c504bd6f
commit
05f2ca6e5d
@ -34,14 +34,17 @@ CLUSTER_CREATE_ATTRS = clusters.CREATION_ATTRIBUTES
|
|||||||
CERTIFICATE_CREATE_ATTRS = certificates.CREATION_ATTRIBUTES
|
CERTIFICATE_CREATE_ATTRS = certificates.CREATION_ATTRIBUTES
|
||||||
|
|
||||||
|
|
||||||
def _cleanup_params(attrs, check, **params):
|
def _cleanup_params(attrs, create, **params):
|
||||||
args = {}
|
args = {}
|
||||||
for (key, value) in params.items():
|
for (key, value) in params.items():
|
||||||
if key in attrs:
|
if key in attrs:
|
||||||
if value is None:
|
if value is None:
|
||||||
|
if create:
|
||||||
value = ''
|
value = ''
|
||||||
|
else:
|
||||||
|
continue
|
||||||
args[str(key)] = str(value)
|
args[str(key)] = str(value)
|
||||||
elif check:
|
elif create:
|
||||||
raise exceptions.BadRequest(
|
raise exceptions.BadRequest(
|
||||||
"Key must be in %s" % ",".join(attrs))
|
"Key must be in %s" % ",".join(attrs))
|
||||||
if key == "labels":
|
if key == "labels":
|
||||||
@ -66,6 +69,7 @@ def _create_patches(old, new):
|
|||||||
# new = {'a': 'A', 'c': 'c', 'd': None, 'e': '', 'f': 'F'}
|
# new = {'a': 'A', 'c': 'c', 'd': None, 'e': '', 'f': 'F'}
|
||||||
# patch = [
|
# patch = [
|
||||||
# {'op': 'add', 'path': '/f', 'value': 'F'}
|
# {'op': 'add', 'path': '/f', 'value': 'F'}
|
||||||
|
# {'op': 'remove', 'path': '/b'},
|
||||||
# {'op': 'remove', 'path': '/e'},
|
# {'op': 'remove', 'path': '/e'},
|
||||||
# {'op': 'remove', 'path': '/d'},
|
# {'op': 'remove', 'path': '/d'},
|
||||||
# {'op': 'replace', 'path': '/c', 'value': 'c'}
|
# {'op': 'replace', 'path': '/c', 'value': 'c'}
|
||||||
@ -84,6 +88,11 @@ def _create_patches(old, new):
|
|||||||
elif key not in old:
|
elif key not in old:
|
||||||
patch.append({'op': 'add', 'path': path, 'value': new[key]})
|
patch.append({'op': 'add', 'path': path, 'value': new[key]})
|
||||||
|
|
||||||
|
for key in old:
|
||||||
|
path = '/' + key
|
||||||
|
if key not in new:
|
||||||
|
patch.append({'op': 'remove', 'path': path})
|
||||||
|
|
||||||
return patch
|
return patch
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,8 @@
|
|||||||
? response.data.name : "";
|
? response.data.name : "";
|
||||||
config.model.coe = response.data.coe
|
config.model.coe = response.data.coe
|
||||||
? response.data.coe : "";
|
? response.data.coe : "";
|
||||||
|
config.model.server_type = response.data.server_type
|
||||||
|
? response.data.server_type : "";
|
||||||
config.model.public = response.data.public
|
config.model.public = response.data.public
|
||||||
? response.data.public : false;
|
? response.data.public : false;
|
||||||
config.model.registry_enabled = response.data.registry_enabled
|
config.model.registry_enabled = response.data.registry_enabled
|
||||||
|
@ -445,6 +445,7 @@
|
|||||||
model = {
|
model = {
|
||||||
name: "",
|
name: "",
|
||||||
coe: "",
|
coe: "",
|
||||||
|
server_type: "",
|
||||||
public: "",
|
public: "",
|
||||||
registry_enabled: "",
|
registry_enabled: "",
|
||||||
tls_disabled: "",
|
tls_disabled: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user