Skip to content

Commit

Permalink
refresh object_name when image using trait observer
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Sep 18, 2023
1 parent 3a6554e commit b8f0164
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dockerspawner/dockerspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,10 @@ def _object_name_default(self):
"""Render the name of our container/service using name_template"""
return self._render_templates(self.name_template)

async def _object_name_for_current_image(self):
"""Render the name of our container/service using name_template"""
return self._render_templates(self.name_template)
@observe("image")
def _image_changed(self, change):
# re-render object name if image changes
self.object_name = self._object_name_default()

def load_state(self, state):
super(DockerSpawner, self).load_state(state)
Expand Down Expand Up @@ -1263,7 +1264,6 @@ async def start(self, image=None, extra_create_kwargs=None, extra_host_config=No
if image_option:
# save choice in self.image
self.image = await self.check_allowed(image_option)
self.object_name = await self._object_name_for_current_image()

image = self.image
await self.pull_image(image)
Expand Down

0 comments on commit b8f0164

Please sign in to comment.