Skip to content

Commit ace9513

Browse files
committed
Merge host component outbound networking implementation into new factor crate
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent 7583fc5 commit ace9513

File tree

12 files changed

+34
-65
lines changed

12 files changed

+34
-65
lines changed

Cargo.lock

Lines changed: 11 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/factor-outbound-mysql/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spin-core = { path = "../core" }
2121
spin-expressions = { path = "../expressions" }
2222
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
2323
spin-factors = { path = "../factors" }
24-
spin-outbound-networking = { path = "../outbound-networking" }
2524
spin-world = { path = "../world" }
2625
table = { path = "../table" }
2726
tokio = { version = "1", features = ["rt-multi-thread"] }

crates/factor-outbound-networking/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ rustls = { version = "0.23", default-features = false, features = ["ring", "std"
1313
rustls-pemfile = { version = "2.1.2", optional = true }
1414
rustls-pki-types = "1.7.0"
1515
serde = { version = "1", features = ["derive"] }
16+
spin-expressions = { path = "../expressions" }
1617
spin-factor-variables = { path = "../factor-variables" }
1718
spin-factor-wasi = { path = "../factor-wasi" }
1819
spin-factors = { path = "../factors" }
19-
# TODO: merge with this crate
20-
spin-outbound-networking = { path = "../outbound-networking" }
20+
spin-locked-app = { path = "../locked-app" }
2121
spin-serde = { path = "../serde" }
22+
terminal = { path = "../terminal" }
2223
tracing = { workspace = true }
24+
url = "2.4.1"
25+
urlencoding = "2.1"
2326
webpki-roots = "0.26"
2427

2528
[dev-dependencies]

crates/factor-outbound-networking/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
mod config;
12
pub mod runtime_config;
23

34
use std::{collections::HashMap, sync::Arc};
45

6+
use config::ALLOWED_HOSTS_KEY;
57
use futures_util::{
68
future::{BoxFuture, Shared},
79
FutureExt,
@@ -14,9 +16,11 @@ use spin_factors::{
1416
ConfigureAppContext, Error, Factor, FactorInstanceBuilder, InstanceBuilders, PrepareContext,
1517
RuntimeFactors,
1618
};
17-
use spin_outbound_networking::{AllowedHostsConfig, ALLOWED_HOSTS_KEY};
1819

19-
pub use spin_outbound_networking::OutboundUrl;
20+
pub use config::{
21+
is_service_chaining_host, parse_service_chaining_target, AllowedHostConfig, AllowedHostsConfig,
22+
HostConfig, OutboundUrl, SERVICE_CHAINING_DOMAIN_SUFFIX,
23+
};
2024

2125
pub use runtime_config::ComponentTlsConfigs;
2226

crates/loader/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ shellexpand = "3.1"
2626
spin-common = { path = "../common" }
2727
spin-locked-app = { path = "../locked-app" }
2828
spin-manifest = { path = "../manifest" }
29-
spin-outbound-networking = { path = "../outbound-networking" }
29+
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
3030
spin-serde = { path = "../serde" }
3131
tempfile = "3.8.0"
3232
terminal = { path = "../terminal" }

crates/loader/src/local.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::{anyhow, bail, ensure, Context, Result};
44
use futures::{future::try_join_all, StreamExt};
55
use reqwest::Url;
66
use spin_common::{paths::parent_dir, sloth, ui::quoted_path};
7+
use spin_factor_outbound_networking::SERVICE_CHAINING_DOMAIN_SUFFIX;
78
use spin_locked_app::{
89
locked::{
910
self, ContentPath, ContentRef, LockedApp, LockedComponent, LockedComponentDependency,
@@ -12,7 +13,6 @@ use spin_locked_app::{
1213
values::{ValuesMap, ValuesMapBuilder},
1314
};
1415
use spin_manifest::schema::v2::{self, AppManifest, KebabId, WasiFilesMount};
15-
use spin_outbound_networking::SERVICE_CHAINING_DOMAIN_SUFFIX;
1616
use spin_serde::DependencyName;
1717
use std::collections::BTreeMap;
1818
use tokio::{io::AsyncWriteExt, sync::Semaphore};
@@ -147,7 +147,7 @@ impl LocalLoader {
147147
let allowed_outbound_hosts = component
148148
.normalized_allowed_outbound_hosts()
149149
.context("`allowed_http_hosts` is malformed")?;
150-
spin_outbound_networking::AllowedHostsConfig::validate(&allowed_outbound_hosts)
150+
spin_factor_outbound_networking::AllowedHostsConfig::validate(&allowed_outbound_hosts)
151151
.context("`allowed_outbound_hosts` is malformed")?;
152152

153153
let metadata = ValuesMapBuilder::new()
@@ -784,7 +784,7 @@ fn requires_service_chaining(component: &spin_manifest::schema::v2::Component) -
784784
}
785785

786786
fn is_chaining_host(pattern: &str) -> bool {
787-
use spin_outbound_networking::{AllowedHostConfig, HostConfig};
787+
use spin_factor_outbound_networking::{AllowedHostConfig, HostConfig};
788788

789789
let Ok(allowed) = AllowedHostConfig::parse(pattern) else {
790790
return false;

crates/outbound-networking/Cargo.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

crates/trigger-http/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ spin-core = { path = "../core" }
3434
spin-factor-outbound-http = { path = "../factor-outbound-http" }
3535
spin-factor-wasi = { path = "../factor-wasi" }
3636
spin-http = { path = "../http" }
37-
spin-outbound-networking = { path = "../outbound-networking" }
37+
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
3838
spin-telemetry = { path = "../telemetry" }
3939
spin-trigger = { path = "../trigger" }
4040
spin-world = { path = "../world" }

crates/trigger-http/src/headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::{net::SocketAddr, str, str::FromStr};
33
use anyhow::Result;
44
use http::Uri;
55
use hyper::Request;
6+
use spin_factor_outbound_networking::is_service_chaining_host;
67
use spin_http::routes::RouteMatch;
7-
use spin_outbound_networking::is_service_chaining_host;
88

99
use crate::Body;
1010

0 commit comments

Comments
 (0)