github.com/nilium/gitlab-runner@v12.5.0+incompatible/helpers/docker/helperimage/windows_info.go (about) 1 package helperimage 2 3 import ( 4 "errors" 5 "fmt" 6 "strings" 7 ) 8 9 const ( 10 windows1809 = "1809" 11 windows1803 = "1803" 12 13 baseImage1809 = "servercore1809" 14 baseImage1803 = "servercore1803" 15 16 windowsSupportedArchitecture = "x86_64" 17 ) 18 19 var supportedOSVersions = map[string]string{ 20 windows1803: baseImage1803, 21 windows1809: baseImage1809, 22 } 23 24 var ErrUnsupportedOSVersion = errors.New("could not determine windows version") 25 26 var powerShellCmd = []string{"PowerShell", "-NoProfile", "-NoLogo", "-InputFormat", "text", "-OutputFormat", "text", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "-"} 27 28 type windowsInfo struct{} 29 30 func (w *windowsInfo) Create(revision string, cfg Config) (Info, error) { 31 osVersion, err := w.osVersion(cfg.OperatingSystem) 32 if err != nil { 33 return Info{}, err 34 } 35 36 return Info{ 37 Architecture: windowsSupportedArchitecture, 38 Name: name, 39 Tag: fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, osVersion), 40 IsSupportingLocalImport: false, 41 Cmd: powerShellCmd, 42 }, nil 43 44 } 45 46 func (w *windowsInfo) osVersion(operatingSystem string) (string, error) { 47 for osVersion, baseImage := range supportedOSVersions { 48 if strings.Contains(operatingSystem, fmt.Sprintf(" %s ", osVersion)) { 49 return baseImage, nil 50 } 51 } 52 53 return "", ErrUnsupportedOSVersion 54 }