go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/detector/parser_esxi_version.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package detector
     5  
     6  import (
     7  	"fmt"
     8  	"regexp"
     9  )
    10  
    11  var EsxiReleaseRegex = regexp.MustCompile(`^VMware ESXi\s(.*)\s*$`)
    12  
    13  func ParseEsxiRelease(content string) (string, error) {
    14  	m := EsxiReleaseRegex.FindStringSubmatch(content)
    15  	if len(m) < 1 {
    16  		return "", fmt.Errorf("could not parse esxi version: %s", content)
    17  	}
    18  	return m[1], nil
    19  }