-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add version flag to all the shims #268
Merged
+90
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::process::Command; | ||
use std::str::from_utf8; | ||
|
||
fn main() { | ||
let output = match Command::new("git").arg("rev-parse").arg("HEAD").output() { | ||
Ok(output) => output, | ||
Err(_) => { | ||
return; | ||
} | ||
}; | ||
let mut hash = from_utf8(&output.stdout).unwrap().trim().to_string(); | ||
|
||
let output_dirty = match Command::new("git").arg("diff").arg("--exit-code").output() { | ||
Ok(output) => output, | ||
Err(_) => { | ||
return; | ||
} | ||
}; | ||
|
||
if !output_dirty.status.success() { | ||
hash.push_str(".m"); | ||
} | ||
println!("cargo:rustc-env=CARGO_GIT_HASH={}", hash); | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/containerd-shim-wasmedge/src/bin/containerd-shim-wasmedge-v1/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
use containerd_shim as shim; | ||
use containerd_shim_wasm::sandbox::ShimCli; | ||
use containerd_shim_wasmedge::instance::Wasi as WasiInstance; | ||
use containerd_shim_wasmedge::parse_version; | ||
|
||
fn main() { | ||
parse_version(); | ||
shim::run::<ShimCli<WasiInstance>>("io.containerd.wasmedge.v1", None); | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/containerd-shim-wasmedge/src/bin/containerd-shim-wasmedged-v1/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
use containerd_shim as shim; | ||
use containerd_shim_wasm::sandbox::manager::Shim; | ||
use containerd_shim_wasmedge::parse_version; | ||
|
||
fn main() { | ||
parse_version(); | ||
shim::run::<Shim>("containerd-shim-wasmedged-v1", None) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::process::Command; | ||
use std::str::from_utf8; | ||
|
||
fn main() { | ||
let output = match Command::new("git").arg("rev-parse").arg("HEAD").output() { | ||
Ok(output) => output, | ||
Err(_) => { | ||
return; | ||
} | ||
}; | ||
let mut hash = from_utf8(&output.stdout).unwrap().trim().to_string(); | ||
|
||
let output_dirty = match Command::new("git").arg("diff").arg("--exit-code").output() { | ||
Ok(output) => output, | ||
Err(_) => { | ||
return; | ||
} | ||
}; | ||
|
||
if !output_dirty.status.success() { | ||
hash.push_str(".m"); | ||
} | ||
println!("cargo:rustc-env=CARGO_GIT_HASH={}", hash); | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/containerd-shim-wasmtime/src/bin/containerd-shim-wasmtime-v1/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
use containerd_shim as shim; | ||
use containerd_shim_wasm::sandbox::ShimCli; | ||
use containerd_shim_wasmtime::instance::Wasi as WasiInstance; | ||
use containerd_shim_wasmtime::parse_version; | ||
|
||
fn main() { | ||
parse_version(); | ||
shim::run::<ShimCli<WasiInstance>>("io.containerd.wasmtime.v1", None); | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/containerd-shim-wasmtime/src/bin/containerd-shim-wasmtimed-v1/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
use containerd_shim as shim; | ||
use containerd_shim_wasm::sandbox::manager::Shim; | ||
use containerd_shim_wasmtime::parse_version; | ||
|
||
fn main() { | ||
parse_version(); | ||
shim::run::<Shim>("containerd-shim-wasmtimed-v1", None) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: create a
containerd_shim_wasm::run
function that takes the version / revision, and handles this logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a good way to handle this in containerd-shim-wasm crate, as each shim implementation still needs to read os args, parse flags and get the version / revision... Could not save much logic here. With that said, I will leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant something like:
and
then you can remove
parse_version
from all thelib.rs