-
Notifications
You must be signed in to change notification settings - Fork 19
Expose a 'defaultEndpoint' off of a Service to make consumption easier. #465
Conversation
api/service.ts
Outdated
* The primary endpoint exposed by the service. All endpoints (including this one) | ||
* can also be retrieved by using the 'Service.endpoints' property. | ||
*/ | ||
defaultEndpoint: pulumi.Output<Endpoint>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the way you get away with this being Endpoint
instead of Endpoint | undefined
is to throw inside the promise transformation? Is that "safe"? How do those errors bubble up? (they can't be "caught" like normal promise errors since we don't expose them into apply
). Will they only bubble up when defaultEndpoint
is referenced, or even if it never is referenced?
That said, we really do want this to be Endpoint
so that we can still pass it to proxy
and transform it relatively easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that "safe"? How do those errors bubble up?
They should bubble up like any sort of exception thrown during resource creation. It will just be during the phase where we await output promises. This will likely happen during closure serialization.
Let me go see how this appears to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: "Testing error" was just the message i threw.
Note: i've switched to using RunError here. It seems appropriate given that this represents a problem with the user's code. |
Does that work in cases theses errors are hit at runtime (through |
yes. these should just work. i'll validate the closure serialization just to make sure. |
Yup. clsoure serialization properly serializes over this type, and gives it hte right prototype and everything. Amazing :D |
@@ -662,28 +674,39 @@ export class Service extends pulumi.ComponentResource implements cloud.Service { | |||
const localEndpoints = getEndpoints(ports); | |||
this.endpoints = localEndpoints; | |||
|
|||
this.defaultEndpoint = firstContainerName === undefined || firstContainerPort === undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a comment about why we do this?
firstContainerPort = container.ports[0].port; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need firstContainerName
or firstContainerPort
- or do we just need a bool indicating whether there was at least one port found in any container? (which we could set in the for loop below).
Fixes #408