File tree Expand file tree Collapse file tree 4 files changed +24
-9
lines changed Expand file tree Collapse file tree 4 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 1313 "executable" : " osinfo"
1414 },
1515 "export" : {
16- "executable" : " osinfo"
16+ "executable" : " osinfo" ,
17+ "args" : [
18+ " export"
19+ ]
1720 },
1821 "schema" : {
1922 "embedded" : {
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ impl Display for Family {
6262const ID : & str = "https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json" ;
6363
6464impl OsInfo {
65- pub fn new ( ) -> Self {
65+ pub fn new ( include_name : bool ) -> Self {
6666 let os_info = os_info:: get ( ) ;
6767 let edition = os_info. edition ( ) . map ( ToString :: to_string) ;
6868 let codename = os_info. codename ( ) . map ( ToString :: to_string) ;
@@ -78,12 +78,16 @@ impl OsInfo {
7878 _ => Bitness :: Unknown ,
7979 } ;
8080 let version = os_info. version ( ) . to_string ( ) ;
81- let name = Some (
82- match & architecture {
83- Some ( arch) => format ! ( "{family} {version} {arch}" ) ,
84- None => format ! ( "{family:?} {version}" ) ,
85- }
86- ) ;
81+ let name = if include_name {
82+ Some (
83+ match & architecture {
84+ Some ( arch) => format ! ( "{family} {version} {arch}" ) ,
85+ None => format ! ( "{family:?} {version}" ) ,
86+ }
87+ )
88+ } else {
89+ None
90+ } ;
8791 Self {
8892 id : ID . to_string ( ) ,
8993 family,
Original file line number Diff line number Diff line change 44mod config;
55
66fn main ( ) {
7- let json = serde_json:: to_string ( & config:: OsInfo :: new ( ) ) . unwrap ( ) ;
7+ let args: Vec < String > = std:: env:: args ( ) . collect ( ) ;
8+ let include_name = if args. len ( ) > 1 && args[ 1 ] == "export" {
9+ true
10+ } else {
11+ false
12+ } ;
13+ let json = serde_json:: to_string ( & config:: OsInfo :: new ( include_name) ) . unwrap ( ) ;
814 println ! ( "{json}" ) ;
915}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ Describe 'osinfo resource tests' {
2222 else {
2323 $out.actualState.bitness | Should - BeExactly ' 32'
2424 }
25+
26+ $out._name | Should - BeNullOrEmpty
2527 }
2628
2729 It ' should perform synthetic test' {
You can’t perform that action at this time.
0 commit comments