Skip to content

Commit

Permalink
Rebuild Provision Requests with arrays
Browse files Browse the repository at this point in the history
If a field is included in the FIELD_ARRAY constant, we allow the resulting values returned as arrays.
  • Loading branch information
syncrou committed Jun 26, 2017
1 parent 091c64f commit a5404e1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/rebuild_provision_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
class Tab
attr_reader :output, :log

ARRAY_FIELD_NAMES = [:security_groups].freeze

def initialize(dialog_content, provision_options, quiet)
@dialog_content = dialog_content
@provision_options = provision_options
Expand Down Expand Up @@ -116,7 +118,7 @@ def ws_only_files
def dialog_field_values(dialog_tab)
dialog_tab[:fields].keys.each do |field|
value = @provision_options[field]
value = value.first if value.kind_of?(Array)
value = process_list_values(field, value)
yield(field.to_s, value) if value.present?
@provision_options.delete(field)
end
Expand Down Expand Up @@ -181,6 +183,18 @@ def schedule(tab, dialog_tab)
end
general_tab(tab, dialog_tab)
end

private

def process_list_values(key, value)
if ARRAY_FIELD_NAMES.include?(key)
value
elsif value.kind_of?(Array)
value.first
else
value
end
end
end

class Dialog
Expand Down

0 comments on commit a5404e1

Please sign in to comment.