Verified Commit 4d832493 authored by Steve Azzopardi's avatar Steve Azzopardi Committed by Steve Azzopardi - Out Of Office back Tuesday December 14th
Browse files

Add support for PowerShell for helper image

A default command is passed to the helper image container when it
starts, since it's specific to Linux it take in consideration which OS
is being used.

The helperimage package now also controls the command that are used by
default.
parent 40a66895
package common
type ContainerCommand []string
var (
ContainerCommandBuild ContainerCommand = []string{"gitlab-runner-build"}
)
......@@ -58,7 +58,7 @@ func (s *commandExecutor) requestNewPredefinedContainer() (*types.ContainerJSON,
Name: prebuildImage.ID,
}
containerJSON, err := s.createContainer("predefined", buildImage, common.ContainerCommandBuild, []string{prebuildImage.ID})
containerJSON, err := s.createContainer("predefined", buildImage, s.helperImageInfo.Cmd, []string{prebuildImage.ID})
if err != nil {
return nil, err
}
......
......@@ -152,7 +152,7 @@ func (s *executor) Run(cmd common.ExecutorCommand) error {
containerCommand := s.BuildShell.DockerCommand
if cmd.Predefined {
containerName = "helper"
containerCommand = common.ContainerCommandBuild
containerCommand = s.helperImageInfo.Cmd
}
ctx, cancel := context.WithCancel(context.Background())
......
......@@ -21,6 +21,7 @@ type Info struct {
Name string
Tag string
IsSupportingLocalImport bool
Cmd []string
}
func (i Info) String() string {
......
......@@ -5,6 +5,8 @@ import (
"runtime"
)
var bashCmd = []string{"gitlab-runner-build"}
type linuxInfo struct{}
func (l *linuxInfo) Create(revision string, cfg Config) (Info, error) {
......@@ -15,6 +17,7 @@ func (l *linuxInfo) Create(revision string, cfg Config) (Info, error) {
Name: name,
Tag: fmt.Sprintf("%s-%s", arch, revision),
IsSupportingLocalImport: true,
Cmd: bashCmd,
}, nil
}
......
......@@ -22,6 +22,7 @@ func Test_linuxInfo_create(t *testing.T) {
Name: name,
Tag: fmt.Sprintf("%s-2923a43", getExpectedArch()),
IsSupportingLocalImport: true,
Cmd: bashCmd,
},
},
"Docker runs on armv6l": {
......@@ -32,6 +33,7 @@ func Test_linuxInfo_create(t *testing.T) {
Name: name,
Tag: "arm-2923a43",
IsSupportingLocalImport: true,
Cmd: bashCmd,
},
},
"Docker runs on amd64": {
......@@ -42,6 +44,7 @@ func Test_linuxInfo_create(t *testing.T) {
Name: name,
Tag: "x86_64-2923a43",
IsSupportingLocalImport: true,
Cmd: bashCmd,
},
},
"Configured architecture is unknown": {
......@@ -52,6 +55,7 @@ func Test_linuxInfo_create(t *testing.T) {
Name: name,
Tag: "some-random-arch-2923a43",
IsSupportingLocalImport: true,
Cmd: bashCmd,
},
},
}
......
......@@ -23,6 +23,8 @@ var supportedOSVersions = map[string]string{
var ErrUnsupportedOSVersion = errors.New("could not determine windows version")
var powerShellCmd = []string{"PowerShell", "-NoProfile", "-NoLogo", "-InputFormat", "text", "-OutputFormat", "text", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "-"}
type windowsInfo struct{}
func (w *windowsInfo) Create(revision string, cfg Config) (Info, error) {
......@@ -36,6 +38,7 @@ func (w *windowsInfo) Create(revision string, cfg Config) (Info, error) {
Name: name,
Tag: fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, osVersion),
IsSupportingLocalImport: false,
Cmd: powerShellCmd,
}, nil
}
......
......@@ -21,6 +21,7 @@ func Test_windowsInfo_create(t *testing.T) {
Name: name,
Tag: fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, baseImage1809),
IsSupportingLocalImport: false,
Cmd: powerShellCmd,
},
expectedErr: nil,
},
......@@ -31,6 +32,7 @@ func Test_windowsInfo_create(t *testing.T) {
Name: name,
Tag: fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, baseImage1809),
IsSupportingLocalImport: false,
Cmd: powerShellCmd,
},
expectedErr: nil,
},
......@@ -41,6 +43,7 @@ func Test_windowsInfo_create(t *testing.T) {
Name: name,
Tag: fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, baseImage1803),
IsSupportingLocalImport: false,
Cmd: powerShellCmd,
},
expectedErr: nil,
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment