This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
33 additions
and
0 deletions.
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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os/exec" | ||
) | ||
|
||
// GetNodeInfo empty func to allow CI to complete | ||
func GetNodeInfo() (*NodeInfoObject, error) { | ||
return nil, nil | ||
} | ||
|
||
// GetWin32OS exports win32_operatingsystem powershell class | ||
func GetWin32OS() (Win32OS, error) { | ||
cmd := exec.Command("powershell", "gwmi", "Win32_OperatingSystem", "|", "ConvertTo-Json") | ||
|
||
// cmd.Stderr = os.Stderr | ||
o, err := cmd.Output() | ||
|
||
if err != nil { | ||
return Win32OS{}, fmt.Errorf("exec gwmi Win32_OperatingSystem: %s", err) | ||
} | ||
|
||
var j Win32OS | ||
|
||
if err := json.Unmarshal(o, &j); err != nil { | ||
return Win32OS{}, fmt.Errorf("failed unmarshalling Win32_OperatingSystem: %s", err) | ||
} | ||
|
||
return j, nil | ||
} | ||
|
||
// Win32OS structure | ||
type Win32OS struct { | ||
Caption string `json:"Caption"` //os version | ||
TotalVirtualMemorySize int `json:"TotalVirtualMemorySize"` | ||
TotalVisibleMemorySize int `json:"TotalVisibleMemorySize"` | ||
} |