utils_windows.go 978 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package libcontainerd
  2. import (
  3. "strconv"
  4. "strings"
  5. )
  6. // setupEnvironmentVariables converts 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.SplitN(s, "=", 2)
  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. // Apply for the flush option is a no-op.
  23. func (s *FlushOption) Apply(interface{}) error {
  24. return nil
  25. }
  26. // buildFromVersion takes an image version string and returns the Windows build
  27. // number. It returns 0 if the build number is not present.
  28. func buildFromVersion(osver string) int {
  29. v := strings.Split(osver, ".")
  30. if len(v) < 3 {
  31. return 0
  32. }
  33. if build, err := strconv.Atoi(v[2]); err == nil {
  34. return build
  35. }
  36. return 0
  37. }