Update extended_choice_param to use convert_xml()
Change-Id: Ia713a21061d6d6db1d1ac48983a44f6f3ea1cc1d
This commit is contained in:
parent
504f6b78ae
commit
00e2ea35d6
@ -395,29 +395,22 @@ def extended_choice_param(registry, xml_parent, data):
|
|||||||
:arg str multi-select-delimiter: value between selections when the
|
:arg str multi-select-delimiter: value between selections when the
|
||||||
parameter is a multi-select (optiona, default ',')
|
parameter is a multi-select (optiona, default ',')
|
||||||
|
|
||||||
Example:
|
Minimal Example:
|
||||||
|
|
||||||
.. literalinclude:: \
|
.. literalinclude:: \
|
||||||
/../../tests/parameters/fixtures/extended-choice-param001.yaml
|
/../../tests/parameters/fixtures/extended-choice-param-minimal.yaml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
|
|
||||||
|
Full Example:
|
||||||
|
.. literalinclude:: \
|
||||||
|
/../../tests/parameters/fixtures/extended-choice-param-full.yaml
|
||||||
|
:language: yaml
|
||||||
"""
|
"""
|
||||||
pdef = base_param(registry, xml_parent, data, False,
|
pdef = base_param(registry, xml_parent, data, False,
|
||||||
'com.cwctravel.hudson.plugins.'
|
'com.cwctravel.hudson.plugins.'
|
||||||
'extended__choice__parameter.'
|
'extended__choice__parameter.'
|
||||||
'ExtendedChoiceParameterDefinition')
|
'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',
|
choicedict = {'single-select': 'PT_SINGLE_SELECT',
|
||||||
'multi-select': 'PT_MULTI_SELECT',
|
'multi-select': 'PT_MULTI_SELECT',
|
||||||
'radio': 'PT_RADIO',
|
'radio': 'PT_RADIO',
|
||||||
@ -428,23 +421,22 @@ def extended_choice_param(registry, xml_parent, data):
|
|||||||
'PT_RADIO': 'PT_RADIO',
|
'PT_RADIO': 'PT_RADIO',
|
||||||
'PT_CHECKBOX': 'PT_CHECKBOX',
|
'PT_CHECKBOX': 'PT_CHECKBOX',
|
||||||
'PT_TEXTBOX': 'PT_TEXTBOX'}
|
'PT_TEXTBOX': 'PT_TEXTBOX'}
|
||||||
|
mapping = [
|
||||||
if choice in choicedict:
|
('value', 'value', ''),
|
||||||
XML.SubElement(pdef, 'type').text = choicedict[choice]
|
('visible-items', 'visibleItemCount', 5),
|
||||||
else:
|
('multi-select-delimiter', 'multiSelectDelimiter', ','),
|
||||||
raise JenkinsJobsException("Type entered is not valid, must be one "
|
('quote-value', 'quoteValue', False),
|
||||||
"of: single-select, multi-select, radio, "
|
('default-value', 'defaultValue', ''),
|
||||||
"textbox or checkbox")
|
('value-description', 'descriptionPropertyValue', ''),
|
||||||
XML.SubElement(pdef, 'propertyFile').text = data.get('property-file', '')
|
('type', 'type', 'single-select', choicedict),
|
||||||
XML.SubElement(pdef, 'propertyKey').text = data.get('property-key', '')
|
('property-file', 'propertyFile', ''),
|
||||||
XML.SubElement(pdef, 'defaultPropertyFile').text = data.get(
|
('property-key', 'propertyKey', ''),
|
||||||
'default-property-file', '')
|
('default-property-file', 'defaultPropertyFile', ''),
|
||||||
XML.SubElement(pdef, 'defaultPropertyKey').text = data.get(
|
('default-property-key', 'defaultPropertyKey', ''),
|
||||||
'default-property-key', '')
|
('description-property-file', 'descriptionPropertyFile', ''),
|
||||||
XML.SubElement(pdef, 'descriptionPropertyFile').text = data.get(
|
('description-property-key', 'descriptionPropertyKey', ''),
|
||||||
'description-property-file', '')
|
]
|
||||||
XML.SubElement(pdef, 'descriptionPropertyKey').text = data.get(
|
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
'description-property-key', '')
|
|
||||||
|
|
||||||
|
|
||||||
def validating_string_param(registry, xml_parent, data):
|
def validating_string_param(registry, xml_parent, data):
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<name>OPTIONS</name>
|
<name>OPTIONS</name>
|
||||||
<description>Available options</description>
|
<description>Available options</description>
|
||||||
<value>OptionA,OptionB,OptionC</value>
|
<value>OptionA,OptionB,OptionC</value>
|
||||||
<visibleItemCount>2</visibleItemCount>
|
<visibleItemCount>5</visibleItemCount>
|
||||||
<multiSelectDelimiter>,</multiSelectDelimiter>
|
<multiSelectDelimiter>,</multiSelectDelimiter>
|
||||||
<quoteValue>false</quoteValue>
|
<quoteValue>false</quoteValue>
|
||||||
<defaultValue/>
|
<defaultValue/>
|
@ -4,5 +4,3 @@ parameters:
|
|||||||
description: "Available options"
|
description: "Available options"
|
||||||
type: 'PT_CHECKBOX'
|
type: 'PT_CHECKBOX'
|
||||||
value: OptionA,OptionB,OptionC
|
value: OptionA,OptionB,OptionC
|
||||||
visible-item-count: "2"
|
|
||||||
|
|
@ -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>
|
|
@ -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
|
|
Loading…
x
Reference in New Issue
Block a user