Skip to content
Snippets Groups Projects
Unverified Commit e9e8db31 authored by Steve Azzopardi's avatar Steve Azzopardi
Browse files

Add newContainerConfig method

There is some duplication between `createAttachableContainer` &
`createExecutableContainer` configuration. Create a new method
`newCotnainerConfig` that removes that duplication.
parent 5cde3026
No related branches found
No related tags found
No related merge requests found
...@@ -836,37 +836,37 @@ func (e *executor) getValidContainers(containers []string) []string { ...@@ -836,37 +836,37 @@ func (e *executor) getValidContainers(containers []string) []string {
} }
func (e *executor) createAttachableContainer(containerType string, imageDefinition common.Image, cmd []string, allowedInternalImages []string) (*types.ContainerJSON, error) { func (e *executor) createAttachableContainer(containerType string, imageDefinition common.Image, cmd []string, allowedInternalImages []string) (*types.ContainerJSON, error) {
config := &container.Config{ config := e.newContainerConfig(cmd, containerType)
Cmd: cmd, config.Tty = false
Labels: e.getLabels(containerType), config.AttachStdin = true
Tty: false, config.AttachStdout = true
AttachStdin: true, config.AttachStderr = true
AttachStdout: true, config.OpenStdin = true
AttachStderr: true, config.StdinOnce = true
OpenStdin: true,
StdinOnce: true,
Env: append(e.Build.GetAllVariables().StringList(), e.BuildShell.Environment...),
}
return e.createContainer(containerType, imageDefinition, allowedInternalImages, config) return e.createContainer(containerType, imageDefinition, allowedInternalImages, config)
} }
func (e *executor) createExecutableContainer(containerType string, imageDefinition common.Image, cmd []string, allowedInternalImages []string) (*types.ContainerJSON, error) { func (e *executor) createExecutableContainer(containerType string, imageDefinition common.Image, cmd []string, allowedInternalImages []string) (*types.ContainerJSON, error) {
config := &container.Config{ config := e.newContainerConfig(cmd, containerType)
Cmd: cmd, config.Tty = true
Labels: e.getLabels(containerType), config.AttachStdin = false
Tty: true, config.AttachStdout = false
AttachStdin: false, config.AttachStderr = false
AttachStdout: false, config.OpenStdin = false
AttachStderr: false, config.StdinOnce = false
OpenStdin: false,
StdinOnce: false,
Env: append(e.Build.GetAllVariables().StringList(), e.BuildShell.Environment...),
}
return e.createContainer(containerType, imageDefinition, allowedInternalImages, config) return e.createContainer(containerType, imageDefinition, allowedInternalImages, config)
} }
func (e *executor) newContainerConfig(cmd []string, containerType string) *container.Config {
return &container.Config{
Cmd: cmd,
Labels: e.getLabels(containerType),
Env: append(e.Build.GetAllVariables().StringList(), e.BuildShell.Environment...),
}
}
func (e *executor) createContainer(containerType string, imageDefinition common.Image, allowedInternalImages []string, config *container.Config) (*types.ContainerJSON, error) { func (e *executor) createContainer(containerType string, imageDefinition common.Image, allowedInternalImages []string, config *container.Config) (*types.ContainerJSON, error) {
image, err := e.expandAndGetDockerImage(imageDefinition.Name, allowedInternalImages) image, err := e.expandAndGetDockerImage(imageDefinition.Name, allowedInternalImages)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment