Skip to content

Commit d7e3694

Browse files
committed
Avoid parsing endpoint unless needed
1 parent b89b1e2 commit d7e3694

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

juju/controller.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -728,24 +728,32 @@ async def create_offer(self, model_uuid, endpoint, offer_name=None, application_
728728
consumers.
729729
730730
@param endpoint: holds the application and endpoint you want to offer
731-
@param offer_name: over ride the offer name to help the consumer
731+
@param offer_name: override the offer name to help the consumer
732+
@param application_name: overrides the application name in the endpoint
732733
"""
733-
try:
734-
offer = parse_offer_endpoint(endpoint)
735-
except OfferParseError as e:
736-
log.error(e.message)
737-
raise
738734

739-
if offer_name is None:
740-
offer_name = offer.application
735+
# If we have both the offer_name and the application_name
736+
# then we're coming from bundle/overlays, so no need to parse the endpoint
737+
# Also we accept endpoints without a colon (:) in the overlays
738+
if offer_name and application_name:
739+
o_name = offer_name
740+
a_name = application_name
741+
eps = {endpoint : endpoint}
742+
else:
743+
try:
744+
offer = parse_offer_endpoint(endpoint)
745+
except OfferParseError as e:
746+
log.error(e.message)
747+
raise
741748

742-
if application_name is None:
743-
application_name = offer.application
749+
o_name = offer_name if offer_name else offer.application
750+
a_name = application_name if application_name else offer.application
751+
eps = {name: name for name in offer.endpoints}
744752

745753
params = client.AddApplicationOffer()
746-
params.application_name = application_name
747-
params.endpoints = {name: name for name in offer.endpoints}
748-
params.offer_name = offer_name
754+
params.application_name = a_name
755+
params.endpoints = eps
756+
params.offer_name = o_name
749757
params.model_tag = tag.model(model_uuid)
750758

751759
facade = client.ApplicationOffersFacade.from_connection(self.connection())

0 commit comments

Comments
 (0)