Add patch info to pre_upload_hook.
We got a specific case in which this change is needed: An aritifact type that only one instance is allowed to be in 'active' status. To enforce that we want to use pre_update_hook, and check if there is any other artifact in 'active' status. To do so we need json_patch info (we need to know if the json_patch change status to "active" or "deactivated". This change aim to suuport this case and also support backward compatibility. With this background, if the a user update 'active' artifact to be with status "deactivated", we must know the patch info. Change-Id: I6e85ff89144ca6d3a69c7a240de3f41bd1d999e7
This commit is contained in:
parent
1cee3290ed
commit
26e4184c8d
@ -151,7 +151,7 @@ class Engine(object):
|
|||||||
action_names = ['update']
|
action_names = ['update']
|
||||||
af_dict = af.to_dict()
|
af_dict = af.to_dict()
|
||||||
policy.authorize('artifact:update', af_dict, context)
|
policy.authorize('artifact:update', af_dict, context)
|
||||||
af.pre_update_hook(context, af)
|
af.pre_update_hook_with_patch(context, af, patch)
|
||||||
try:
|
try:
|
||||||
for operation in patch._ops:
|
for operation in patch._ops:
|
||||||
# apply the change to make sure that it's correct
|
# apply the change to make sure that it's correct
|
||||||
|
@ -549,6 +549,10 @@ Possible values:
|
|||||||
def pre_update_hook(cls, context, af):
|
def pre_update_hook(cls, context, af):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def pre_update_hook_with_patch(cls, context, af, json_patch):
|
||||||
|
cls.pre_update_hook(context, af)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def post_update_hook(cls, context, af):
|
def post_update_hook(cls, context, af):
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user