Skip to content

Commit

Permalink
backport of commit 64740ed
Browse files Browse the repository at this point in the history
  • Loading branch information
devashish-patel authored and lbajolet-hashicorp committed Jul 22, 2024
1 parent 05bd93a commit e104127
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/hcp/registry/metadata/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func GetOSMetadata() map[string]interface{} {
}

func GetInfo(exec CommandExecutor, flags string) OSInfo {
out, err := _uname(exec, flags)
out, err := uname(exec, flags)
tries := 0
for strings.Contains(out, "broken pipe") && tries < 3 {
out, err = _uname(exec, flags)
out, err = uname(exec, flags)
time.Sleep(500 * time.Millisecond)
tries++
}
Expand All @@ -77,20 +77,20 @@ func GetInfo(exec CommandExecutor, flags string) OSInfo {
if err != nil {
log.Printf("[ERROR] failed to get the OS info: %s", err)
}
core := _retrieveCore(out)
core := retrieveCore(out)
return OSInfo{
Name: runtime.GOOS,
Arch: runtime.GOARCH,
Version: core,
}
}

func _uname(exec CommandExecutor, flags string) (string, error) {
func uname(exec CommandExecutor, flags string) (string, error) {
output, err := exec.Exec("uname", flags)
return string(output), err
}

func _retrieveCore(osStr string) string {
func retrieveCore(osStr string) string {
osStr = strings.Replace(osStr, "\n", "", -1)
osStr = strings.Replace(osStr, "\r\n", "", -1)
osInfo := strings.Split(osStr, " ")
Expand Down

0 comments on commit e104127

Please sign in to comment.