Skip to content

Commit 4e55cee

Browse files
authored
Fix false warning in config schema validator (#6240)
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 68b449b commit 4e55cee

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ConfigValidator {
7878
void validate(ConfigObject config) {
7979
final flatConfig = config.flatten()
8080
for( String key : flatConfig.keySet() ) {
81-
final names = key.tokenize('.')
81+
final names = key.tokenize('.').findAll { name -> !isSelector(name) }
8282
if( names.first() == 'profiles' ) {
8383
if( !names.isEmpty() ) names.remove(0)
8484
if( !names.isEmpty() ) names.remove(0)
@@ -100,6 +100,15 @@ class ConfigValidator {
100100
}
101101
}
102102

103+
/**
104+
* Determine whether a scope name is a process selector.
105+
*
106+
* @param name
107+
*/
108+
private boolean isSelector(String name) {
109+
return name.startsWith('withLabel:') || name.startsWith('withName:')
110+
}
111+
103112
/**
104113
* Determine whether a config option is defined in the schema.
105114
*

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,23 @@ class ConfigValidatorTest extends Specification {
6464
!capture.toString().contains('the following environment variable in the config will be ignored: \'NXF_DEBUG\'')
6565
}
6666

67+
def 'should ignore process selectors' () {
68+
given:
69+
def config = new ConfigMap([
70+
process: [
71+
'withLabel:foobar': [
72+
cpus: 2
73+
],
74+
'withName:foobar': [
75+
cpus: 2
76+
]
77+
]
78+
])
79+
80+
when:
81+
new ConfigValidator().validate(config)
82+
then:
83+
!capture.toString().contains('Unrecognized config option')
84+
}
85+
6786
}

0 commit comments

Comments
 (0)