utils_windows.go 867 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package libcontainerd
  2. import (
  3. "strconv"
  4. "strings"
  5. )
  6. // setupEnvironmentVariables convert a string array of environment variables
  7. // into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc.
  8. func setupEnvironmentVariables(a []string) map[string]string {
  9. r := make(map[string]string)
  10. for _, s := range a {
  11. arr := strings.Split(s, "=")
  12. if len(arr) == 2 {
  13. r[arr[0]] = arr[1]
  14. }
  15. }
  16. return r
  17. }
  18. // Apply for a servicing option is a no-op.
  19. func (s *ServicingOption) Apply(interface{}) error {
  20. return nil
  21. }
  22. // buildFromVersion takes an image version string and returns the Windows build
  23. // number. It returns 0 if the build number is not present.
  24. func buildFromVersion(osver string) int {
  25. v := strings.Split(osver, ".")
  26. if len(v) < 3 {
  27. return 0
  28. }
  29. if build, err := strconv.Atoi(v[2]); err == nil {
  30. return build
  31. }
  32. return 0
  33. }