@@ -39,15 +39,17 @@ pub struct Flags {
3939 /// Shim action (start / delete).
4040 /// See <https://github.com/containerd/containerd/blob/master/runtime/v2/shim/shim.go#L191>
4141 pub action : String ,
42+ /// Version of the shim.
43+ pub version : bool ,
4244}
4345
4446/// Parses command line arguments passed to the shim.
45- /// This func replicates https://github.com/containerd/containerd/blob/master/runtime/v2/shim/shim.go#L110
4647pub fn parse < S : AsRef < OsStr > > ( args : & [ S ] ) -> Result < Flags > {
4748 let mut flags = Flags :: default ( ) ;
4849
4950 let args: Vec < String > = go_flag:: parse_args ( args, |f| {
5051 f. add_flag ( "debug" , & mut flags. debug ) ;
52+ f. add_flag ( "v" , & mut flags. version ) ;
5153 f. add_flag ( "namespace" , & mut flags. namespace ) ;
5254 f. add_flag ( "id" , & mut flags. id ) ;
5355 f. add_flag ( "socket" , & mut flags. socket ) ;
@@ -61,12 +63,6 @@ pub fn parse<S: AsRef<OsStr>>(args: &[S]) -> Result<Flags> {
6163 flags. action = action. into ( ) ;
6264 }
6365
64- if flags. namespace . is_empty ( ) {
65- return Err ( Error :: InvalidArgument ( String :: from (
66- "Shim namespace cannot be empty" ,
67- ) ) ) ;
68- }
69-
7066 Ok ( flags)
7167}
7268
@@ -125,11 +121,4 @@ mod tests {
125121 assert_eq ! ( flags. action, "start" ) ;
126122 assert_eq ! ( flags. id, "" ) ;
127123 }
128-
129- #[ test]
130- fn no_namespace ( ) {
131- let empty: [ String ; 0 ] = [ ] ;
132- let result = parse ( & empty) . err ( ) ;
133- assert ! ( result. is_some( ) )
134- }
135124}
0 commit comments