microsandbox-rb 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +138 -1
- data/Cargo.lock +25 -25
- data/DESIGN.md +16 -6
- data/README.md +31 -16
- data/ext/microsandbox/Cargo.toml +4 -4
- data/ext/microsandbox/src/agent.rs +18 -7
- data/ext/microsandbox/src/conv.rs +37 -1
- data/ext/microsandbox/src/fs_stream.rs +92 -0
- data/ext/microsandbox/src/image.rs +6 -0
- data/ext/microsandbox/src/lib.rs +40 -0
- data/ext/microsandbox/src/sandbox.rs +673 -64
- data/ext/microsandbox/src/snapshot.rs +72 -6
- data/ext/microsandbox/src/volume.rs +113 -1
- data/lib/microsandbox/agent.rb +3 -1
- data/lib/microsandbox/exec_handle.rb +7 -3
- data/lib/microsandbox/exec_output.rb +7 -7
- data/lib/microsandbox/fs.rb +84 -2
- data/lib/microsandbox/image.rb +2 -1
- data/lib/microsandbox/log_entry.rb +4 -2
- data/lib/microsandbox/metrics.rb +9 -0
- data/lib/microsandbox/sandbox.rb +461 -70
- data/lib/microsandbox/snapshot.rb +63 -6
- data/lib/microsandbox/ssh.rb +14 -9
- data/lib/microsandbox/version.rb +2 -2
- data/lib/microsandbox/volume.rb +100 -1
- data/lib/microsandbox.rb +35 -1
- data/sig/microsandbox.rbs +70 -6
- metadata +2 -1
data/ext/microsandbox/src/lib.rs
CHANGED
|
@@ -13,6 +13,7 @@ mod backend;
|
|
|
13
13
|
mod conv;
|
|
14
14
|
mod error;
|
|
15
15
|
mod exec;
|
|
16
|
+
mod fs_stream;
|
|
16
17
|
mod image;
|
|
17
18
|
mod runtime;
|
|
18
19
|
mod sandbox;
|
|
@@ -47,6 +48,43 @@ fn install() -> Result<(), Error> {
|
|
|
47
48
|
runtime::block_on(microsandbox::setup::install()).map_err(error::to_ruby)
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
/// Customizable install via the core `Setup` builder. `opts`: base_dir (install
|
|
52
|
+
/// root), version (pin the runtime version), force (re-download even if present
|
|
53
|
+
/// — repairs a corrupt install), skip_verify. Mirrors the Node `Setup` builder.
|
|
54
|
+
fn setup(opts: RHash) -> Result<(), Error> {
|
|
55
|
+
use microsandbox::setup::Setup;
|
|
56
|
+
let base_dir = conv::opt_string(opts, "base_dir")?;
|
|
57
|
+
let version = conv::opt_string(opts, "version")?;
|
|
58
|
+
let skip_verify = conv::opt_bool(opts, "skip_verify")?;
|
|
59
|
+
let force = conv::opt_bool(opts, "force")?;
|
|
60
|
+
// `Setup` uses a typed-builder whose `strip_option` setters change the type
|
|
61
|
+
// on each call, so optional fields can't be set conditionally on one binding
|
|
62
|
+
// — branch on presence instead (matching the Node binding).
|
|
63
|
+
let setup = match (base_dir, version) {
|
|
64
|
+
(Some(d), Some(v)) => Setup::builder()
|
|
65
|
+
.base_dir(d)
|
|
66
|
+
.version(v)
|
|
67
|
+
.skip_verify(skip_verify)
|
|
68
|
+
.force(force)
|
|
69
|
+
.build(),
|
|
70
|
+
(Some(d), None) => Setup::builder()
|
|
71
|
+
.base_dir(d)
|
|
72
|
+
.skip_verify(skip_verify)
|
|
73
|
+
.force(force)
|
|
74
|
+
.build(),
|
|
75
|
+
(None, Some(v)) => Setup::builder()
|
|
76
|
+
.version(v)
|
|
77
|
+
.skip_verify(skip_verify)
|
|
78
|
+
.force(force)
|
|
79
|
+
.build(),
|
|
80
|
+
(None, None) => Setup::builder()
|
|
81
|
+
.skip_verify(skip_verify)
|
|
82
|
+
.force(force)
|
|
83
|
+
.build(),
|
|
84
|
+
};
|
|
85
|
+
runtime::block_on(setup.install()).map_err(error::to_ruby)
|
|
86
|
+
}
|
|
87
|
+
|
|
50
88
|
/// Whether the `msb` runtime + `libkrunfw` are installed and resolvable.
|
|
51
89
|
fn is_installed() -> bool {
|
|
52
90
|
microsandbox::setup::is_installed()
|
|
@@ -88,6 +126,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
88
126
|
|
|
89
127
|
native.define_singleton_method("version", function!(version, 0))?;
|
|
90
128
|
native.define_singleton_method("install", function!(install, 0))?;
|
|
129
|
+
native.define_singleton_method("setup", function!(setup, 1))?;
|
|
91
130
|
native.define_singleton_method("installed?", function!(is_installed, 0))?;
|
|
92
131
|
native.define_singleton_method("set_runtime_msb_path", function!(set_runtime_msb_path, 1))?;
|
|
93
132
|
native.define_singleton_method(
|
|
@@ -101,6 +140,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
101
140
|
sandbox::define(ruby, &native)?;
|
|
102
141
|
exec::define(ruby, &native)?;
|
|
103
142
|
stream::define(ruby, &native)?;
|
|
143
|
+
fs_stream::define(ruby, &native)?;
|
|
104
144
|
snapshot::define(ruby, &native)?;
|
|
105
145
|
image::define(ruby, &native)?;
|
|
106
146
|
volume::define(ruby, &native)?;
|