Skip to content

Commit

Permalink
Merge pull request #2795 from calebschoepp/merge-networking-impls
Browse files Browse the repository at this point in the history
Merge host component outbound networking implementation into new factor crate
  • Loading branch information
lann authored Sep 3, 2024
2 parents 8fda052 + ace9513 commit 8c17f33
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 65 deletions.
33 changes: 11 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/factor-outbound-mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ spin-core = { path = "../core" }
spin-expressions = { path = "../expressions" }
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
spin-factors = { path = "../factors" }
spin-outbound-networking = { path = "../outbound-networking" }
spin-world = { path = "../world" }
table = { path = "../table" }
tokio = { version = "1", features = ["rt-multi-thread"] }
Expand Down
7 changes: 5 additions & 2 deletions crates/factor-outbound-networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ rustls = { version = "0.23", default-features = false, features = ["ring", "std"
rustls-pemfile = { version = "2.1.2", optional = true }
rustls-pki-types = "1.7.0"
serde = { version = "1", features = ["derive"] }
spin-expressions = { path = "../expressions" }
spin-factor-variables = { path = "../factor-variables" }
spin-factor-wasi = { path = "../factor-wasi" }
spin-factors = { path = "../factors" }
# TODO: merge with this crate
spin-outbound-networking = { path = "../outbound-networking" }
spin-locked-app = { path = "../locked-app" }
spin-serde = { path = "../serde" }
terminal = { path = "../terminal" }
tracing = { workspace = true }
url = "2.4.1"
urlencoding = "2.1"
webpki-roots = "0.26"

[dev-dependencies]
Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions crates/factor-outbound-networking/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
mod config;
pub mod runtime_config;

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

use config::ALLOWED_HOSTS_KEY;
use futures_util::{
future::{BoxFuture, Shared},
FutureExt,
Expand All @@ -14,9 +16,11 @@ use spin_factors::{
ConfigureAppContext, Error, Factor, FactorInstanceBuilder, InstanceBuilders, PrepareContext,
RuntimeFactors,
};
use spin_outbound_networking::{AllowedHostsConfig, ALLOWED_HOSTS_KEY};

pub use spin_outbound_networking::OutboundUrl;
pub use config::{
is_service_chaining_host, parse_service_chaining_target, AllowedHostConfig, AllowedHostsConfig,
HostConfig, OutboundUrl, SERVICE_CHAINING_DOMAIN_SUFFIX,
};

pub use runtime_config::ComponentTlsConfigs;

Expand Down
2 changes: 1 addition & 1 deletion crates/loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shellexpand = "3.1"
spin-common = { path = "../common" }
spin-locked-app = { path = "../locked-app" }
spin-manifest = { path = "../manifest" }
spin-outbound-networking = { path = "../outbound-networking" }
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
spin-serde = { path = "../serde" }
tempfile = "3.8.0"
terminal = { path = "../terminal" }
Expand Down
6 changes: 3 additions & 3 deletions crates/loader/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::{anyhow, bail, ensure, Context, Result};
use futures::{future::try_join_all, StreamExt};
use reqwest::Url;
use spin_common::{paths::parent_dir, sloth, ui::quoted_path};
use spin_factor_outbound_networking::SERVICE_CHAINING_DOMAIN_SUFFIX;
use spin_locked_app::{
locked::{
self, ContentPath, ContentRef, LockedApp, LockedComponent, LockedComponentDependency,
Expand All @@ -12,7 +13,6 @@ use spin_locked_app::{
values::{ValuesMap, ValuesMapBuilder},
};
use spin_manifest::schema::v2::{self, AppManifest, KebabId, WasiFilesMount};
use spin_outbound_networking::SERVICE_CHAINING_DOMAIN_SUFFIX;
use spin_serde::DependencyName;
use std::collections::BTreeMap;
use tokio::{io::AsyncWriteExt, sync::Semaphore};
Expand Down Expand Up @@ -147,7 +147,7 @@ impl LocalLoader {
let allowed_outbound_hosts = component
.normalized_allowed_outbound_hosts()
.context("`allowed_http_hosts` is malformed")?;
spin_outbound_networking::AllowedHostsConfig::validate(&allowed_outbound_hosts)
spin_factor_outbound_networking::AllowedHostsConfig::validate(&allowed_outbound_hosts)
.context("`allowed_outbound_hosts` is malformed")?;

let metadata = ValuesMapBuilder::new()
Expand Down Expand Up @@ -784,7 +784,7 @@ fn requires_service_chaining(component: &spin_manifest::schema::v2::Component) -
}

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

let Ok(allowed) = AllowedHostConfig::parse(pattern) else {
return false;
Expand Down
15 changes: 0 additions & 15 deletions crates/outbound-networking/Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion crates/trigger-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spin-core = { path = "../core" }
spin-factor-outbound-http = { path = "../factor-outbound-http" }
spin-factor-wasi = { path = "../factor-wasi" }
spin-http = { path = "../http" }
spin-outbound-networking = { path = "../outbound-networking" }
spin-factor-outbound-networking = { path = "../factor-outbound-networking" }
spin-telemetry = { path = "../telemetry" }
spin-trigger = { path = "../trigger" }
spin-world = { path = "../world" }
Expand Down
2 changes: 1 addition & 1 deletion crates/trigger-http/src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::{net::SocketAddr, str, str::FromStr};
use anyhow::Result;
use http::Uri;
use hyper::Request;
use spin_factor_outbound_networking::is_service_chaining_host;
use spin_http::routes::RouteMatch;
use spin_outbound_networking::is_service_chaining_host;

use crate::Body;

Expand Down
2 changes: 1 addition & 1 deletion crates/trigger-http/src/outbound_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use http::uri::Scheme;
use spin_factor_outbound_http::{
HostFutureIncomingResponse, InterceptOutcome, OutgoingRequestConfig, Request,
};
use spin_factor_outbound_networking::parse_service_chaining_target;
use spin_http::routes::RouteMatch;
use spin_outbound_networking::parse_service_chaining_target;
use wasmtime_wasi_http::types::IncomingResponse;

use crate::HttpServer;
Expand Down
21 changes: 5 additions & 16 deletions examples/spin-timer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8c17f33

Please sign in to comment.