77
88from .meta import load_instance_meta , load_binding_meta , dump_binding_meta
99from .utils import get_instance_path , get_chart_path , get_plan_path , \
10- get_addon_path , get_addon_name
11- from .tasks import provision , bind , deprovision
10+ get_addon_path , get_addon_name , get_addon_updateable
11+ from .tasks import provision , bind , deprovision , update
1212from helmbroker .loader import read_addons_file
1313
1414
@@ -88,8 +88,22 @@ def update(self,
8888 async_allowed : bool ,
8989 ** kwargs
9090 ) -> UpdateServiceSpec :
91- # Update service instnce
92- return ProvisionedServiceSpec ()
91+ instance_path = get_instance_path (instance_id )
92+ if not os .path .exists (instance_path ):
93+ raise ErrBadRequest ("Instance %s does not exist" % instance_id )
94+ is_plan_updateable = get_addon_updateable (instance_id )
95+ if not is_plan_updateable :
96+ raise ErrBadRequest ("Instance %s does not updateable" % instance_id )
97+ if not async_allowed :
98+ raise ErrAsyncRequired ()
99+ plan_path = get_plan_path (instance_id )
100+ # delete the pre plan
101+ shutil .rmtree (plan_path )
102+ _ , addon_plan_path = get_addon_path (details .service_id , details .plan_id )
103+ # add the new plan
104+ shutil .copy (addon_plan_path , plan_path )
105+ update .delay (instance_id , details )
106+ return UpdateServiceSpec (is_async = True )
93107
94108 def deprovision (self ,
95109 instance_id : str ,
@@ -103,7 +117,7 @@ def deprovision(self,
103117 raise ErrAsyncRequired ()
104118
105119 deprovision .delay (instance_id , details )
106- return DeprovisionServiceSpec (state = ProvisionState . IS_ASYNC )
120+ return DeprovisionServiceSpec (is_async = True )
107121
108122 def last_operation (self ,
109123 instance_id : str ,
0 commit comments