-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service dialog generation rely only on OrchestrationParameterConstraint #16047
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,9 @@ def add_field(parameter, group, position, name_prefix = nil) | |
|
||
checkbox = parameter.constraints.detect { |c| c.kind_of?(OrchestrationTemplate::OrchestrationParameterBoolean) } | ||
return create_checkbox(parameter, group, position, name_prefix) if checkbox | ||
|
||
textarea = parameter.constraints.detect { |c| c.kind_of?(OrchestrationTemplate::OrchestrationParameterMultiline) } | ||
return create_textarea(parameter, group, position, name_prefix) if textarea | ||
end | ||
|
||
create_textbox(parameter, group, position, name_prefix) | ||
|
@@ -59,7 +62,7 @@ def create_dynamic_dropdown_list(parameter, group, position, dynamic_dropdown, n | |
group.dialog_fields.build( | ||
:type => "DialogFieldDropDownList", | ||
:name => "#{name_prefix}#{parameter.name}", | ||
:data_type => parameter.data_type || "string", | ||
:data_type => "string", | ||
:dynamic => true, | ||
:display => "edit", | ||
:required => parameter.required, | ||
|
@@ -76,34 +79,29 @@ def create_dropdown_list(parameter, group, position, dropdown, name_prefix) | |
values = dropdown.allowed_values | ||
dropdown_list = values.kind_of?(Hash) ? values.to_a : values.collect { |v| [v, v] } | ||
group.dialog_fields.build( | ||
:type => "DialogFieldDropDownList", | ||
:name => "#{name_prefix}#{parameter.name}", | ||
:data_type => parameter.data_type || "string", | ||
:display => "edit", | ||
:required => parameter.required, | ||
:values => dropdown_list, | ||
:default_value => parameter.default_value || dropdown_list.first, | ||
:label => parameter.label, | ||
:description => parameter.description, | ||
:reconfigurable => parameter.reconfigurable, | ||
:position => position, | ||
:dialog_group => group | ||
:type => "DialogFieldDropDownList", | ||
:name => "#{name_prefix}#{parameter.name}", | ||
:data_type => "string", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Why are drop-downs always strings now? |
||
:display => "edit", | ||
:force_multi_value => dropdown.allow_multiple, | ||
:required => parameter.required, | ||
:values => dropdown_list, | ||
:default_value => parameter.default_value || dropdown_list.first, | ||
:label => parameter.label, | ||
:description => parameter.description, | ||
:reconfigurable => parameter.reconfigurable, | ||
:position => position, | ||
:dialog_group => group | ||
) | ||
end | ||
|
||
def create_textbox(parameter, group, position, name_prefix) | ||
if parameter.data_type == 'string' || parameter.data_type == 'integer' | ||
data_type = parameter.data_type | ||
field_type = 'DialogFieldTextBox' | ||
else | ||
data_type = 'string' | ||
field_type = 'DialogFieldTextAreaBox' | ||
end | ||
data_type = parameter.data_type.casecmp('integer').zero? ? 'integer' : 'string' | ||
if parameter.constraints | ||
pattern = parameter.constraints.detect { |c| c.kind_of?(OrchestrationTemplate::OrchestrationParameterPattern) } | ||
end | ||
group.dialog_fields.build( | ||
:type => field_type, | ||
:type => 'DialogFieldTextBox', | ||
:name => "#{name_prefix}#{parameter.name}", | ||
:data_type => data_type, | ||
:display => "edit", | ||
|
@@ -120,14 +118,29 @@ def create_textbox(parameter, group, position, name_prefix) | |
) | ||
end | ||
|
||
def create_textarea(parameter, group, position, name_prefix) | ||
group.dialog_fields.build( | ||
:type => 'DialogFieldTextAreaBox', | ||
:name => "#{name_prefix}#{parameter.name}", | ||
:data_type => 'string', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TextAreaBox I agree only makes sense for strings. 👍 |
||
:display => "edit", | ||
:required => parameter.required, | ||
:default_value => parameter.default_value, | ||
:label => parameter.label, | ||
:description => parameter.description, | ||
:reconfigurable => parameter.reconfigurable, | ||
:position => position, | ||
:dialog_group => group | ||
) | ||
end | ||
|
||
def create_checkbox(parameter, group, position, name_prefix) | ||
group.dialog_fields.build( | ||
:type => "DialogFieldCheckBox", | ||
:name => "#{name_prefix}#{parameter.name}", | ||
:data_type => "boolean", | ||
:display => "edit", | ||
:default_value => parameter.default_value, | ||
:options => {:protected => parameter.hidden?}, | ||
:label => parameter.label, | ||
:description => parameter.description, | ||
:reconfigurable => parameter.reconfigurable, | ||
|
1 change: 1 addition & 0 deletions
1
app/models/orchestration_template/orchestration_parameter_allowed.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class OrchestrationTemplate | ||
class OrchestrationParameterAllowed < OrchestrationParameterConstraint | ||
attr_accessor :allowed_values | ||
attr_accessor :allow_multiple | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
app/models/orchestration_template/orchestration_parameter_multiline.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class OrchestrationTemplate | ||
class OrchestrationParameterMultiline < OrchestrationParameterConstraint | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzwei Does this mean we would no longer support dropdown-list with an 'integer' type? I would image that is something we would still need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter.data_type
is provider specific type. It can be any value or any spelling. We will convert the string back to required value per provider before sending the provisioning request.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is only for orchestration and only the drop-downs I am ok with this as long as you are processing the values before sending to the provider. Previously I was thinking of this issue we ran into (https://bugzilla.redhat.com/show_bug.cgi?id=1478367) where we were passing the value to Azure deployment as an integer instead of a string.