-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Services currently expose their ports through different means. The Python service, for example, writes the logical port it exposes to stdout and the Python service code knows to look there for the port. Docker services do this by exposing a port from their Docker file.
This usually is opque to users of the test-environment crate because they simply ask a test environment to replace a logical port with the actual port the service is listening on in the host.
However, some environments don't use services (e.g., spin-test), and they are instead supposed to know the magical mapping between logical port number and what service is available there (e.g., port 7 is TCP echo and port 80 is HTTP echo). With more services this will become even more confusing.
Instead, we should not be writing port numbers into Spin.toml templates but instead referring to the services directly:
# Instead of:
# allowed_outbound_hosts = ["*://127.0.0.1:%{port=7}"]
# We now have:
allowed_outbound_hosts = ["*://127.0.0.1:%{port=tcp-echo}"]The environment can then ask a specific service for its exposes port. And if a test runner doesn't use services, it can decide how best to handle port mapping from service to port.
What about services that expose multiple ports
We currently don't have any services that expose more than one port, but that might change in the future. Perhaps in the future we extend the syntax to something like:
allowed_outbound_hosts = ["*://127.0.0.1:%{port=my-new-service[some-feature]}"]