tilt-dev / tilt

Define your dev environment as code. For microservice apps on Kubernetes.
https://tilt.dev/
Apache License 2.0
7.7k stars 303 forks source link

Provide a way to hide port-forwards in the Tilt UI #5485

Open psigen opened 2 years ago

psigen commented 2 years ago

When I am developing APIs that are used internally (e.g. REST or gRPC), I need to create port-forwards to things that do not display a webpage, but are used by other applications. In these situations, I want to add a Link to a k8s_resource referencing my other application that uses an API, and not show an HTTP address to the API endpoint itself in the Tilt UI.

One example is when I am running a GraphQL Playground separately that connects to a graphql API. I do not want to show the API endpoint as an HTTP URL in the Tilt UI. Instead, I can add a Link to the GraphQL Playground website where I can make interactive calls to the API using my port-forward.

Unfortunately, there does not seem to be any option to create a port-forward and completely hide or make non-clickable the hyperlink in the UI. https://github.com/tilt-dev/tilt/blob/d79b05e6a6f667e0a34599878a36394590fc8932/pkg/model/manifest.go#L448-L450

This has been pretty confusing for my users, since they get a set of links like http://localhost:8080 that just show error codes if clicked. Right now I am using the option name="dontclickme", but this is a silly workaround.

nicks commented 2 years ago

Thanks for the request! Ya, i wonder if we can come up with a way to configure this that's intuitive.

psigen commented 2 years ago

One option that might make sense is to define a sentinel value like PortForward.AUTO and make that the default, and switch the value of name=None to suppress the port visibility.

This would let folks do:

port_forward(...)                           # Default behavior of showing port name
port_forward(..., name = PortForward.AUTO)  # Default behavior of showing port name
port_forward(..., name = None)              # Do not display anything on the UI
wuservices commented 2 years ago

Came across this with something similar as I'm exposing an additional port for a websocket for my app. Another thought is you could make the visibility explicit, e.g.

port_forward(..., ui = False)