Skip to content

Commit cec424f

Browse files
committed
Upload pending local resources after deploy only for server_side_deploy
1 parent 67128e9 commit cec424f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

juju/model.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,10 +2113,18 @@ async def _deploy(self, charm_url, application, series, config,
21132113
revision=charm_origin.revision,
21142114
)
21152115
result = await app_facade.DeployFromRepository([app])
2116+
# Collect the errors
21162117
errors = []
21172118
for r in result.results:
21182119
if r.errors:
21192120
errors.extend([e.message for e in r.errors])
2121+
# Upload pending local resources if any
2122+
for _result in result.results:
2123+
for pending_upload_resource in getattr(_result, 'pendingresourceuploads', []):
2124+
_path = pending_upload_resource.filename
2125+
p = Path(_path)
2126+
data = p.read_text() if p.exists() else ''
2127+
self._upload(data, _path, application, pending_upload_resource.name, 'file', '')
21202128
else:
21212129
app = client.ApplicationDeploy(
21222130
charm_url=charm_url,
@@ -2140,13 +2148,6 @@ async def _deploy(self, charm_url, application, series, config,
21402148
if errors:
21412149
raise JujuError('\n'.join(errors))
21422150

2143-
for _result in result.results:
2144-
for pending_upload_resource in _result.pendingresourceuploads:
2145-
_path = pending_upload_resource.filename
2146-
p = Path(_path)
2147-
data = p.read_text() if p.exists() else ''
2148-
self._upload(data, _path, application, pending_upload_resource.name, 'file', '')
2149-
21502151
return await self._wait_for_new('application', application)
21512152

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

0 commit comments

Comments
 (0)