lib/gooddata/lcm/lcm2.rb in gooddata-0.6.51 vs lib/gooddata/lcm/lcm2.rb in gooddata-0.6.52

- old
+ new

@@ -83,48 +83,45 @@ SegmentsFilter, CreateSegmentMasters, EnsureTechnicalUsersDomain, EnsureTechnicalUsersProject, SynchronizeLdm, - SynchronizeMeta, - SynchronizeLabelTypes, - SynchronizeAttributeDrillpath, + CollectAttributes, + CollectMeta, + CollectTaggedObjects, + CollectComputedAttributeMetrics, + ImportObjectCollections, + SynchronizeComputedAttributes, SynchronizeProcesses, SynchronizeSchedules, SynchronizeColorPalette, SynchronizeNewSegments, UpdateReleaseTable ], provision: [ EnsureReleaseTable, CollectSegments, - SegmentsFilter, PurgeClients, CollectClients, AssociateClients, ProvisionClients, EnsureTechnicalUsersDomain, EnsureTechnicalUsersProject, - SynchronizeAttributeDrillpath, - SynchronizeETLsInSegment, - SynchronizeColorPalette + SynchronizeETLsInSegment ], rollout: [ EnsureReleaseTable, CollectSegments, - SegmentsFilter, CollectSegmentClients, EnsureTechnicalUsersDomain, EnsureTechnicalUsersProject, SynchronizeLdm, - # SynchronizeLabelTypes, - SynchronizeAttributeDrillpath, ApplyCustomMaql, - SynchronizeColorPalette, SynchronizeClients, + SynchronizeComputedAttributes, SynchronizeETLsInSegment ] } MODE_NAMES = MODES.keys @@ -196,22 +193,27 @@ end headings = keys.map(&:upcase) rows = messages && messages.map do |message| + unless message + GoodData.logger.warn("Found an empty message in the results of the #{action.name} action") + next + end row = [] keys.each do |heading| row << message[heading] end row end rows ||= [] + rows.compact! table = Terminal::Table.new :title => title, :headings => headings do |t| rows.each_with_index do |row, index| - t << row + t << (row || []) t.add_separator if index < rows.length - 1 end end puts "\n#{table}" @@ -240,10 +242,12 @@ end end end end + check_unused_params(actions, params) + # Print name of actions to be performed for debug purposes print_action_names(mode, actions) # TODO: Check all action params first @@ -259,27 +263,39 @@ params.strict.to_b else true end + skip_actions = (params.skip_actions || []) + actions = actions.reject do |action| + skip_actions.include?(action.to_s) + end + # Run actions errors = [] results = [] actions.each do |action| puts # Invoke action begin + # Check if all required parameters were passed + BaseAction.check_params(action.const_get('PARAMS'), params) + out = action.send(:call, params) rescue => e errors << { action: action, - err: e + err: e, + backtrace: e.backtrace } break if fail_early end + # in case fail_early = false, we need to execute another action + next unless out + # Handle output results and params res = out.is_a?(Array) ? out : out[:results] out_params = out.is_a?(Hash) ? out[:params] || {} : {} new_params = convert_to_smart_hash(out_params) @@ -314,9 +330,46 @@ { actions: actions.map(&:short_name), results: brick_results, params: params } + end + + def check_unused_params(actions, params) + default_params = [ + :client_gdc_hostname, + :client_gdc_protocol, + :fail_early, + :gdc_logger, + :gdc_password, + :gdc_username, + :strict + ] + + action_params = actions.map do |action| + action.const_get(:PARAMS).keys.map(&:downcase) + end + + action_params.flatten!.uniq! + + param_names = params.keys.map(&:downcase) + + unused_params = param_names - (action_params + default_params) + + if unused_params.any? + GoodData.logger.warn("Following params are not used by any action: #{JSON.pretty_generate(unused_params)}") + + rows = [] + actions.each do |action| + action_params = action.const_get(:PARAMS) + action_params.each do |_k, v| + rows << [action.short_name, v[:name], v[:description], v[:type].class.short_name] + end + end + + table = Terminal::Table.new :headings => ['Action', 'Parameter', 'Description', 'Parameter Type'], :rows => rows + puts table.to_s + end end end end end