Skip to content

Commit

Permalink
Upload pending local resources after deploy only for server_side_deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
cderici committed Sep 20, 2023
1 parent 63659d1 commit 1d05e5c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2113,10 +2113,18 @@ async def _deploy(self, charm_url, application, series, config,
revision=charm_origin.revision,
)
result = await app_facade.DeployFromRepository([app])
# Collect the errors
errors = []
for r in result.results:
if r.errors:
errors.extend([e.message for e in r.errors])
# Upload pending local resources if any
for _result in result.results:
for pending_upload_resource in getattr(_result, 'pendingresourceuploads', []):
_path = pending_upload_resource.filename
p = Path(_path)
data = p.read_text() if p.exists() else ''
self._upload(data, _path, application, pending_upload_resource.name, 'file', '')
else:
app = client.ApplicationDeploy(
charm_url=charm_url,
Expand All @@ -2140,13 +2148,6 @@ async def _deploy(self, charm_url, application, series, config,
if errors:
raise JujuError('\n'.join(errors))

for _result in result.results:
for pending_upload_resource in _result.pendingresourceuploads:
_path = pending_upload_resource.filename
p = Path(_path)
data = p.read_text() if p.exists() else ''
self._upload(data, _path, application, pending_upload_resource.name, 'file', '')

return await self._wait_for_new('application', application)

async def destroy_unit(self, unit_id, destroy_storage=False, dry_run=False, force=False, max_wait=None):
Expand Down

0 comments on commit 1d05e5c

Please sign in to comment.