runcible 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81e84d07e192dd82fcf5eb669130f43b389dc667
4
- data.tar.gz: 1c04abfe584586d01c6f7a6f0d45dd7700cd18b1
3
+ metadata.gz: 6fddef47151b53308fce3a4a103f5a082e657f47
4
+ data.tar.gz: 149ff0d3f758d5289c95e771f3056c567de70bc4
5
5
  SHA512:
6
- metadata.gz: 02fa77aa02bb6569fc2e7b71f92ac82c6db708eb953cbb8a69fbbfc2b49a24a91dba7c5f5b2bacdfe79a7c7686d8839c2c78479fd2f442b8b1f97d405682fb4b
7
- data.tar.gz: 0ce2e8c37fb40f68095cc0545d4b5472cc3d9bec62f0c0d5f3ab11f8ba76abfee362f6735b35ef139ae2d91c1df58a84059c2e9a63ec125d879de48af9172f94
6
+ metadata.gz: eb888ca430e0d85510c0c3116d673e762acf837eb23b4d79dffe0dccd6a74a362639303384dba25110670ad8cfb9adb60838e20f83c338318ff931219d70ad14
7
+ data.tar.gz: ca48cd2e29a30c0c2fbddb5ad85c9d4273a95f9227b14d01ca22752ac093af9ed444bdcaec6172b774390fc9575ab197b22da1d47018652f2717866419dce197
data/Gemfile CHANGED
@@ -6,9 +6,10 @@ gemspec
6
6
  group :test do
7
7
  gem 'rake', '0.9.2.2'
8
8
  gem 'vcr'
9
- gem 'webmock'
9
+ gem 'webmock', '< 2.0.0' # https://github.com/vcr/vcr/issues/570
10
10
  gem 'minitest', '~> 4.7'
11
11
  gem 'parseconfig'
12
12
  gem 'mocha', "~> 0.14.0"
13
- gem 'rubocop', "0.24.1"
13
+ gem 'rubocop', "0.39.0"
14
+ gem 'coveralls'
14
15
  end
data/README.md CHANGED
@@ -1,16 +1,17 @@
1
1
  # Runcible
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/Katello/runcible.png)](http://travis-ci.org/Katello/runcible)
4
+ [![Coverage Status](https://coveralls.io/repos/github/Katello/runcible/badge.svg?branch=master)](https://coveralls.io/github/Katello/runcible?branch=master)
4
5
 
5
6
  Exposing Pulp's juiciest parts. http://www.pulpproject.org/
6
7
 
7
- Latest Live Tested Version: **pulp-server-2.8.0-0.7.beta.el7.noarch**
8
+ Latest Live Tested Version: **pulp-server-2.8.3-0.1.beta.el7.noarch**
8
9
 
9
10
  Current stable Runcible: https://github.com/Katello/runcible/tree/0.3
10
11
 
11
12
  For in-depth class and method documentation: http://katello.github.com/runcible/
12
13
 
13
- Please file new issues here: [Readmine](http://projects.theforeman.org/projects/runcible/issues/new)
14
+ Please file new issues here: [Redmine](http://projects.theforeman.org/projects/runcible/issues/new)
14
15
 
15
16
  ## Installation
16
17
 
@@ -31,16 +31,16 @@ module Runcible
31
31
  #on occation path will already have prefix (sync cancel)
32
32
  path = clone_config[:api_path] + path unless path.start_with?(clone_config[:api_path])
33
33
 
34
- RestClient.log = []
34
+ RestClient.log = []
35
35
  headers = clone_config[:headers].clone
36
36
 
37
37
  get_params = options[:params] if options[:params]
38
38
  path = combine_get_params(path, get_params) if get_params
39
39
 
40
40
  client_options = {}
41
- client_options[:timeout] = clone_config[:timeout] if clone_config[:timeout]
42
- client_options[:open_timeout] = clone_config[:open_timeout] if clone_config[:open_timeout]
43
- client_options[:verify_ssl] = clone_config[:verify_ssl] unless clone_config[:verify_ssl].nil?
41
+ client_options[:timeout] = clone_config[:timeout] if clone_config[:timeout]
42
+ client_options[:open_timeout] = clone_config[:open_timeout] if clone_config[:open_timeout]
43
+ client_options[:verify_ssl] = clone_config[:verify_ssl] unless clone_config[:verify_ssl].nil?
44
44
 
45
45
  if clone_config[:oauth]
46
46
  headers = add_oauth_header(method, path, headers)
@@ -52,7 +52,7 @@ module Runcible
52
52
  client_options[:ssl_client_cert] = clone_config[:cert_auth][:ssl_client_cert]
53
53
  client_options[:ssl_client_key] = clone_config[:cert_auth][:ssl_client_key]
54
54
  else
55
- client_options[:user] = clone_config[:user]
55
+ client_options[:user] = clone_config[:user]
56
56
  client_options[:password] = config[:http_auth][:password]
57
57
  end
58
58
 
@@ -83,7 +83,7 @@ module Runcible
83
83
  end
84
84
 
85
85
  def combine_get_params(path, params)
86
- query_string = params.map do |k, v|
86
+ query_string = params.map do |k, v|
87
87
  if v.is_a? Array
88
88
  v.map { |y| "#{k}=#{y}" }.join('&')
89
89
  else
@@ -105,11 +105,11 @@ module Runcible
105
105
  def format_payload_json(payload_hash)
106
106
  if payload_hash
107
107
  if payload_hash[:optional]
108
- if payload_hash[:required]
109
- payload = payload_hash[:required].merge(payload_hash[:optional])
110
- else
111
- payload = payload_hash[:optional]
112
- end
108
+ payload = if payload_hash[:required]
109
+ payload_hash[:required].merge(payload_hash[:optional])
110
+ else
111
+ payload_hash[:optional]
112
+ end
113
113
  elsif payload_hash[:delta]
114
114
  payload = payload_hash
115
115
  else
@@ -128,7 +128,7 @@ module Runcible
128
128
  if body.respond_to? :with_indifferent_access
129
129
  body = body.with_indifferent_access
130
130
  elsif body.is_a? Array
131
- body = body.map do |i|
131
+ body = body.map do |i|
132
132
  i.respond_to?(:with_indifferent_access) ? i.with_indifferent_access : i
133
133
  end
134
134
  end
@@ -114,12 +114,12 @@ module Runcible
114
114
  units.each do |unit|
115
115
  content_unit = {}
116
116
  content_unit[:type_id] = type_id
117
- if unit.is_a?(Hash)
118
- #allow user to pass in entire unit
119
- content_unit[:unit_key] = unit
120
- else
121
- content_unit[:unit_key] = { unit_key => unit }
122
- end
117
+ content_unit[:unit_key] = if unit.is_a?(Hash)
118
+ #allow user to pass in entire unit
119
+ unit
120
+ else
121
+ { unit_key => unit }
122
+ end
123
123
 
124
124
  content.push(content_unit)
125
125
  end
@@ -132,7 +132,7 @@ module Runcible
132
132
  # @param [String, Array] ids array of consumer ids
133
133
  # @return [RestClient::Response]
134
134
  def regenerate_applicability_by_ids(ids)
135
- criteria = {
135
+ criteria = {
136
136
  'consumer_criteria' => { 'filters' => { 'id' => { '$in' => ids } } }
137
137
  }
138
138
  regenerate_applicability(criteria)
@@ -149,7 +149,7 @@ module Runcible
149
149
  def applicable_errata(ids)
150
150
  ids = [ids] if ids.is_a? String
151
151
 
152
- criteria = {
152
+ criteria = {
153
153
  'criteria' => { 'filters' => { 'id' => { '$in' => ids } } },
154
154
  'content_types' => [Runcible::Extensions::Errata.content_type]
155
155
  }
@@ -0,0 +1,9 @@
1
+ module Runcible
2
+ module Extensions
3
+ class File < Runcible::Extensions::Unit
4
+ def self.content_type
5
+ 'iso'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -31,20 +31,18 @@ module Runcible
31
31
  # @param [Hash] optional container for all optional parameters
32
32
  # @return [RestClient::Response] the created repository
33
33
  def create_with_importer_and_distributors(id, importer, distributors = [], optional = {})
34
- if importer.is_a?(Runcible::Models::Importer)
34
+ if importer && importer.is_a?(Runcible::Models::Importer)
35
35
  optional[:importer_type_id] = importer.id
36
36
  optional[:importer_config] = importer.config
37
- else
37
+ elsif importer
38
38
  optional[:importer_type_id] = importer.delete('id') || importer.delete(:id)
39
39
  optional[:importer_config] = importer
40
- end if importer
40
+ end
41
41
 
42
42
  repo_type = if importer.methods.include?(:repo_type)
43
43
  importer.repo_type
44
44
  elsif importer.is_a?(Hash) && importer.key?(:repo_type)
45
45
  importer[:repo_type]
46
- else
47
- nil
48
46
  end
49
47
 
50
48
  if optional.key?(:importer_type_id) && repo_type
@@ -326,7 +324,27 @@ module Runcible
326
324
  # the [{:image_id => <image hash>, :tag =>"value"}]
327
325
  # @return [RestClient::Response]
328
326
  def update_docker_tags(id, tags)
329
- update(id, :scratchpad => {:tags => tags})
327
+ update(id, :scratchpad => {:tags => tags})
328
+ end
329
+
330
+ # Retrieves the file IDs for a single repository
331
+ #
332
+ # @param [String] id the ID of the repository
333
+ # @return [RestClient::Response] the set of repository file IDs
334
+ def file_ids(id)
335
+ criteria = {:type_ids => [Runcible::Extensions::File.content_type],
336
+ :fields => {:unit => [], :association => ['unit_id']}}
337
+
338
+ unit_search(id, criteria).map { |i| i['unit_id'] }
339
+ end
340
+
341
+ # Retrieves the files for a single repository
342
+ #
343
+ # @param [String] id the ID of the repository
344
+ # @return [RestClient::Response] the set of repository files
345
+ def files(id)
346
+ criteria = {:type_ids => [Runcible::Extensions::File.content_type]}
347
+ unit_search(id, criteria).map { |i| i['metadata'].with_indifferent_access }
330
348
  end
331
349
 
332
350
  # Creates or updates a sync schedule for a repository
@@ -387,7 +405,7 @@ module Runcible
387
405
  # False is the default option.
388
406
  # @return [RestClient::Response]
389
407
  def regenerate_applicability_by_ids(ids, parallel = false)
390
- criteria = {
408
+ criteria = {
391
409
  'parallel' => parallel,
392
410
  'repo_criteria' => { 'filters' => { 'id' => { '$in' => ids } } }
393
411
  }
@@ -1,16 +1,5 @@
1
1
  module Runcible
2
2
  class Instance
3
- # rubocop:disable Style/ClassVars
4
- def self.resource_classes
5
- @@resource_classes ||= gather_classes('resources')
6
- @@resource_classes
7
- end
8
-
9
- def self.extension_classes
10
- @@extension_classes ||= gather_classes('extensions')
11
- @@extension_classes
12
- end
13
-
14
3
  attr_accessor :resources
15
4
  attr_accessor :extensions
16
5
 
@@ -50,6 +39,29 @@ module Runcible
50
39
 
51
40
  attr_reader :config
52
41
 
42
+ class << self
43
+ # rubocop:disable Style/ClassVars
44
+ def resource_classes
45
+ @@resource_classes ||= gather_classes('resources')
46
+ @@resource_classes
47
+ end
48
+
49
+ def extension_classes
50
+ @@extension_classes ||= gather_classes('extensions')
51
+ @@extension_classes
52
+ end
53
+
54
+ private
55
+
56
+ def gather_classes(type)
57
+ const = Runcible
58
+ const = const.const_get(type.camelize)
59
+ path = File.dirname(__FILE__) + "/#{type}/*.rb"
60
+ base_names = Dir.glob(path).map { |f| File.basename(f, '.rb') }
61
+ base_names.map { |name| const.const_get(name.camelize) }
62
+ end
63
+ end
64
+
53
65
  private
54
66
 
55
67
  def initialize_wrappers
@@ -72,14 +84,6 @@ module Runcible
72
84
  # (e.g. consumer_group)
73
85
  class_object.name.split('::').last.underscore
74
86
  end
75
-
76
- def self.gather_classes(type)
77
- const = Runcible
78
- const = const.const_get(type.camelize)
79
- path = File.dirname(__FILE__) + "/#{type}/*.rb"
80
- base_names = Dir.glob(path).map { |f| File.basename(f, '.rb') }
81
- base_names.map { |name| const.const_get(name.camelize) }
82
- end
83
87
  end
84
88
 
85
89
  #Wrapper class to provide access to instances
@@ -6,7 +6,7 @@ module Runcible
6
6
  class DockerDistributor < Distributor
7
7
  #optional attributes
8
8
  attr_accessor 'docker_publish_directory', 'protected',
9
- 'redirect_url', 'repo_registry_id'
9
+ 'redirect_url', 'repo_registry_id'
10
10
 
11
11
  def initialize(params = {})
12
12
  super(params)
@@ -1,8 +1,8 @@
1
1
  module Runcible
2
2
  module Models
3
3
  class DockerImporter < Importer
4
- ID = 'docker_importer'
5
- REPO_TYPE = 'docker-repo'
4
+ ID = 'docker_importer'.freeze
5
+ REPO_TYPE = 'docker-repo'.freeze
6
6
 
7
7
  attr_accessor 'upstream_name', 'mask_id', 'enable_v1'
8
8
 
@@ -1,7 +1,7 @@
1
1
  module Runcible
2
2
  module Models
3
3
  class IsoImporter < Importer
4
- ID = 'iso_importer'
4
+ ID = 'iso_importer'.freeze
5
5
 
6
6
  # Importer Type id
7
7
  #
@@ -1,8 +1,8 @@
1
1
  module Runcible
2
2
  module Models
3
3
  class OstreeImporter < Importer
4
- ID = 'ostree_web_importer'
5
- REPO_TYPE = 'OSTREE'
4
+ ID = 'ostree_web_importer'.freeze
5
+ REPO_TYPE = 'OSTREE'.freeze
6
6
 
7
7
  attr_accessor 'branches'
8
8
 
@@ -1,8 +1,8 @@
1
1
  module Runcible
2
2
  module Models
3
3
  class PuppetImporter < Importer
4
- ID = 'puppet_importer'
5
- REPO_TYPE = 'puppet-repo'
4
+ ID = 'puppet_importer'.freeze
5
+ REPO_TYPE = 'puppet-repo'.freeze
6
6
 
7
7
  attr_accessor 'queries'
8
8
 
@@ -1,8 +1,8 @@
1
1
  module Runcible
2
2
  module Models
3
3
  class PythonImporter < Importer
4
- ID = 'python_importer'
5
- REPO_TYPE = 'python-repo'
4
+ ID = 'python_importer'.freeze
5
+ REPO_TYPE = 'python-repo'.freeze
6
6
 
7
7
  attr_accessor 'packages_names'
8
8
 
@@ -1,11 +1,11 @@
1
1
  module Runcible
2
2
  module Models
3
3
  class YumImporter < Importer
4
- ID = 'yum_importer'
5
- REPO_TYPE = 'rpm-repo'
6
- DOWNLOAD_IMMEDIATE = 'immediate'
7
- DOWNLOAD_ON_DEMAND = 'on_demand'
8
- DOWNLOAD_BACKGROUND = 'background'
4
+ ID = 'yum_importer'.freeze
5
+ REPO_TYPE = 'rpm-repo'.freeze
6
+ DOWNLOAD_IMMEDIATE = 'immediate'.freeze
7
+ DOWNLOAD_ON_DEMAND = 'on_demand'.freeze
8
+ DOWNLOAD_BACKGROUND = 'background'.freeze
9
9
  DOWNLOAD_POLICIES = [DOWNLOAD_IMMEDIATE, DOWNLOAD_ON_DEMAND, DOWNLOAD_BACKGROUND].freeze
10
10
 
11
11
  attr_accessor 'download_policy'
@@ -7,7 +7,7 @@ module Runcible
7
7
  # @param [String] id the ID of the consumer
8
8
  # @return [String] the consumer path, may contain the id if passed
9
9
  def self.path(id = nil)
10
- (id.nil?) ? 'consumers/' : "consumers/#{id}/"
10
+ id.nil? ? 'consumers/' : "consumers/#{id}/"
11
11
  end
12
12
 
13
13
  # Creates a consumer
@@ -9,7 +9,7 @@ module Runcible
9
9
  # @param [String] upload_id the id of the upload_request
10
10
  # @return [String] the content path, may contain the upload_id if passed
11
11
  def upload_path(upload_id = nil)
12
- (upload_id.nil?) ? 'content/uploads/' : "content/uploads/#{upload_id}/"
12
+ upload_id.nil? ? 'content/uploads/' : "content/uploads/#{upload_id}/"
13
13
  end
14
14
 
15
15
  # Creates an Upload Request
@@ -3,14 +3,14 @@ module Runcible
3
3
  # @see https://pulp-dev-guide.readthedocs.org/en/latest/events/index.html
4
4
  class EventNotifier < Runcible::Base
5
5
  class EventTypes
6
- REPO_SYNC_COMPLETE = 'repo.sync.finish'
7
- REPO_SYNC_START = 'repo.sync.start'
8
- REPO_PUBLISH_COMPLETE = 'repo.publish.finish'
9
- REPO_PUBLISH_START = 'repo.publish.start'
6
+ REPO_SYNC_COMPLETE = 'repo.sync.finish'.freeze
7
+ REPO_SYNC_START = 'repo.sync.start'.freeze
8
+ REPO_PUBLISH_COMPLETE = 'repo.publish.finish'.freeze
9
+ REPO_PUBLISH_START = 'repo.publish.start'.freeze
10
10
  end
11
11
 
12
12
  class NotifierTypes
13
- REST_API = 'http'
13
+ REST_API = 'http'.freeze
14
14
  end
15
15
 
16
16
  # Generates the API path for Event Notifiers
@@ -18,7 +18,7 @@ module Runcible
18
18
  # @param [String] id the ID of the event notifier
19
19
  # @return [String] the event notifier path, may contain the ID if passed
20
20
  def self.path(id = nil)
21
- (id.nil?) ? 'events/' : "events/#{id}/"
21
+ id.nil? ? 'events/' : "events/#{id}/"
22
22
  end
23
23
 
24
24
  # Creates an Event Notification
@@ -9,7 +9,7 @@ module Runcible
9
9
  # @param [String] id the id of the repository
10
10
  # @return [String] the repository path, may contain the id if passed
11
11
  def self.path(id = nil)
12
- (id.nil?) ? 'repositories/' : "repositories/#{id}/"
12
+ id.nil? ? 'repositories/' : "repositories/#{id}/"
13
13
  end
14
14
 
15
15
  # Creates a repository
@@ -13,7 +13,7 @@ module Runcible
13
13
  def self.path(repo_id, importer_id, schedule_id = nil)
14
14
  repo_path = Runcible::Resources::Repository.path(repo_id)
15
15
  path = "#{repo_path}importers/#{importer_id}/schedules/sync/"
16
- (schedule_id.nil?) ? path : "#{path}#{schedule_id}/"
16
+ schedule_id.nil? ? path : "#{path}#{schedule_id}/"
17
17
  end
18
18
 
19
19
  # List the schedules for a repository for a given importer type
@@ -7,7 +7,7 @@ module Runcible
7
7
  # @param [String] id the ID of the role
8
8
  # @return [String] the role path, may contain the ID if passed
9
9
  def self.path(id = nil)
10
- (id.nil?) ? 'roles/' : "roles/#{id}/"
10
+ id.nil? ? 'roles/' : "roles/#{id}/"
11
11
  end
12
12
 
13
13
  # Adds a user to a role
@@ -7,7 +7,7 @@ module Runcible
7
7
  # @param [String] id the id of the task
8
8
  # @return [String] the task path, may contain the id if passed
9
9
  def self.path(id = nil)
10
- (id.nil?) ? 'tasks/' : "tasks/#{id}/"
10
+ id.nil? ? 'tasks/' : "tasks/#{id}/"
11
11
  end
12
12
 
13
13
  # Polls for the status of a task
@@ -7,7 +7,7 @@ module Runcible
7
7
  # @param [String] id the id of the task
8
8
  # @return [String] the task path, may contain the id if passed
9
9
  def self.path(id = nil)
10
- (id.nil?) ? 'task_groups/' : "task_groups/#{id}/"
10
+ id.nil? ? 'task_groups/' : "task_groups/#{id}/"
11
11
  end
12
12
 
13
13
  def self.summary_path(id)
@@ -7,7 +7,7 @@ module Runcible
7
7
  # @param [String] login the user's login
8
8
  # @return [String] the user path, may contain the login if passed
9
9
  def self.path(login = nil)
10
- (login.nil?) ? 'users/' : "users/#{login}/"
10
+ login.nil? ? 'users/' : "users/#{login}/"
11
11
  end
12
12
 
13
13
  # Retrieves all users
@@ -1,3 +1,3 @@
1
1
  module Runcible
2
- VERSION = '1.7.2'
2
+ VERSION = '1.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runcible
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric D Helms, Justin Sherrill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-18 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -135,6 +135,7 @@ files:
135
135
  - lib/runcible/extensions/docker_manifest.rb
136
136
  - lib/runcible/extensions/docker_tag.rb
137
137
  - lib/runcible/extensions/errata.rb
138
+ - lib/runcible/extensions/file.rb
138
139
  - lib/runcible/extensions/ostree_branch.rb
139
140
  - lib/runcible/extensions/package_category.rb
140
141
  - lib/runcible/extensions/package_group.rb
@@ -196,8 +197,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
197
  version: '0'
197
198
  requirements: []
198
199
  rubyforge_project:
199
- rubygems_version: 2.2.5
200
+ rubygems_version: 2.4.6
200
201
  signing_key:
201
202
  specification_version: 4
202
203
  summary: ''
203
204
  test_files: []
205
+ has_rdoc: