Skip to content

Commit 41759d3

Browse files
authored
Allow -with-docker to be used without a default container image (#7054)
1 parent c40d742 commit 41759d3

2 files changed

Lines changed: 6 additions & 48 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -798,32 +798,6 @@ class ConfigBuilder {
798798
else if( containerConfig.image ) {
799799
config.process.container = containerConfig.image
800800
}
801-
802-
if( !hasContainerDirective(config.process) )
803-
throw new AbortOperationException("You have requested to run with ${engine.capitalize()} but no image was specified")
804-
805-
}
806-
807-
/**
808-
* Verify that configuration for process contains at last one `container` directive
809-
*
810-
* @param process
811-
* @return {@code true} when a `container` is defined or {@code false} otherwise
812-
*/
813-
protected boolean hasContainerDirective(process) {
814-
815-
if( process instanceof Map ) {
816-
if( process.container )
817-
return true
818-
819-
def result = process
820-
.findAll { String name, value -> (name.startsWith('withName:') || name.startsWith('$')) && value instanceof Map }
821-
.find { String name, Map value -> value.container as boolean } // the first non-empty `container` string
822-
823-
return result as boolean
824-
}
825-
826-
return false
827801
}
828802

829803
ConfigObject buildConfigObject() {

modules/nextflow/src/test/groovy/nextflow/config/ConfigBuilderTest.groovy

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,10 @@ class ConfigBuilderTest extends Specification {
727727
when:
728728
opt = new CliOptions()
729729
run = new CmdRun(withDocker: '-')
730-
new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
730+
config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
731731
then:
732-
def e = thrown(AbortOperationException)
733-
e.message == 'You have requested to run with Docker but no image was specified'
732+
config.docker.enabled
733+
!config.process.container
734734

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

747747
}
748748

@@ -791,22 +791,6 @@ class ConfigBuilderTest extends Specification {
791791

792792
}
793793

794-
def 'has container directive' () {
795-
when:
796-
def config = new ConfigBuilder()
797-
798-
then:
799-
!config.hasContainerDirective(null)
800-
!config.hasContainerDirective([:])
801-
!config.hasContainerDirective([foo: true])
802-
config.hasContainerDirective([container: 'hello/world'])
803-
!config.hasContainerDirective([foo: 1, bar: 2])
804-
!config.hasContainerDirective([foo: 1, bar: 2, baz: [container: 'user/repo']])
805-
config.hasContainerDirective([foo: 1, bar: 2, $baz: [container: 'user/repo']])
806-
config.hasContainerDirective([foo: 1, bar: 2, 'withName:baz': [container: 'user/repo']])
807-
808-
}
809-
810794
def 'should set session trace options' () {
811795

812796
given:

0 commit comments

Comments
 (0)