Project

General

Profile

Revision 502df2e4

Added by Thomas McKay about 6 years ago

repo enable for subscriptions that don't have release version

View differences:

lib/hammer_cli_csv/subscriptions.rb
51 51
        end
52 52
      end
53 53

  
54
      # FIXME: TODO remove this rubocop
55
      # rubocop:disable CyclomaticComplexity
54 56
      def enable_products_from_csv(line)
55 57
        organization = line[ORGANIZATION] || option_organization
56 58
        raise "Organization is required in either input CSV or by option --organization" if organization.nil? || organization.empty?
......
77 79
        repository_set = results[0]
78 80

  
79 81
        repository = repository_set['repositories'].find do |repo|
80
          repo['name'].end_with?("#{line[ARCH]} #{line[RELEASE]}")
82
          if line[RELEASE].nil? || line[RELEASE].empty?
83
            repo['name'].end_with?("#{line[ARCH]}")
84
          else
85
            repo['name'].end_with?("#{line[ARCH]} #{line[RELEASE]}")
86
          end
81 87
        end
82 88

  
83 89
        if repository.nil?
......
87 93
          end
88 94
          raise "No match for content set '#{line[CONTENT_SET]}'" if !product_content
89 95

  
90
          @api.resource(:repository_sets).call(:enable, {
96
          params = {
91 97
              'id' => product_content['content']['id'],
92 98
              'product_id' => product['id'],
93
              'basearch' => line[ARCH],
94
              'releasever' => line[RELEASE]
95
          })
99
              'basearch' => line[ARCH]
100
          }
101
          params['releasever'] = line[RELEASE] unless line[RELEASE].nil? || line[RELEASE].empty?
102

  
103
          @api.resource(:repository_sets).call(:enable, params)
96 104
          puts 'done' if option_verbose?
97 105
        else
98 106
          puts "Repository #{repository['name']} already enabled" if option_verbose?

Also available in: Unified diff