Skip to content

Commit 4f762a8

Browse files
committed
Add apo model helper to check if controller supports expose parameters
1 parent 658d92b commit 4f762a8

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

juju/application.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ async def destroy(self):
236236
return await app_facade.Destroy(application=self.name)
237237
remove = destroy
238238

239+
def supports_granular_expose_parameters(self):
240+
"""Returns true if the controller supports granular, per-endpoint
241+
expose parameters."""
242+
return self._facade_version() >= 13
243+
239244
async def expose(self, exposed_endpoints=None):
240245
"""Make a subset of the application endpoints or the entire application
241246
available over the network.
@@ -254,7 +259,7 @@ async def expose(self, exposed_endpoints=None):
254259
is not supported and an error will be raised if it is provided.
255260
"""
256261
app_facade = self._facade()
257-
facade_version = self._facade_version()
262+
ctrl_supports_expose_parameters = self.supports_granular_expose_parameters()
258263

259264
if exposed_endpoints is not None:
260265
if not isinstance(exposed_endpoints, dict):
@@ -280,7 +285,7 @@ async def expose(self, exposed_endpoints=None):
280285
)
281286

282287
is_security_risk = (
283-
facade_version < 13 and
288+
not ctrl_supports_expose_parameters and
284289
(
285290
has_more_than_one_endpoints or
286291
has_non_wildcard_endpoint or
@@ -308,7 +313,7 @@ async def expose(self, exposed_endpoints=None):
308313
else:
309314
log.debug("expose all endpoints of %s and allow access from CIDRs 0.0.0.0/0 and ::/0", self.name)
310315

311-
if facade_version < 13:
316+
if not ctrl_supports_expose_parameters:
312317
return await app_facade.Expose(application=self.name)
313318

314319
return await app_facade.Expose(application=self.name,

0 commit comments

Comments
 (0)