Merge "Update extended_choice_param to use convert_xml()"

This commit is contained in:
Zuul 2017-10-23 17:24:35 +00:00 committed by Gerrit Code Review
commit 6445c6c3a1
7 changed files with 24 additions and 73 deletions

View File

@ -396,29 +396,22 @@ def extended_choice_param(registry, xml_parent, data):
:arg str multi-select-delimiter: value between selections when the
parameter is a multi-select (optiona, default ',')
Example:
Minimal Example:
.. literalinclude:: \
/../../tests/parameters/fixtures/extended-choice-param001.yaml
/../../tests/parameters/fixtures/extended-choice-param-minimal.yaml
:language: yaml
Full Example:
.. literalinclude:: \
/../../tests/parameters/fixtures/extended-choice-param-full.yaml
:language: yaml
"""
pdef = base_param(registry, xml_parent, data, False,
'com.cwctravel.hudson.plugins.'
'extended__choice__parameter.'
'ExtendedChoiceParameterDefinition')
XML.SubElement(pdef, 'value').text = data.get('value', '')
XML.SubElement(pdef, 'visibleItemCount').text = str(data.get(
'visible-items', data.get('visible-item-count', 5)))
XML.SubElement(pdef, 'multiSelectDelimiter').text = data.get(
'multi-select-delimiter', ',')
XML.SubElement(pdef, 'quoteValue').text = str(data.get('quote-value',
False)).lower()
XML.SubElement(pdef, 'defaultValue').text = data.get(
'default-value', '')
XML.SubElement(pdef, 'descriptionPropertyValue').text = data.get(
'value-description', '')
choice = data.get('type', 'single-select')
choicedict = {'single-select': 'PT_SINGLE_SELECT',
'multi-select': 'PT_MULTI_SELECT',
'radio': 'PT_RADIO',
@ -429,23 +422,22 @@ def extended_choice_param(registry, xml_parent, data):
'PT_RADIO': 'PT_RADIO',
'PT_CHECKBOX': 'PT_CHECKBOX',
'PT_TEXTBOX': 'PT_TEXTBOX'}
if choice in choicedict:
XML.SubElement(pdef, 'type').text = choicedict[choice]
else:
raise JenkinsJobsException("Type entered is not valid, must be one "
"of: single-select, multi-select, radio, "
"textbox or checkbox")
XML.SubElement(pdef, 'propertyFile').text = data.get('property-file', '')
XML.SubElement(pdef, 'propertyKey').text = data.get('property-key', '')
XML.SubElement(pdef, 'defaultPropertyFile').text = data.get(
'default-property-file', '')
XML.SubElement(pdef, 'defaultPropertyKey').text = data.get(
'default-property-key', '')
XML.SubElement(pdef, 'descriptionPropertyFile').text = data.get(
'description-property-file', '')
XML.SubElement(pdef, 'descriptionPropertyKey').text = data.get(
'description-property-key', '')
mapping = [
('value', 'value', ''),
('visible-items', 'visibleItemCount', 5),
('multi-select-delimiter', 'multiSelectDelimiter', ','),
('quote-value', 'quoteValue', False),
('default-value', 'defaultValue', ''),
('value-description', 'descriptionPropertyValue', ''),
('type', 'type', 'single-select', choicedict),
('property-file', 'propertyFile', ''),
('property-key', 'propertyKey', ''),
('default-property-file', 'defaultPropertyFile', ''),
('default-property-key', 'defaultPropertyKey', ''),
('description-property-file', 'descriptionPropertyFile', ''),
('description-property-key', 'descriptionPropertyKey', ''),
]
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
def validating_string_param(registry, xml_parent, data):

View File

@ -7,7 +7,7 @@
<name>OPTIONS</name>
<description>Available options</description>
<value>OptionA,OptionB,OptionC</value>
<visibleItemCount>2</visibleItemCount>
<visibleItemCount>5</visibleItemCount>
<multiSelectDelimiter>,</multiSelectDelimiter>
<quoteValue>false</quoteValue>
<defaultValue/>

View File

@ -4,5 +4,3 @@ parameters:
description: "Available options"
type: 'PT_CHECKBOX'
value: OptionA,OptionB,OptionC
visible-item-count: "2"

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition>
<name>OPTIONS</name>
<description>Available options</description>
<value/>
<visibleItemCount>2</visibleItemCount>
<multiSelectDelimiter>,</multiSelectDelimiter>
<quoteValue>false</quoteValue>
<defaultValue>foo</defaultValue>
<descriptionPropertyValue>bar1, bar2, bar3</descriptionPropertyValue>
<type>PT_SINGLE_SELECT</type>
<propertyFile>/home/foo/property.prop</propertyFile>
<propertyKey>key</propertyKey>
<defaultPropertyFile>/home/property.prop</defaultPropertyFile>
<defaultPropertyKey>fookey</defaultPropertyKey>
<descriptionPropertyFile>/home/foo/bar.properties</descriptionPropertyFile>
<descriptionPropertyKey>bar_desc</descriptionPropertyKey>
</com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
</project>

View File

@ -1,13 +0,0 @@
parameters:
- extended-choice:
name: OPTIONS
description: "Available options"
property-file: /home/foo/property.prop
property-key: key
visible-items: 2
default-value: foo
default-property-file: /home/property.prop
default-property-key: fookey
description-property-file: /home/foo/bar.properties
description-property-key: bar_desc
value-description: bar1, bar2, bar3