Skip to content

Commit

Permalink
More testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jan 17, 2025
1 parent 0eede1b commit a694bae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ unstable_remote:
auth:
token: 'DEPOT_TOKEN'
headers:
Authorization:
'Bearer depot_org_ece2365d877c7f2f437f46de5bf03bd54862e3ca7fde67f079264e971ecb0789'
'X-Depot-Org': '1xtpjd084j'
'X-Depot-Project': '90xxfkst9n'
# cache:
Expand Down
6 changes: 5 additions & 1 deletion crates/config/src/workspace/remote_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ pub struct RemoteConfig {
}

impl RemoteConfig {
pub fn is_bearer_auth(&self) -> bool {
self.auth.as_ref().is_some_and(|auth| auth.token.is_some())
}

pub fn is_localhost(&self) -> bool {
self.host.contains("localhost") || self.host.contains("0.0.0.0")
}

pub fn is_secure(&self) -> bool {
self.auth.is_some() || self.tls.is_some() || self.mtls.is_some()
self.is_bearer_auth() || self.tls.is_some() || self.mtls.is_some()
}
}
20 changes: 8 additions & 12 deletions crates/remote/src/grpc_remote_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ pub struct GrpcRemoteClient {

impl GrpcRemoteClient {
fn inject_auth_headers(&self, mut req: Request<()>) -> Result<Request<()>, Status> {
if self.config.mtls.is_some() || self.config.tls.is_some() {
return Ok(req);
}

if let Some(auth) = &self.config.auth {
let headers = req.metadata_mut();

Expand Down Expand Up @@ -101,7 +97,7 @@ impl RemoteClient for GrpcRemoteClient {
"(with mTLS)"
} else if config.tls.is_some() {
"(with TLS)"
} else if config.auth.is_some() {
} else if config.is_bearer_auth() {
"(with auth)"
} else {
"(insecure)"
Expand All @@ -110,13 +106,13 @@ impl RemoteClient for GrpcRemoteClient {

// Although we use a grpc(s) protocol for the host,
// tonic only supports http(s), so change it
let url = if let Some(suffix) = host.strip_prefix("grpc") {
format!("http{suffix}")
} else {
host.to_owned()
};
// let url = if let Some(suffix) = host.strip_prefix("grpc") {
// format!("http{suffix}")
// } else {
// host.to_owned()
// };

let mut endpoint = Endpoint::from_shared(url)
let mut endpoint = Endpoint::from_shared(host.to_owned())
.map_err(map_transport_error)?
.user_agent("moon")
.map_err(map_transport_error)?
Expand Down Expand Up @@ -147,7 +143,7 @@ impl RemoteClient for GrpcRemoteClient {

// We can't inject auth headers into this initial connection,
// so defer the connection until a client is used
if self.config.auth.is_some() {
if self.config.is_bearer_auth() {
self.channel = Some(endpoint.connect_lazy());
} else {
self.channel = Some(endpoint.connect().await.map_err(map_transport_error)?);
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export interface Runtime {
}

export type ExtendsFrom = string[] | string;

// 123

0 comments on commit a694bae

Please sign in to comment.