mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
Merge pull request #88 from marcusholl/pr/useSetsInsteadOfLists
Replace usage of lists for denoting keys by sets.
This commit is contained in:
commit
5256494ffa
@ -6,7 +6,7 @@ import com.sap.piper.MapUtils
|
||||
|
||||
class ConfigurationMerger {
|
||||
@NonCPS
|
||||
def static merge(Map configs, List configKeys, Map defaults) {
|
||||
def static merge(Map configs, Set configKeys, Map defaults) {
|
||||
Map filteredConfig = configKeys?configs.subMap(configKeys):configs
|
||||
Map merged = [:]
|
||||
|
||||
@ -23,8 +23,8 @@ class ConfigurationMerger {
|
||||
|
||||
@NonCPS
|
||||
def static merge(
|
||||
Map parameters, List parameterKeys,
|
||||
Map configuration, List configurationKeys,
|
||||
Map parameters, Set parameterKeys,
|
||||
Map configuration, Set configurationKeys,
|
||||
Map defaults=[:]
|
||||
){
|
||||
Map merged
|
||||
@ -34,9 +34,9 @@ class ConfigurationMerger {
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
def static mergeWithPipelineData(Map parameters, List parameterKeys,
|
||||
def static mergeWithPipelineData(Map parameters, Set parameterKeys,
|
||||
Map pipelineDataMap,
|
||||
Map configurationMap, List configurationKeys,
|
||||
Map configurationMap, Set configurationKeys,
|
||||
Map stepDefaults=[:]
|
||||
){
|
||||
Map merged
|
||||
@ -49,9 +49,9 @@ class ConfigurationMerger {
|
||||
|
||||
@NonCPS
|
||||
def static merge(
|
||||
Map parameters, List parameterKeys,
|
||||
Map generalConfigurationMap, List generalConfigurationKeys, Map generalConfigurationDefaults,
|
||||
Map stepConfigurationMap, List stepConfigurationKeys, Map stepConfigurationDefaults=[:]
|
||||
Map parameters, Set parameterKeys,
|
||||
Map generalConfigurationMap, Set generalConfigurationKeys, Map generalConfigurationDefaults,
|
||||
Map stepConfigurationMap, Set stepConfigurationKeys, Map stepConfigurationDefaults=[:]
|
||||
){
|
||||
Map merged
|
||||
Map mergedStepConfiguration = merge(stepConfigurationMap, stepConfigurationKeys, stepConfigurationDefaults)
|
||||
|
@ -9,9 +9,9 @@ class ConfigurationMergerTest {
|
||||
void testMerge(){
|
||||
Map defaults = [dockerImage: 'mvn']
|
||||
Map parameters = [goals: 'install', flags: '']
|
||||
List parameterKeys = ['flags']
|
||||
Set parameterKeys = ['flags']
|
||||
Map configuration = [flags: '-B']
|
||||
List configurationKeys = ['flags']
|
||||
Set configurationKeys = ['flags']
|
||||
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
||||
Assert.assertEquals('mvn', merged.dockerImage)
|
||||
Assert.assertNull(merged.goals)
|
||||
@ -22,7 +22,7 @@ class ConfigurationMergerTest {
|
||||
void testMergeParameterWithDefault(){
|
||||
Map defaults = [nonErpDestinations: []]
|
||||
Map parameters = [nonErpDestinations: null]
|
||||
List parameterKeys = ['nonErpDestinations']
|
||||
Set parameterKeys = ['nonErpDestinations']
|
||||
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, defaults)
|
||||
Assert.assertEquals([], merged.nonErpDestinations)
|
||||
}
|
||||
@ -31,9 +31,9 @@ class ConfigurationMergerTest {
|
||||
void testMergeCustomPipelineValues(){
|
||||
Map defaults = [dockerImage: 'mvn']
|
||||
Map parameters = [goals: 'install', flags: '']
|
||||
List parameterKeys = ['flags']
|
||||
Set parameterKeys = ['flags']
|
||||
Map configuration = [flags: '-B']
|
||||
List configurationKeys = ['flags']
|
||||
Set configurationKeys = ['flags']
|
||||
Map pipelineDataMap = [artifactVersion: '1.2.3', flags: 'test']
|
||||
Map merged = ConfigurationMerger.mergeWithPipelineData(parameters, parameterKeys, pipelineDataMap, configuration, configurationKeys, defaults)
|
||||
Assert.assertEquals('', merged.flags)
|
||||
@ -44,9 +44,9 @@ class ConfigurationMergerTest {
|
||||
void testMergeDeepStructure(){
|
||||
Map defaults = [fruits: [apples: 1, oranges: 10, bananaaas: 0]]
|
||||
Map configuration = [fruits: [bananaaas: 50, cucumbers: 1000]]
|
||||
List configurationKeys = ['fruits']
|
||||
Set configurationKeys = ['fruits']
|
||||
Map parameters = [fruits: [apples: 18], veggie: []]
|
||||
List parameterKeys = ['fruits']
|
||||
Set parameterKeys = ['fruits']
|
||||
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
||||
Assert.assertEquals(50, merged.fruits.bananaaas)
|
||||
Assert.assertEquals(18, merged.fruits.apples)
|
||||
|
@ -29,7 +29,7 @@ def call(Map parameters = [:]) {
|
||||
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
|
||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
||||
|
||||
List parameterKeys = [
|
||||
Set parameterKeys = [
|
||||
'artifactType',
|
||||
'buildTool',
|
||||
'dockerVersionSource',
|
||||
@ -47,7 +47,7 @@ def call(Map parameters = [:]) {
|
||||
Map pipelineDataMap = [
|
||||
gitCommitId: gitUtils.getGitCommitId()
|
||||
]
|
||||
List stepConfigurationKeys = [
|
||||
Set stepConfigurationKeys = [
|
||||
'artifactType',
|
||||
'buildTool',
|
||||
'dockerVersionSource',
|
||||
|
@ -7,7 +7,7 @@ import com.sap.piper.MapUtils
|
||||
import groovy.transform.Field
|
||||
|
||||
@Field def STEP_NAME = 'checksPublishResults'
|
||||
@Field List TOOLS = [
|
||||
@Field Set TOOLS = [
|
||||
'aggregation', 'tasks', 'pmd', 'cpd', 'findbugs', 'checkstyle', 'eslint', 'pylint'
|
||||
]
|
||||
|
||||
@ -24,7 +24,7 @@ def call(Map parameters = [:]) {
|
||||
prepareDefaultValues script: script
|
||||
prepare(parameters)
|
||||
|
||||
List configKeys = TOOLS.plus('archive')
|
||||
Set configKeys = TOOLS.plus('archive')
|
||||
|
||||
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, STEP_NAME)
|
||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, STEP_NAME)
|
||||
|
@ -17,7 +17,7 @@ def call(Map parameters = [:]) {
|
||||
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
|
||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
||||
|
||||
List parameterKeys = [
|
||||
Set parameterKeys = [
|
||||
'artifactVersion',
|
||||
'influxServer',
|
||||
'influxPrefix'
|
||||
@ -25,7 +25,7 @@ def call(Map parameters = [:]) {
|
||||
Map pipelineDataMap = [
|
||||
artifactVersion: commonPipelineEnvironment.getArtifactVersion()
|
||||
]
|
||||
List stepConfigurationKeys = [
|
||||
Set stepConfigurationKeys = [
|
||||
'influxServer',
|
||||
'influxPrefix'
|
||||
]
|
||||
|
@ -11,7 +11,7 @@ def call(Map parameters = [:]) {
|
||||
|
||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, 'mavenExecute')
|
||||
|
||||
List parameterKeys = [
|
||||
Set parameterKeys = [
|
||||
'dockerImage',
|
||||
'globalSettingsFile',
|
||||
'projectSettingsFile',
|
||||
@ -21,7 +21,7 @@ def call(Map parameters = [:]) {
|
||||
'm2Path',
|
||||
'defines'
|
||||
]
|
||||
List stepConfigurationKeys = [
|
||||
Set stepConfigurationKeys = [
|
||||
'dockerImage',
|
||||
'globalSettingsFile',
|
||||
'projectSettingsFile',
|
||||
|
@ -6,16 +6,16 @@ def call(Map parameters = [:]) {
|
||||
|
||||
def stepName = 'mtaBuild'
|
||||
|
||||
List parameterKeys = [
|
||||
Set parameterKeys = [
|
||||
'buildTarget',
|
||||
'mtaJarLocation'
|
||||
]
|
||||
|
||||
List stepConfigurationKeys = [
|
||||
Set stepConfigurationKeys = [
|
||||
'buildTarget'
|
||||
]
|
||||
|
||||
List generalConfigurationKeys = [
|
||||
Set generalConfigurationKeys = [
|
||||
'mtaJarLocation'
|
||||
]
|
||||
|
||||
|
@ -7,7 +7,7 @@ def call(parameters = [:]) {
|
||||
|
||||
def stepName = 'neoDeploy'
|
||||
|
||||
List parameterKeys = [
|
||||
Set parameterKeys = [
|
||||
'applicationName',
|
||||
'archivePath',
|
||||
'account',
|
||||
@ -27,7 +27,7 @@ def call(parameters = [:]) {
|
||||
'warAction'
|
||||
]
|
||||
|
||||
List stepConfigurationKeys = [
|
||||
Set stepConfigurationKeys = [
|
||||
'account',
|
||||
'dockerEnvVars',
|
||||
'dockerImage',
|
||||
|
Loading…
Reference in New Issue
Block a user