Skip to content

Commit

Permalink
Merge pull request #145 from wllenyj/sandbox
Browse files Browse the repository at this point in the history
shim: add Sandbox API support
  • Loading branch information
mxpv authored May 16, 2023
2 parents 7ec216f + 79d5d5a commit 35a97f1
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/shim-protos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tokio = { workspace = true, features = ["full"] }
[features]
default = []
async = ["ttrpc/async", "async-trait"]
sandbox = []

[[example]]
name = "shim-proto-server"
Expand Down
18 changes: 18 additions & 0 deletions crates/shim-protos/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ fn main() {
"vendor/github.com/containerd/containerd/protobuf/plugin/fieldpath.proto",
"vendor/github.com/containerd/containerd/api/types/mount.proto",
"vendor/github.com/containerd/containerd/api/types/task/task.proto",
#[cfg(feature = "sandbox")]
"vendor/github.com/containerd/containerd/api/types/platform.proto",
],
false,
);
Expand Down Expand Up @@ -77,6 +79,22 @@ fn main() {
true,
);
}

#[cfg(feature = "sandbox")]
{
genmodule(
"sandbox",
&["vendor/github.com/containerd/containerd/runtime/sandbox/v1/sandbox.proto"],
false,
);

#[cfg(feature = "async")]
genmodule(
"sandbox_async",
&["vendor/github.com/containerd/containerd/runtime/sandbox/v1/sandbox.proto"],
true,
);
}
}

fn genmodule(name: &str, inputs: &[&str], async_all: bool) {
Expand Down
15 changes: 15 additions & 0 deletions crates/shim-protos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub use ttrpc;

pub mod cgroups;
pub mod events;
#[cfg(feature = "sandbox")]
mod sandbox;
pub mod shim;
pub mod types;

Expand Down Expand Up @@ -100,3 +102,16 @@ pub mod shim_async {
pub mod api {
pub use crate::shim::{empty::*, events::*, mount::*, shim::*, task::*};
}

#[cfg(feature = "sandbox")]
pub use sandbox::sandbox as sandbox_api;

#[cfg(feature = "sandbox")]
pub mod sandbox_sync {
pub use crate::sandbox::sandbox_ttrpc::*;
}

#[cfg(all(feature = "sandbox", feature = "async"))]
pub mod sandbox_async {
pub use crate::sandbox::sandbox_async::*;
}
36 changes: 36 additions & 0 deletions crates/shim-protos/src/sandbox.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

pub mod sandbox {
include!(concat!(env!("OUT_DIR"), "/sandbox/sandbox.rs"));
}

pub mod sandbox_ttrpc {
include!(concat!(env!("OUT_DIR"), "/sandbox/sandbox_ttrpc.rs"));
}

#[cfg(feature = "async")]
pub mod sandbox_async {
include!(concat!(env!("OUT_DIR"), "/sandbox_async/sandbox_ttrpc.rs"));
}

pub(crate) mod mount {
pub use crate::types::mount::*;
}

pub(crate) mod platform {
pub use crate::types::platform::*;
}
5 changes: 5 additions & 0 deletions crates/shim-protos/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ pub mod task {
pub mod fieldpath {
include!(concat!(env!("OUT_DIR"), "/types/fieldpath.rs"));
}

#[cfg(feature = "sandbox")]
pub mod platform {
include!(concat!(env!("OUT_DIR"), "/types/platform.rs"));
}

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

0 comments on commit 35a97f1

Please sign in to comment.