(
server: &str,
sandbox: &str,
service: &str,
target_port: u16,
tls: &TlsOptions,
)
| 4121 | } |
| 4122 | |
| 4123 | pub async fn service_expose( |
| 4124 | server: &str, |
| 4125 | sandbox: &str, |
| 4126 | service: &str, |
| 4127 | target_port: u16, |
| 4128 | tls: &TlsOptions, |
| 4129 | ) -> Result<()> { |
| 4130 | let mut client = grpc_client(server, tls).await?; |
| 4131 | let response = client |
| 4132 | .expose_service(ExposeServiceRequest { |
| 4133 | sandbox: sandbox.to_string(), |
| 4134 | service: service.to_string(), |
| 4135 | target_port: u32::from(target_port), |
| 4136 | domain: true, |
| 4137 | }) |
| 4138 | .await |
| 4139 | .map_err(service_expose_status_error)? |
| 4140 | .into_inner(); |
| 4141 | |
| 4142 | if service.is_empty() { |
| 4143 | println!( |
| 4144 | "{} Exposed sandbox {} -> 127.0.0.1:{}", |
| 4145 | "✓".green().bold(), |
| 4146 | sandbox.bold(), |
| 4147 | target_port, |
| 4148 | ); |
| 4149 | } else { |
| 4150 | println!( |
| 4151 | "{} Exposed service {} on sandbox {} -> 127.0.0.1:{}", |
| 4152 | "✓".green().bold(), |
| 4153 | service.bold(), |
| 4154 | sandbox.bold(), |
| 4155 | target_port, |
| 4156 | ); |
| 4157 | } |
| 4158 | if !response.url.is_empty() { |
| 4159 | let url = service_url_for_gateway(&response.url, server); |
| 4160 | println!(" URL: {}", url.cyan()); |
| 4161 | } |
| 4162 | Ok(()) |
| 4163 | } |
| 4164 | |
| 4165 | fn service_expose_status_error(status: Status) -> miette::Report { |
| 4166 | service_status_error("expose service", "sandbox:write", status) |
no test coverage detected