Skip to content
Open
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 @@ -48,7 +48,7 @@ class ConfigParserV2 implements ConfigParser {

private List<String> appliedProfiles

private Set<String> declaredProfiles
private Set<String> declaredProfiles = new HashSet<>()

private Map<String,Object> declaredParams

Expand Down Expand Up @@ -133,7 +133,7 @@ class ConfigParserV2 implements ConfigParser {
script.run()

final target = script.getTarget()
declaredProfiles = script.getDeclaredProfiles()
declaredProfiles.addAll(script.getDeclaredProfiles())
declaredParams = script.getDeclaredParams()
return Bolts.toConfigObject(target)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,36 @@ class ConfigParserV2Test extends Specification {
slurper.getDeclaredProfiles() == ['alpha','beta'] as Set
}

def 'should accumulate declared profiles across multiple config files' () {
// a single parser instance is reused to parse all config files (see ConfigBuilder),
// so the set of declared profiles must accumulate rather than be overwritten by the
// last file parsed -- otherwise profiles defined in an earlier file are reported as
// "Unknown configuration profile" when a later file declares none
given:
def withProfiles = '''
profiles {
alpha {
a = 1
}
beta {
b = 2
}
}
'''
def withoutProfiles = '''
tower {
enabled = true
}
'''

when:
def slurper = new ConfigParserV2().setProfiles(['alpha'])
slurper.parse(withProfiles)
slurper.parse(withoutProfiles)
then:
slurper.getDeclaredProfiles() == ['alpha','beta'] as Set
}

def 'should return the map of declared params' () {

given:
Expand Down
Loading