Skip to content

Commit 0746884

Browse files
authored
Merge branch 'fermyon:main' into issue/2335/fix-swallowed-mqtt-errors
2 parents 5c70710 + 4c8c2db commit 0746884

File tree

36 files changed

+586
-125
lines changed

36 files changed

+586
-125
lines changed

.github/actions/spin-ci-dependencies/action.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ inputs:
7878
default: 'false'
7979
type: bool
8080

81-
vcpkg:
82-
description: 'setup vcpkg'
81+
openssl-windows:
82+
description: 'setup openssl on windows'
8383
required: false
8484
default: 'false'
8585
type: bool
@@ -91,7 +91,7 @@ runs:
9191
shell: bash
9292
if: ${{ inputs.rust == 'true' }}
9393
run: |
94-
rustup toolchain install ${{ inputs.rust-version }} --component clippy --component rustfmt
94+
rustup toolchain install ${{ inputs.rust-version }} --component clippy --component rustfmt --no-self-update
9595
rustup default ${{ inputs.rust-version }}
9696
9797
- name: "Install Wasm Rust target"
@@ -136,10 +136,10 @@ runs:
136136
with:
137137
version: ${{ inputs.tinygo-version }}
138138

139-
## Install vcpgk
140-
- name: "Install vcpkg"
139+
## Install openssl
140+
- name: "Install openssl on windows"
141141
run: |
142142
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
143143
vcpkg install openssl:x64-windows-static-md
144144
shell: pwsh
145-
if: ${{ inputs.vcpkg == 'true' }}
145+
if: ${{ inputs.openssl-windows == 'true' }}

.github/workflows/build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
rust: true
127127
rust-wasm: true
128128
rust-cache: true
129-
vcpkg: "${{ matrix.os == 'windows-latest' }}"
129+
openssl-windows: "${{ matrix.os == 'windows-latest' }}"
130130

131131
- name: Cargo Build
132132
run: cargo build --workspace --release --all-targets
@@ -257,7 +257,7 @@ jobs:
257257
- name: Install Rust toolchain
258258
shell: bash
259259
run: |
260-
rustup toolchain install ${{ env.RUST_VERSION }}
260+
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update
261261
rustup default ${{ env.RUST_VERSION }}
262262
263263
- name: Install target
@@ -280,8 +280,7 @@ jobs:
280280
- name: setup dependencies
281281
uses: ./.github/actions/spin-ci-dependencies
282282
with:
283-
vcpkg: "${{ matrix.os == 'windows-latest' }}"
284-
openssl-mac: "${{ matrix.os == 'macos-latest' }}"
283+
openssl-windows: "${{ matrix.os == 'windows-latest' }}"
285284

286285
- name: build release
287286
shell: bash

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- name: Install Rust toolchain
9595
shell: bash
9696
run: |
97-
rustup toolchain install ${{ env.RUST_VERSION }}
97+
rustup toolchain install ${{ env.RUST_VERSION }} --no-self-update
9898
rustup default ${{ env.RUST_VERSION }}
9999
100100
- name: Install target
@@ -117,7 +117,7 @@ jobs:
117117
- name: setup dependencies
118118
uses: ./.github/actions/spin-ci-dependencies
119119
with:
120-
vcpkg: "${{ matrix.os == 'windows-latest' }}"
120+
openssl-windows: "${{ matrix.os == 'windows-latest' }}"
121121

122122
- name: build release
123123
shell: bash

Cargo.lock

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

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use cargo_target_dep::build_target_dep;
1010
const TIMER_TRIGGER_INTEGRATION_TEST: &str = "examples/spin-timer/app-example";
1111

1212
fn main() {
13+
// Don't inherit flags from our own invocation of cargo into sub-invocations
14+
// since the flags are intended for the host and we're compiling for wasm.
15+
std::env::remove_var("CARGO_ENCODED_RUSTFLAGS");
16+
1317
// Extract environment information to be passed to plugins.
1418
// Git information will be set to defaults if Spin is not
1519
// built within a Git worktree.

crates/common/src/url.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,34 @@ pub fn parse_file_url(url: &str) -> anyhow::Result<PathBuf> {
1111
.to_file_path()
1212
.map_err(|_| anyhow!("Invalid file URL path: {url:?}"))
1313
}
14+
15+
/// Remove the credentials from a URL string
16+
pub fn remove_credentials(url: &str) -> anyhow::Result<String> {
17+
let mut url = url::Url::parse(url).with_context(|| format!("Invalid URL: {url:?}"))?;
18+
url.set_username("")
19+
.map_err(|_| anyhow!("Could not remove username"))?;
20+
url.set_password(None)
21+
.map_err(|_| anyhow!("Could not remove password"))?;
22+
Ok(url.to_string())
23+
}
24+
25+
#[cfg(test)]
26+
mod test {
27+
use super::*;
28+
29+
#[test]
30+
fn remove_credentials_removes_credentials() {
31+
assert_eq!(
32+
"redis://example.com:4567",
33+
remove_credentials("redis://example.com:4567").unwrap()
34+
);
35+
assert_eq!(
36+
"redis://example.com:4567",
37+
remove_credentials("redis://me:[email protected]:4567").unwrap()
38+
);
39+
assert_eq!(
40+
"http://example.com/users",
41+
remove_credentials("http://me:[email protected]/users").unwrap()
42+
);
43+
}
44+
}

crates/core/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod store;
1515
pub mod wasi_2023_10_18;
1616
pub mod wasi_2023_11_10;
1717

18-
use std::{path::PathBuf, sync::Arc, time::Duration};
18+
use std::{path::PathBuf, time::Duration};
1919

2020
use anyhow::Result;
2121
use crossbeam_channel::Sender;
@@ -395,14 +395,14 @@ impl<T: OutboundWasiHttpHandler + Send + Sync> Engine<T> {
395395
/// Creates a new [`InstancePre`] for the given [`Component`].
396396
#[instrument(skip_all)]
397397
pub fn instantiate_pre(&self, component: &Component) -> Result<InstancePre<T>> {
398-
let inner = Arc::new(self.linker.instantiate_pre(component)?);
398+
let inner = self.linker.instantiate_pre(component)?;
399399
Ok(InstancePre { inner })
400400
}
401401

402402
/// Creates a new [`ModuleInstancePre`] for the given [`Module`].
403403
#[instrument(skip_all)]
404404
pub fn module_instantiate_pre(&self, module: &Module) -> Result<ModuleInstancePre<T>> {
405-
let inner = Arc::new(self.module_linker.instantiate_pre(module)?);
405+
let inner = self.module_linker.instantiate_pre(module)?;
406406
Ok(ModuleInstancePre { inner })
407407
}
408408

@@ -424,7 +424,7 @@ impl<T> AsRef<wasmtime::Engine> for Engine<T> {
424424
///
425425
/// See [`wasmtime::component::InstancePre`] for more information.
426426
pub struct InstancePre<T> {
427-
inner: Arc<wasmtime::component::InstancePre<Data<T>>>,
427+
inner: wasmtime::component::InstancePre<Data<T>>,
428428
}
429429

430430
impl<T: Send + Sync> InstancePre<T> {
@@ -453,7 +453,7 @@ impl<T> AsRef<wasmtime::component::InstancePre<Data<T>>> for InstancePre<T> {
453453
///
454454
/// See [`wasmtime::InstancePre`] for more information.
455455
pub struct ModuleInstancePre<T> {
456-
inner: Arc<wasmtime::InstancePre<Data<T>>>,
456+
inner: wasmtime::InstancePre<Data<T>>,
457457
}
458458

459459
impl<T: Send + Sync> ModuleInstancePre<T> {

crates/core/src/wasi_2023_10_18.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod bindings {
2222
path: "../../wit",
2323
interfaces: r#"
2424
include wasi:http/[email protected];
25-
25+
2626
// NB: this is handling the historical behavior where Spin supported
2727
// more than "just" this snaphsot of the proxy world but additionally
2828
// other CLI-related interfaces.
@@ -156,6 +156,8 @@ where
156156
wasi::io::poll::add_to_linker(linker, |t| t)?;
157157
wasi::io::streams::add_to_linker(linker, |t| t)?;
158158
wasi::random::random::add_to_linker(linker, |t| t)?;
159+
wasi::random::insecure::add_to_linker(linker, |t| t)?;
160+
wasi::random::insecure_seed::add_to_linker(linker, |t| t)?;
159161
wasi::cli::exit::add_to_linker(linker, |t| t)?;
160162
wasi::cli::environment::add_to_linker(linker, |t| t)?;
161163
wasi::cli::stdin::add_to_linker(linker, |t| t)?;
@@ -898,6 +900,28 @@ where
898900
}
899901
}
900902

903+
impl<T> wasi::random::insecure::Host for T
904+
where
905+
T: WasiView,
906+
{
907+
fn get_insecure_random_bytes(&mut self, len: u64) -> wasmtime::Result<Vec<u8>> {
908+
<T as latest::random::insecure::Host>::get_insecure_random_bytes(self, len)
909+
}
910+
911+
fn get_insecure_random_u64(&mut self) -> wasmtime::Result<u64> {
912+
<T as latest::random::insecure::Host>::get_insecure_random_u64(self)
913+
}
914+
}
915+
916+
impl<T> wasi::random::insecure_seed::Host for T
917+
where
918+
T: WasiView,
919+
{
920+
fn insecure_seed(&mut self) -> wasmtime::Result<(u64, u64)> {
921+
<T as latest::random::insecure_seed::Host>::insecure_seed(self)
922+
}
923+
}
924+
901925
impl<T> wasi::cli::exit::Host for T
902926
where
903927
T: WasiView,

crates/core/src/wasi_2023_11_10.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod bindings {
2121
path: "../../wit",
2222
interfaces: r#"
2323
include wasi:http/[email protected];
24-
24+
2525
// NB: this is handling the historical behavior where Spin supported
2626
// more than "just" this snapshot of the proxy world but additionally
2727
// other CLI-related interfaces.
@@ -154,6 +154,8 @@ where
154154
wasi::io::poll::add_to_linker(linker, |t| t)?;
155155
wasi::io::streams::add_to_linker(linker, |t| t)?;
156156
wasi::random::random::add_to_linker(linker, |t| t)?;
157+
wasi::random::insecure::add_to_linker(linker, |t| t)?;
158+
wasi::random::insecure_seed::add_to_linker(linker, |t| t)?;
157159
wasi::cli::exit::add_to_linker(linker, |t| t)?;
158160
wasi::cli::environment::add_to_linker(linker, |t| t)?;
159161
wasi::cli::stdin::add_to_linker(linker, |t| t)?;
@@ -843,6 +845,28 @@ where
843845
}
844846
}
845847

848+
impl<T> wasi::random::insecure::Host for T
849+
where
850+
T: WasiView,
851+
{
852+
fn get_insecure_random_bytes(&mut self, len: u64) -> wasmtime::Result<Vec<u8>> {
853+
<T as latest::random::insecure::Host>::get_insecure_random_bytes(self, len)
854+
}
855+
856+
fn get_insecure_random_u64(&mut self) -> wasmtime::Result<u64> {
857+
<T as latest::random::insecure::Host>::get_insecure_random_u64(self)
858+
}
859+
}
860+
861+
impl<T> wasi::random::insecure_seed::Host for T
862+
where
863+
T: WasiView,
864+
{
865+
fn insecure_seed(&mut self) -> wasmtime::Result<(u64, u64)> {
866+
<T as latest::random::insecure_seed::Host>::insecure_seed(self)
867+
}
868+
}
869+
846870
impl<T> wasi::cli::exit::Host for T
847871
where
848872
T: WasiView,

crates/doctor/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "spin-doctor"
3-
version = "0.1.0"
4-
edition = "2021"
3+
version = { workspace = true }
4+
authors = { workspace = true }
5+
edition = { workspace = true }
56

67
[dependencies]
78
anyhow = "1"

0 commit comments

Comments
 (0)