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 13
13
"executable" : " osinfo"
14
14
},
15
15
"export" : {
16
- "executable" : " osinfo"
16
+ "executable" : " osinfo" ,
17
+ "args" : [
18
+ " export"
19
+ ]
17
20
},
18
21
"schema" : {
19
22
"embedded" : {
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ impl Display for Family {
62
62
const ID : & str = "https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json" ;
63
63
64
64
impl OsInfo {
65
- pub fn new ( ) -> Self {
65
+ pub fn new ( include_name : bool ) -> Self {
66
66
let os_info = os_info:: get ( ) ;
67
67
let edition = os_info. edition ( ) . map ( ToString :: to_string) ;
68
68
let codename = os_info. codename ( ) . map ( ToString :: to_string) ;
@@ -78,12 +78,16 @@ impl OsInfo {
78
78
_ => Bitness :: Unknown ,
79
79
} ;
80
80
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
+ } ;
87
91
Self {
88
92
id : ID . to_string ( ) ,
89
93
family,
Original file line number Diff line number Diff line change 4
4
mod config;
5
5
6
6
fn 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 ( ) ;
8
14
println ! ( "{json}" ) ;
9
15
}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ Describe 'osinfo resource tests' {
22
22
else {
23
23
$out.actualState.bitness | Should - BeExactly ' 32'
24
24
}
25
+
26
+ $out._name | Should - BeNullOrEmpty
25
27
}
26
28
27
29
It ' should perform synthetic test' {
You can’t perform that action at this time.
0 commit comments