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 {
|
class ConfigurationMerger {
|
||||||
@NonCPS
|
@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 filteredConfig = configKeys?configs.subMap(configKeys):configs
|
||||||
Map merged = [:]
|
Map merged = [:]
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ class ConfigurationMerger {
|
|||||||
|
|
||||||
@NonCPS
|
@NonCPS
|
||||||
def static merge(
|
def static merge(
|
||||||
Map parameters, List parameterKeys,
|
Map parameters, Set parameterKeys,
|
||||||
Map configuration, List configurationKeys,
|
Map configuration, Set configurationKeys,
|
||||||
Map defaults=[:]
|
Map defaults=[:]
|
||||||
){
|
){
|
||||||
Map merged
|
Map merged
|
||||||
@ -34,9 +34,9 @@ class ConfigurationMerger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NonCPS
|
@NonCPS
|
||||||
def static mergeWithPipelineData(Map parameters, List parameterKeys,
|
def static mergeWithPipelineData(Map parameters, Set parameterKeys,
|
||||||
Map pipelineDataMap,
|
Map pipelineDataMap,
|
||||||
Map configurationMap, List configurationKeys,
|
Map configurationMap, Set configurationKeys,
|
||||||
Map stepDefaults=[:]
|
Map stepDefaults=[:]
|
||||||
){
|
){
|
||||||
Map merged
|
Map merged
|
||||||
@ -49,9 +49,9 @@ class ConfigurationMerger {
|
|||||||
|
|
||||||
@NonCPS
|
@NonCPS
|
||||||
def static merge(
|
def static merge(
|
||||||
Map parameters, List parameterKeys,
|
Map parameters, Set parameterKeys,
|
||||||
Map generalConfigurationMap, List generalConfigurationKeys, Map generalConfigurationDefaults,
|
Map generalConfigurationMap, Set generalConfigurationKeys, Map generalConfigurationDefaults,
|
||||||
Map stepConfigurationMap, List stepConfigurationKeys, Map stepConfigurationDefaults=[:]
|
Map stepConfigurationMap, Set stepConfigurationKeys, Map stepConfigurationDefaults=[:]
|
||||||
){
|
){
|
||||||
Map merged
|
Map merged
|
||||||
Map mergedStepConfiguration = merge(stepConfigurationMap, stepConfigurationKeys, stepConfigurationDefaults)
|
Map mergedStepConfiguration = merge(stepConfigurationMap, stepConfigurationKeys, stepConfigurationDefaults)
|
||||||
|
@ -9,9 +9,9 @@ class ConfigurationMergerTest {
|
|||||||
void testMerge(){
|
void testMerge(){
|
||||||
Map defaults = [dockerImage: 'mvn']
|
Map defaults = [dockerImage: 'mvn']
|
||||||
Map parameters = [goals: 'install', flags: '']
|
Map parameters = [goals: 'install', flags: '']
|
||||||
List parameterKeys = ['flags']
|
Set parameterKeys = ['flags']
|
||||||
Map configuration = [flags: '-B']
|
Map configuration = [flags: '-B']
|
||||||
List configurationKeys = ['flags']
|
Set configurationKeys = ['flags']
|
||||||
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
||||||
Assert.assertEquals('mvn', merged.dockerImage)
|
Assert.assertEquals('mvn', merged.dockerImage)
|
||||||
Assert.assertNull(merged.goals)
|
Assert.assertNull(merged.goals)
|
||||||
@ -22,7 +22,7 @@ class ConfigurationMergerTest {
|
|||||||
void testMergeParameterWithDefault(){
|
void testMergeParameterWithDefault(){
|
||||||
Map defaults = [nonErpDestinations: []]
|
Map defaults = [nonErpDestinations: []]
|
||||||
Map parameters = [nonErpDestinations: null]
|
Map parameters = [nonErpDestinations: null]
|
||||||
List parameterKeys = ['nonErpDestinations']
|
Set parameterKeys = ['nonErpDestinations']
|
||||||
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, defaults)
|
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, defaults)
|
||||||
Assert.assertEquals([], merged.nonErpDestinations)
|
Assert.assertEquals([], merged.nonErpDestinations)
|
||||||
}
|
}
|
||||||
@ -31,9 +31,9 @@ class ConfigurationMergerTest {
|
|||||||
void testMergeCustomPipelineValues(){
|
void testMergeCustomPipelineValues(){
|
||||||
Map defaults = [dockerImage: 'mvn']
|
Map defaults = [dockerImage: 'mvn']
|
||||||
Map parameters = [goals: 'install', flags: '']
|
Map parameters = [goals: 'install', flags: '']
|
||||||
List parameterKeys = ['flags']
|
Set parameterKeys = ['flags']
|
||||||
Map configuration = [flags: '-B']
|
Map configuration = [flags: '-B']
|
||||||
List configurationKeys = ['flags']
|
Set configurationKeys = ['flags']
|
||||||
Map pipelineDataMap = [artifactVersion: '1.2.3', flags: 'test']
|
Map pipelineDataMap = [artifactVersion: '1.2.3', flags: 'test']
|
||||||
Map merged = ConfigurationMerger.mergeWithPipelineData(parameters, parameterKeys, pipelineDataMap, configuration, configurationKeys, defaults)
|
Map merged = ConfigurationMerger.mergeWithPipelineData(parameters, parameterKeys, pipelineDataMap, configuration, configurationKeys, defaults)
|
||||||
Assert.assertEquals('', merged.flags)
|
Assert.assertEquals('', merged.flags)
|
||||||
@ -44,9 +44,9 @@ class ConfigurationMergerTest {
|
|||||||
void testMergeDeepStructure(){
|
void testMergeDeepStructure(){
|
||||||
Map defaults = [fruits: [apples: 1, oranges: 10, bananaaas: 0]]
|
Map defaults = [fruits: [apples: 1, oranges: 10, bananaaas: 0]]
|
||||||
Map configuration = [fruits: [bananaaas: 50, cucumbers: 1000]]
|
Map configuration = [fruits: [bananaaas: 50, cucumbers: 1000]]
|
||||||
List configurationKeys = ['fruits']
|
Set configurationKeys = ['fruits']
|
||||||
Map parameters = [fruits: [apples: 18], veggie: []]
|
Map parameters = [fruits: [apples: 18], veggie: []]
|
||||||
List parameterKeys = ['fruits']
|
Set parameterKeys = ['fruits']
|
||||||
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
||||||
Assert.assertEquals(50, merged.fruits.bananaaas)
|
Assert.assertEquals(50, merged.fruits.bananaaas)
|
||||||
Assert.assertEquals(18, merged.fruits.apples)
|
Assert.assertEquals(18, merged.fruits.apples)
|
||||||
|
@ -29,7 +29,7 @@ def call(Map parameters = [:]) {
|
|||||||
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
|
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
|
||||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
||||||
|
|
||||||
List parameterKeys = [
|
Set parameterKeys = [
|
||||||
'artifactType',
|
'artifactType',
|
||||||
'buildTool',
|
'buildTool',
|
||||||
'dockerVersionSource',
|
'dockerVersionSource',
|
||||||
@ -47,7 +47,7 @@ def call(Map parameters = [:]) {
|
|||||||
Map pipelineDataMap = [
|
Map pipelineDataMap = [
|
||||||
gitCommitId: gitUtils.getGitCommitId()
|
gitCommitId: gitUtils.getGitCommitId()
|
||||||
]
|
]
|
||||||
List stepConfigurationKeys = [
|
Set stepConfigurationKeys = [
|
||||||
'artifactType',
|
'artifactType',
|
||||||
'buildTool',
|
'buildTool',
|
||||||
'dockerVersionSource',
|
'dockerVersionSource',
|
||||||
|
@ -7,7 +7,7 @@ import com.sap.piper.MapUtils
|
|||||||
import groovy.transform.Field
|
import groovy.transform.Field
|
||||||
|
|
||||||
@Field def STEP_NAME = 'checksPublishResults'
|
@Field def STEP_NAME = 'checksPublishResults'
|
||||||
@Field List TOOLS = [
|
@Field Set TOOLS = [
|
||||||
'aggregation', 'tasks', 'pmd', 'cpd', 'findbugs', 'checkstyle', 'eslint', 'pylint'
|
'aggregation', 'tasks', 'pmd', 'cpd', 'findbugs', 'checkstyle', 'eslint', 'pylint'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ def call(Map parameters = [:]) {
|
|||||||
prepareDefaultValues script: script
|
prepareDefaultValues script: script
|
||||||
prepare(parameters)
|
prepare(parameters)
|
||||||
|
|
||||||
List configKeys = TOOLS.plus('archive')
|
Set configKeys = TOOLS.plus('archive')
|
||||||
|
|
||||||
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, STEP_NAME)
|
final Map stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, STEP_NAME)
|
||||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(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 stepDefaults = ConfigurationLoader.defaultStepConfiguration(script, stepName)
|
||||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, stepName)
|
||||||
|
|
||||||
List parameterKeys = [
|
Set parameterKeys = [
|
||||||
'artifactVersion',
|
'artifactVersion',
|
||||||
'influxServer',
|
'influxServer',
|
||||||
'influxPrefix'
|
'influxPrefix'
|
||||||
@ -25,7 +25,7 @@ def call(Map parameters = [:]) {
|
|||||||
Map pipelineDataMap = [
|
Map pipelineDataMap = [
|
||||||
artifactVersion: commonPipelineEnvironment.getArtifactVersion()
|
artifactVersion: commonPipelineEnvironment.getArtifactVersion()
|
||||||
]
|
]
|
||||||
List stepConfigurationKeys = [
|
Set stepConfigurationKeys = [
|
||||||
'influxServer',
|
'influxServer',
|
||||||
'influxPrefix'
|
'influxPrefix'
|
||||||
]
|
]
|
||||||
|
@ -11,7 +11,7 @@ def call(Map parameters = [:]) {
|
|||||||
|
|
||||||
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, 'mavenExecute')
|
final Map stepConfiguration = ConfigurationLoader.stepConfiguration(script, 'mavenExecute')
|
||||||
|
|
||||||
List parameterKeys = [
|
Set parameterKeys = [
|
||||||
'dockerImage',
|
'dockerImage',
|
||||||
'globalSettingsFile',
|
'globalSettingsFile',
|
||||||
'projectSettingsFile',
|
'projectSettingsFile',
|
||||||
@ -21,7 +21,7 @@ def call(Map parameters = [:]) {
|
|||||||
'm2Path',
|
'm2Path',
|
||||||
'defines'
|
'defines'
|
||||||
]
|
]
|
||||||
List stepConfigurationKeys = [
|
Set stepConfigurationKeys = [
|
||||||
'dockerImage',
|
'dockerImage',
|
||||||
'globalSettingsFile',
|
'globalSettingsFile',
|
||||||
'projectSettingsFile',
|
'projectSettingsFile',
|
||||||
|
@ -6,16 +6,16 @@ def call(Map parameters = [:]) {
|
|||||||
|
|
||||||
def stepName = 'mtaBuild'
|
def stepName = 'mtaBuild'
|
||||||
|
|
||||||
List parameterKeys = [
|
Set parameterKeys = [
|
||||||
'buildTarget',
|
'buildTarget',
|
||||||
'mtaJarLocation'
|
'mtaJarLocation'
|
||||||
]
|
]
|
||||||
|
|
||||||
List stepConfigurationKeys = [
|
Set stepConfigurationKeys = [
|
||||||
'buildTarget'
|
'buildTarget'
|
||||||
]
|
]
|
||||||
|
|
||||||
List generalConfigurationKeys = [
|
Set generalConfigurationKeys = [
|
||||||
'mtaJarLocation'
|
'mtaJarLocation'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ def call(parameters = [:]) {
|
|||||||
|
|
||||||
def stepName = 'neoDeploy'
|
def stepName = 'neoDeploy'
|
||||||
|
|
||||||
List parameterKeys = [
|
Set parameterKeys = [
|
||||||
'applicationName',
|
'applicationName',
|
||||||
'archivePath',
|
'archivePath',
|
||||||
'account',
|
'account',
|
||||||
@ -27,7 +27,7 @@ def call(parameters = [:]) {
|
|||||||
'warAction'
|
'warAction'
|
||||||
]
|
]
|
||||||
|
|
||||||
List stepConfigurationKeys = [
|
Set stepConfigurationKeys = [
|
||||||
'account',
|
'account',
|
||||||
'dockerEnvVars',
|
'dockerEnvVars',
|
||||||
'dockerImage',
|
'dockerImage',
|
||||||
|
Loading…
Reference in New Issue
Block a user