Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -798,32 +798,6 @@ class ConfigBuilder {
else if( containerConfig.image ) {
config.process.container = containerConfig.image
}

if( !hasContainerDirective(config.process) )
throw new AbortOperationException("You have requested to run with ${engine.capitalize()} but no image was specified")

}

/**
* Verify that configuration for process contains at last one `container` directive
*
* @param process
* @return {@code true} when a `container` is defined or {@code false} otherwise
*/
protected boolean hasContainerDirective(process) {

if( process instanceof Map ) {
if( process.container )
return true

def result = process
.findAll { String name, value -> (name.startsWith('withName:') || name.startsWith('$')) && value instanceof Map }
.find { String name, Map value -> value.container as boolean } // the first non-empty `container` string

return result as boolean
}

return false
}

ConfigObject buildConfigObject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,10 @@ class ConfigBuilderTest extends Specification {
when:
opt = new CliOptions()
run = new CmdRun(withDocker: '-')
new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
then:
def e = thrown(AbortOperationException)
e.message == 'You have requested to run with Docker but no image was specified'
config.docker.enabled
!config.process.container

when:
file.text =
Expand All @@ -739,10 +739,10 @@ class ConfigBuilderTest extends Specification {
'''
opt = new CliOptions(config: [file.toFile().canonicalPath])
run = new CmdRun(withDocker: '-')
new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
then:
e = thrown(AbortOperationException)
e.message == 'You have requested to run with Docker but no image was specified'
config.docker.enabled
!config.process.container

}

Expand Down Expand Up @@ -791,22 +791,6 @@ class ConfigBuilderTest extends Specification {

}

def 'has container directive' () {
when:
def config = new ConfigBuilder()

then:
!config.hasContainerDirective(null)
!config.hasContainerDirective([:])
!config.hasContainerDirective([foo: true])
config.hasContainerDirective([container: 'hello/world'])
!config.hasContainerDirective([foo: 1, bar: 2])
!config.hasContainerDirective([foo: 1, bar: 2, baz: [container: 'user/repo']])
config.hasContainerDirective([foo: 1, bar: 2, $baz: [container: 'user/repo']])
config.hasContainerDirective([foo: 1, bar: 2, 'withName:baz': [container: 'user/repo']])

}

def 'should set session trace options' () {

given:
Expand Down
Loading