katello 3.7.1.1 → 3.8.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -7
  3. data/app/assets/javascripts/katello/common/index.js +0 -1
  4. data/app/assets/javascripts/katello/sync_management/index.js +0 -1
  5. data/app/controllers/katello/api/registry/registry_proxies_controller.rb +477 -0
  6. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +1 -1
  7. data/app/controllers/katello/api/v2/activation_keys_controller.rb +2 -2
  8. data/app/controllers/katello/api/v2/api_controller.rb +3 -1
  9. data/app/controllers/katello/api/v2/content_credentials_controller.rb +1 -1
  10. data/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb +1 -1
  11. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +15 -1
  12. data/app/controllers/katello/api/v2/environments_controller.rb +5 -2
  13. data/app/controllers/katello/api/v2/errata_controller.rb +48 -34
  14. data/app/controllers/katello/api/v2/gpg_keys_controller.rb +1 -1
  15. data/app/controllers/katello/api/v2/host_collections_controller.rb +1 -1
  16. data/app/controllers/katello/api/v2/host_packages_controller.rb +5 -1
  17. data/app/controllers/katello/api/v2/organizations_controller.rb +1 -1
  18. data/app/controllers/katello/api/v2/packages_controller.rb +33 -22
  19. data/app/controllers/katello/api/v2/products_controller.rb +1 -1
  20. data/app/controllers/katello/api/v2/repositories_controller.rb +6 -5
  21. data/app/controllers/katello/api/v2/repository_sets_controller.rb +1 -10
  22. data/app/controllers/katello/api/v2/sync_plans_controller.rb +1 -1
  23. data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +20 -12
  24. data/app/controllers/katello/remote_execution_controller.rb +6 -6
  25. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +9 -37
  26. data/app/lib/actions/katello/content_view/promote.rb +6 -2
  27. data/app/lib/actions/katello/content_view_version/after_promote_hook.rb +11 -0
  28. data/app/lib/actions/katello/content_view_version/before_promote_hook.rb +11 -0
  29. data/app/lib/actions/katello/host/remove_subscriptions.rb +1 -1
  30. data/app/lib/actions/pulp/consumer/abstract_content_action.rb +0 -12
  31. data/app/lib/actions/pulp/consumer/content_install.rb +1 -1
  32. data/app/lib/actions/pulp/consumer/content_uninstall.rb +1 -1
  33. data/app/lib/actions/pulp/consumer/content_update.rb +1 -1
  34. data/app/lib/katello/resources/registry.rb +40 -0
  35. data/app/lib/katello/util/package.rb +9 -4
  36. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +1 -1
  37. data/app/models/katello/content_view.rb +4 -12
  38. data/app/models/katello/content_view_version.rb +26 -0
  39. data/app/models/katello/glue/candlepin/owner.rb +8 -0
  40. data/app/models/katello/glue/candlepin/pool.rb +11 -11
  41. data/app/models/katello/glue/candlepin/repository.rb +1 -1
  42. data/app/models/katello/glue/pulp/repos.rb +1 -0
  43. data/app/models/katello/host/content_facet.rb +1 -2
  44. data/app/models/katello/kt_environment.rb +6 -0
  45. data/app/models/katello/product_content.rb +1 -4
  46. data/app/models/katello/repository.rb +2 -0
  47. data/app/models/katello/rpm.rb +118 -14
  48. data/app/services/katello/puppet_class_importer_extensions.rb +17 -20
  49. data/app/services/katello/ui_notifications/pulp/proxy_disk_space.rb +1 -3
  50. data/app/views/katello/api/v2/common/copy.json.rabl +3 -0
  51. data/app/views/katello/api/v2/environments/show.json.rabl +1 -1
  52. data/app/views/katello/api/v2/repositories/base.json.rabl +1 -0
  53. data/app/views/katello/api/v2/repositories/show.json.rabl +4 -2
  54. data/app/views/overrides/activation_keys/_host_environment_select.html.erb +3 -2
  55. data/config/katello.yaml +89 -0
  56. data/config/routes.rb +0 -1
  57. data/config/routes/api/registry.rb +29 -0
  58. data/config/routes/api/v2.rb +1 -1
  59. data/db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb +0 -3
  60. data/db/migrate/20180614184822_add_unauthenticated_pull.rb +9 -0
  61. data/db/migrate/20180618195941_add_description_to_repository.rb +5 -0
  62. data/db/seeds.d/75-job_templates.rb +2 -5
  63. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-repository-sets-modal.controller.js +3 -4
  64. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-subscriptions-modal.controller.js +1 -4
  65. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-subscriptions-modal.html +1 -1
  66. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-host-register.controller.js +1 -1
  67. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-packages-installed.controller.js +1 -1
  68. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-add-subscriptions.controller.js +1 -1
  69. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.routes.js +1 -0
  70. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/content-view-version.controller.js +32 -18
  71. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/views/content-view-version-details.html +1 -1
  72. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/views/content-view-version-docker.html +2 -0
  73. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/details/views/environment-details.html +32 -23
  74. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +6 -0
  75. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +8 -0
  76. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/discovery/discovery.controller.js +1 -1
  77. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/discovery/views/discovery-create.html +1 -1
  78. data/engines/bastion_katello/app/assets/stylesheets/bastion_katello/bastion_katello.scss +0 -5
  79. data/lib/katello/engine.rb +1 -0
  80. data/lib/katello/permission_creator.rb +2 -0
  81. data/lib/katello/permissions/registry_permissions.rb +20 -0
  82. data/lib/katello/plugin.rb +1 -0
  83. data/lib/katello/tasks/clean_backend_objects.rake +3 -12
  84. data/lib/katello/version.rb +1 -1
  85. data/package.json +7 -10
  86. data/webpack/components/Search/Search.test.js +1 -3
  87. data/webpack/containers/Application/config.js +2 -9
  88. data/webpack/containers/Application/index.js +2 -4
  89. data/webpack/mockRequest.js +3 -3
  90. data/webpack/move_to_foreman/common/helpers.js +8 -45
  91. data/webpack/move_to_foreman/components/common/{EmptyState → emptyState}/index.js +3 -16
  92. data/webpack/move_to_foreman/components/common/table/components/Table.js +1 -1
  93. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/CollapseSubscriptionGroupButton.test.js.snap +2 -2
  94. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/TableSelectionCell.test.js.snap +1 -1
  95. data/webpack/move_to_foreman/components/common/table/components/__snapshots__/TableSelectionHeaderCell.test.js.snap +1 -1
  96. data/webpack/move_to_pf/LoadingState/LoadingState.js +14 -27
  97. data/webpack/move_to_pf/LoadingState/LoadingState.test.js +4 -8
  98. data/webpack/move_to_pf/react-bootstrap-select/index.js +1 -12
  99. data/webpack/redux/actions/RedHatRepositories/enabled.js +1 -0
  100. data/webpack/redux/actions/RedHatRepositories/helpers.js +5 -5
  101. data/webpack/redux/actions/RedHatRepositories/sets.js +1 -1
  102. data/webpack/redux/consts.js +0 -6
  103. data/webpack/redux/reducers/index.js +0 -2
  104. data/webpack/scenes/RedHatRepositories/components/EnabledRepository.js +23 -14
  105. data/webpack/scenes/RedHatRepositories/components/RepositorySetRepository.js +1 -1
  106. data/webpack/scenes/RedHatRepositories/components/SearchBar.js +0 -1
  107. data/webpack/scenes/RedHatRepositories/components/__tests__/__snapshots__/RecommendedRepositorySetsToggler.test.js.snap +1 -3
  108. data/webpack/scenes/RedHatRepositories/index.js +3 -7
  109. data/webpack/scenes/RedHatRepositories/index.scss +0 -1
  110. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailActions.js +8 -3
  111. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailReducer.js +1 -30
  112. data/webpack/scenes/Subscriptions/Details/SubscriptionDetails.js +28 -111
  113. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailReducer.test.js +1 -3
  114. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetails.test.js +1 -6
  115. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetails.test.js.snap +424 -519
  116. data/webpack/scenes/Subscriptions/Details/__tests__/subscriptionDetails.fixtures.js +4 -7
  117. data/webpack/scenes/Subscriptions/Details/index.js +3 -5
  118. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +34 -78
  119. data/webpack/scenes/Subscriptions/Manifest/ManifestActions.js +24 -5
  120. data/webpack/scenes/Subscriptions/Manifest/ManifestHistoryReducer.js +1 -9
  121. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManageManifestModal.test.js +0 -3
  122. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManifestActions.test.js +8 -20
  123. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManifestHistoryReducer.test.js +1 -3
  124. data/webpack/scenes/Subscriptions/Manifest/__tests__/__snapshots__/ManageManifestModal.test.js.snap +7 -34
  125. data/webpack/scenes/Subscriptions/Manifest/__tests__/manifest.fixtures.js +16 -9
  126. data/webpack/scenes/Subscriptions/Manifest/index.js +0 -1
  127. data/webpack/scenes/Subscriptions/SubscriptionActions.js +26 -5
  128. data/webpack/scenes/Subscriptions/SubscriptionConstants.js +0 -1
  129. data/webpack/scenes/Subscriptions/SubscriptionHelpers.js +0 -3
  130. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +4 -11
  131. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +36 -31
  132. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js +12 -3
  133. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +27 -57
  134. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js +3 -2
  135. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsTableSchema.js +5 -10
  136. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsActions.test.js +5 -10
  137. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsPage.test.js +4 -49
  138. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js +3 -8
  139. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +11 -21
  140. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/upstreamSubscriptions.fixtures.js +8 -5
  141. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +0 -2
  142. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsReducer.test.js +3 -9
  143. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +2 -14
  144. data/webpack/scenes/Subscriptions/__tests__/subscriptions.fixtures.js +17 -11
  145. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/EntitlementsInlineEditFormatter.js +5 -8
  146. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTable.js +58 -45
  147. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js +4 -11
  148. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableSchema.js +2 -2
  149. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.test.js +3 -16
  150. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +365 -392
  151. data/webpack/scenes/Subscriptions/index.js +0 -1
  152. data/webpack/services/api/fixtures.js +353 -0
  153. data/webpack/services/api/index.js +1 -17
  154. data/webpack/test_setup.js +0 -2
  155. metadata +16 -37
  156. data/config/katello.yml +0 -59
  157. data/webpack/__mocks__/foremanReact/components/BreadcrumbBar.js +0 -3
  158. data/webpack/__mocks__/foremanReact/redux.js +0 -3
  159. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +0 -8
  160. data/webpack/components/SelectOrg/SelectOrg.scss +0 -3
  161. data/webpack/components/SelectOrg/SelectOrgAction.js +0 -41
  162. data/webpack/components/SelectOrg/SelectOrgReducer.js +0 -33
  163. data/webpack/components/SelectOrg/SetOrganization.js +0 -116
  164. data/webpack/components/WithOrganization/withOrganization.js +0 -28
  165. data/webpack/global_test_setup.js +0 -6
  166. data/webpack/helpers/caret.js +0 -6
  167. data/webpack/move_to_pf/Select/Select.js +0 -40
  168. data/webpack/scenes/Products/ProductActions.js +0 -24
  169. data/webpack/scenes/Products/ProductConstants.js +0 -3
  170. data/webpack/scenes/Products/__tests__/ProductActions.test.js +0 -40
  171. data/webpack/scenes/Products/__tests__/products.fixtures.js +0 -90
  172. data/webpack/scenes/RedHatRepositories/components/EnabledRepositoryContent.js +0 -34
  173. data/webpack/scenes/RedHatRepositories/components/__tests__/EnabledRepository.test.js +0 -36
  174. data/webpack/scenes/RedHatRepositories/components/__tests__/EnabledRepositoryContent.test.js +0 -27
  175. data/webpack/scenes/RedHatRepositories/components/__tests__/__snapshots__/EnabledRepository.test.js.snap +0 -25
  176. data/webpack/scenes/RedHatRepositories/components/__tests__/__snapshots__/EnabledRepositoryContent.test.js.snap +0 -47
  177. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailEnabledProducts.js +0 -54
  178. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailProduct.js +0 -29
  179. data/webpack/scenes/Subscriptions/Details/SubscriptionDetails.scss +0 -9
  180. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailEnabledProducts.test.js +0 -18
  181. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailProduct.test.js +0 -13
  182. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetailEnabledProducts.test.js.snap +0 -45
  183. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetailProduct.test.js.snap +0 -67
  184. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/EntitlementsInlineEditFormatter.test.js +0 -110
  185. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/EntitlementsInlineEditFormatter.test.js.snap +0 -228
  186. data/webpack/scenes/Tasks/helpers.js +0 -52
  187. data/webpack/services/api/testHelpers.js +0 -28
@@ -278,7 +278,7 @@ module Katello
278
278
  def get_parent_host(headers)
279
279
  hostnames = headers["HTTP_X_FORWARDED_SERVER"]
280
280
  host = hostnames.split(",")[0] if hostnames
281
- host || Facter.value(:fqdn) || SETTINGS[:fqdn]
281
+ host || SETTINGS[:fqdn]
282
282
  end
283
283
 
284
284
  private
@@ -44,7 +44,7 @@ module Katello
44
44
  end
45
45
  sync_task(::Actions::Katello::ActivationKey::Create, @activation_key)
46
46
  @activation_key.reload
47
- respond(:resource => @activation_key)
47
+ respond_for_create(:resource => @activation_key)
48
48
  end
49
49
 
50
50
  api :PUT, "/activation_keys/:id", N_("Update an activation key")
@@ -98,7 +98,7 @@ module Katello
98
98
  @new_activation_key.subscribe(pool[:id])
99
99
  end
100
100
  @new_activation_key.set_content_overrides(@activation_key.content_overrides) unless @activation_key.content_overrides.blank?
101
- respond_for_show(:resource => @new_activation_key)
101
+ respond_for_create(:resource => @new_activation_key)
102
102
  end
103
103
 
104
104
  api :GET, "/activation_keys/:id/host_collections/available", N_("List host collections the activation key does not belong to")
@@ -20,7 +20,7 @@ module Katello
20
20
  param :search, String, :desc => N_("Search string")
21
21
  param :page, :number, :desc => N_("Page number, starting at 1")
22
22
  param :per_page, :number, :desc => N_("Number of results per page to return")
23
- param :order, String, :desc => N_("Sort field and order, eg. 'name DESC'")
23
+ param :order, String, :desc => N_("Sort field and order, eg. 'id DESC'")
24
24
  param :full_result, :bool, :desc => N_("Whether or not to show all results")
25
25
  param :sort, Hash, :desc => N_("Hash version of 'order' param") do
26
26
  param :by, String, :desc => N_("Field to sort the results on")
@@ -77,6 +77,8 @@ module Katello
77
77
  query = resource.search_for(*search_options).where("#{resource.table_name}.id" => query)
78
78
  end
79
79
 
80
+ query = self.final_custom_index_relation(query) if self.respond_to?(:final_custom_index_relation)
81
+
80
82
  query = query.select(group).group(group) if group
81
83
  sub_total = total.zero? ? 0 : scoped_search_total(query, group)
82
84
 
@@ -56,7 +56,7 @@ module Katello
56
56
  end
57
57
 
58
58
  content_credential = @organization.gpg_keys.create!(content_credential_params.merge(:content => content))
59
- respond_for_show(:resource => content_credential)
59
+ respond_for_create(:resource => content_credential)
60
60
  end
61
61
 
62
62
  api :GET, "/content_credentials/:id", N_("Show a content credential")
@@ -49,7 +49,7 @@ module Katello
49
49
  if rules.many?
50
50
  respond_for_index(:collection => {:results => rules}, :template => 'index')
51
51
  else
52
- respond resource: rules.first
52
+ respond_for_create resource: rules.first
53
53
  end
54
54
  end
55
55
 
@@ -3,7 +3,7 @@ module Katello
3
3
  include Concerns::Api::V2::BulkHostsExtensions
4
4
  include Katello::Concerns::FilteredAutoCompleteSearch
5
5
 
6
- before_action :find_content_view_version, :only => [:show, :promote, :destroy, :export, :republish_repositories]
6
+ before_action :find_content_view_version, :only => [:show, :update, :promote, :destroy, :export, :republish_repositories]
7
7
  before_action :find_content_view, :except => [:incremental_update]
8
8
  before_action :find_environment, :only => [:index]
9
9
  before_action :find_environments, :only => [:promote]
@@ -65,6 +65,20 @@ module Katello
65
65
  respond_for_async :resource => task
66
66
  end
67
67
 
68
+ api :PUT, "/content_view_versions/:id", N_("Update a content view version.")
69
+ param :id, :number, :desc => N_("Content view version identifier"), :required => true
70
+ param :description, String, :desc => N_("The description for the content view version"), :required => true
71
+ def update
72
+ history = @version.history.publish.successful.first
73
+ if history.blank?
74
+ fail HttpErrors::BadRequest, _("This content view version doesn't have a history.")
75
+ else
76
+ history.notes = params[:description]
77
+ history.save!
78
+ respond_for_show(:resource => @version)
79
+ end
80
+ end
81
+
68
82
  api :PUT, "/content_view_versions/:id/republish_repositories", N_("Forces a republish of the version's repositories' metadata.")
69
83
  param :id, :number, :desc => N_("Content view version identifier"), :required => true
70
84
  def republish_repositories
@@ -76,6 +76,7 @@ module Katello
76
76
  param :label, String, :desc => N_("label of the environment"), :required => false
77
77
  param :description, String, :desc => N_("description of the environment")
78
78
  param :registry_name_pattern, String, :desc => N_("pattern for container image names")
79
+ param :registry_unauthenticated_pull, :bool, :desc => N_("allow unauthenticed pull of container images")
79
80
  param :prior_id, Integer, :required => true, :desc => <<-DESC
80
81
  ID of an environment that is prior to the new environment in the chain. It has to be
81
82
  either the ID of Library or the ID of an environment at the end of a chain.
@@ -95,6 +96,7 @@ module Katello
95
96
  param :new_name, String, :desc => N_("new name to be given to the environment")
96
97
  param :description, String, :desc => N_("description of the environment")
97
98
  param :registry_name_pattern, String, :desc => N_("pattern for container image names")
99
+ param :registry_unauthenticated_pull, :bool, :desc => N_("allow unauthenticed pull of container images")
98
100
  param :async, :bool, desc: N_("Do not wait for the update action to finish. Default: true")
99
101
  def update
100
102
  async = ::Foreman::Cast.to_bool(params.fetch(:async, true))
@@ -102,6 +104,7 @@ module Katello
102
104
  fail HttpErrors::BadRequest, _("Can't update the '%s' environment") % "Library" if @environment.library? && update_params.empty?
103
105
  update_params[:name] = params[:environment][:new_name] if params[:environment][:new_name]
104
106
  @environment.update_attributes!(update_params)
107
+ @environment.update_container_repositories(update_params[:registry_unauthenticated_pull]) if update_params.key? :registry_unauthenticated_pull
105
108
  if update_params[:registry_name_pattern]
106
109
  task = send(async ? :async_task : :sync_task, ::Actions::Katello::Environment::PublishRepositories,
107
110
  @environment, content_type: Katello::Repository::DOCKER_TYPE)
@@ -175,9 +178,9 @@ module Katello
175
178
 
176
179
  def environment_params
177
180
  if @environment && @environment.library?
178
- attrs = [:registry_name_pattern]
181
+ attrs = [:registry_name_pattern, :registry_unauthenticated_pull]
179
182
  else
180
- attrs = [:name, :description, :registry_name_pattern]
183
+ attrs = [:name, :description, :registry_name_pattern, :registry_unauthenticated_pull]
181
184
  end
182
185
  attrs << :label if params[:action] == "create"
183
186
  parms = params.require(:environment).permit(*attrs)
@@ -3,21 +3,31 @@ module Katello
3
3
  apipie_concern_subst(:a_resource => N_("an erratum"), :resource => "errata")
4
4
  include Katello::Concerns::Api::V2::RepositoryContentController
5
5
 
6
+ before_action :find_host, :only => [:index, :available_errata]
7
+ before_action :find_optional_organization, :only => :available_errata
8
+ before_action :find_environment, :only => :available_errata
9
+ before_action :find_filter, :only => :available_errata
10
+
6
11
  api :GET, "/errata", N_("List errata")
7
- param :organization_id, :number, :desc => N_("organization identifier")
8
- param :content_view_version_id, :number, :desc => N_("content view version identifier")
9
- param :content_view_filter_id, :number, :desc => N_("content view filter identifier")
10
- param :repository_id, :number, :desc => N_("repository identifier")
11
- param :environment_id, :number, :desc => N_("environment identifier")
12
+ param :organization_id, :number, :desc => N_("Organization identifier")
13
+ param :content_view_version_id, :number, :desc => N_("Content View Version identifier")
14
+ param :content_view_filter_id, :number, :desc => N_("Content View Filter identifier")
15
+ param :repository_id, :number, :desc => N_("Repository identifier")
16
+ param :environment_id, :number, :desc => N_("Environment identifier")
12
17
  param :cve, String, :desc => N_("CVE identifier")
13
- param :errata_restrict_applicable, :bool, :desc => N_("show only errata with one or more applicable hosts")
14
- param :errata_restrict_installable, :bool, :desc => N_("show only errata with one or more installable hosts")
18
+ param :host_id, :number, :desc => N_("Host id to list applicable errata for")
19
+ param :errata_restrict_applicable, :bool, :desc => N_("Return errata that are applicable to one or more hosts (defaults to true if host_id is specified)")
20
+ param :errata_restrict_installable, :bool, :desc => N_("Return errata that are upgradable on one or more hosts")
21
+ param :available_for, String, :desc => N_("Return errata that can be added to the specified object. The values 'content_view_version' and 'content_view_filter are supported.")
15
22
  param_group :search, Api::V2::ApiController
16
23
  def index
17
- params[:errata_restrict_applicable] = false if ::Foreman::Cast.to_bool(params[:errata_restrict_installable])
18
24
  super
19
25
  end
20
26
 
27
+ def available_for_content_view_version(version)
28
+ version.available_errata
29
+ end
30
+
21
31
  def available_for_content_view_filter(filter, collection)
22
32
  collection = filter_by_content_view(filter, collection)
23
33
  ids = Katello::ContentViewErratumFilterRule.where(:content_view_filter_id => filter.id).pluck("errata_id")
@@ -37,44 +47,48 @@ module Katello
37
47
 
38
48
  def custom_index_relation(collection)
39
49
  collection = filter_by_cve(params[:cve], collection) if params[:cve]
40
- hosts = ::Host::Managed.authorized("view_hosts")
41
- hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
42
- if ::Foreman::Cast.to_bool(params[:errata_restrict_applicable])
43
- collection = collection.where(:id => Erratum.applicable_to_hosts(hosts))
44
- end
45
-
46
- if ::Foreman::Cast.to_bool(params[:errata_restrict_installable])
47
- collection = collection.where(:id => Erratum.ids_installable_for_hosts(hosts))
50
+ applicable = ::Foreman::Cast.to_bool(params[:errata_restrict_applicable]) || @host
51
+ installable = ::Foreman::Cast.to_bool(params[:errata_restrict_installable])
52
+ if applicable || installable
53
+ hosts = @host ? [@host] : ::Host::Managed.authorized("view_hosts")
54
+ hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
55
+ if installable
56
+ collection = collection.where(:id => Erratum.ids_installable_for_hosts(hosts))
57
+ elsif applicable
58
+ collection = collection.applicable_to_hosts(hosts)
59
+ end
48
60
  end
49
61
  collection
50
62
  end
51
63
 
52
- api :GET, "/content_view_versions/:id/available_errata", N_("List errata that can be added to the Content View Version via an Incremental Update")
64
+ api :GET, "/content_view_versions/:id/available_errata", N_("Return errata that can be added to the Content View Version via an Incremental Update"), :deprecated => true
53
65
  param :id, :number, :desc => N_("Content View Version identifier"), :required => true
54
- param :repository_id, :number, :desc => N_("repository identifier")
66
+ param :organization_id, :number, :desc => N_("Organization identifier")
67
+ param :content_view_filter_id, :number, :desc => N_("Content View Filter identifier")
68
+ param :repository_id, :number, :desc => N_("Repository identifier")
69
+ param :environment_id, :number, :desc => N_("Environment identifier")
55
70
  param :cve, String, :desc => N_("CVE identifier")
56
- param :errata_restrict_applicable, :bool, :desc => N_("show only errata with one or more applicable hosts")
57
- param_group :search, ::Katello::Api::V2::ApiController
71
+ param :host_id, :number, :desc => N_("Host id to list applicable errata for")
72
+ param :errata_restrict_applicable, :bool, :desc => N_("Return errata that are applicable to one or more hosts (defaults to true if host_id is specified)")
73
+ param :errata_restrict_installable, :bool, :desc => N_("Return errata that are upgradable on one or more hosts")
74
+ param_group :search, Api::V2::ApiController
58
75
  def available_errata
59
- version = ContentViewVersion.find(params[:id])
60
- collection = version.available_errata
61
- if @repo
62
- collection = collection.joins(:repository_errata => :repository).where(:katello_repositories => { :id => @repo })
63
- end
64
- if params[:cve]
65
- collection = collection.joins(:cves).where(:katello_erratum_cves => { :cve_id => params[:cve] })
66
- end
67
- if ::Foreman::Cast.to_bool(params[:errata_restrict_applicable])
68
- hosts = ::Host::Managed.authorized("view_hosts")
69
- collection = collection.applicable_to_hosts(hosts)
70
- end
76
+ params[:content_view_version_id] = params[:id]
77
+ find_content_view_version
78
+ params[:available_for] = "content_view_version"
71
79
  sort_by, sort_order, options = sort_options
72
- collection = scoped_search(collection, sort_by, sort_order, options)
73
- respond_for_index(:collection => collection)
80
+ respond_for_index(:collection => scoped_search(index_relation, sort_by, sort_order, options))
74
81
  end
75
82
 
76
83
  private
77
84
 
85
+ def find_host
86
+ if params[:host_id]
87
+ @host = ::Host::Managed.authorized("view_hosts").find_by(:id => params[:host_id])
88
+ fail HttpErrors::NotFound, _('Could not find a host with id %s') % params[:host_id] unless @host
89
+ end
90
+ end
91
+
78
92
  def filter_by_cve(cve, collection)
79
93
  collection.joins(:cves).where('katello_erratum_cves.cve_id' => cve)
80
94
  end
@@ -48,7 +48,7 @@ module Katello
48
48
  end
49
49
 
50
50
  gpg_key = @organization.gpg_keys.create!(gpg_key_params.merge(:content => content))
51
- respond_for_show(:resource => gpg_key)
51
+ respond_for_create(:resource => gpg_key)
52
52
  end
53
53
 
54
54
  api :GET, "/gpg_keys/:id", N_("Show a gpg key")
@@ -68,7 +68,7 @@ module Katello
68
68
  @host_collection = HostCollection.new(host_collection_params_with_host_ids)
69
69
  @host_collection.organization = @organization
70
70
  @host_collection.save!
71
- respond_for_show(:resource => @host_collection)
71
+ respond_for_create(:resource => @host_collection)
72
72
  end
73
73
 
74
74
  api :PUT, "/host_collections/:id", N_("Update a host collection")
@@ -102,9 +102,13 @@ module Katello
102
102
  @host = resource_finder(::Host::Managed.authorized(:view_hosts, ::Host::Managed), params[:host_id])
103
103
  end
104
104
 
105
+ def valid_package_name?(package_name)
106
+ package_name =~ /^[a-zA-Z0-9\-\.\_\+\,]+$/
107
+ end
108
+
105
109
  def validate_package_list_format(packages)
106
110
  packages.each do |package|
107
- unless package.is_a?(String) && ::Katello::Util::Package.valid_package_name_format(package).nil?
111
+ if !valid_package_name?(package) && !package.is_a?(Hash)
108
112
  fail HttpErrors::BadRequest, _("%s is not a valid package name") % package
109
113
  end
110
114
  end
@@ -78,7 +78,7 @@ module Katello
78
78
  @organization = Organization.new(resource_params)
79
79
  sync_task(::Actions::Katello::Organization::Create, @organization)
80
80
  @organization.reload
81
- respond_for_show :resource => @organization
81
+ respond_for_create :resource => @organization
82
82
  rescue => e
83
83
  process_resource_error(message: e.message)
84
84
  end
@@ -26,42 +26,53 @@ module Katello
26
26
  api :GET, "/content_views/:content_view_id/filters/:filter_id/:resource_id", N_("List :resource_id")
27
27
  api :GET, "/content_view_filters/:content_view_filter_id/:resource_id", N_("List :resource_id")
28
28
  api :GET, "/repositories/:repository_id/:resource_id", N_("List :resource_id")
29
- param :organization_id, :number, :desc => N_("organization identifier")
30
- param :content_view_version_id, :number, :desc => N_("content view version identifier")
31
- param :content_view_filter_id, :number, :desc => N_("content view filter identifier")
32
- param :repository_id, :number, :desc => N_("repository identifier")
33
- param :environment_id, :number, :desc => N_("environment identifier")
34
- param :ids, Array, :desc => N_("ids to filter content by")
35
- param :host_id, :number, :desc => N_("host id to list applicable packages for")
36
- param :packages_restrict_upgradable, :boolean, :desc => N_("Only show packages that are upgradable in the host(s) Content View.")
37
- param :packages_restrict_applicable, :boolean, :desc => N_("Only show packages that are applicable to hosts (defaults to true if host_id is specified)")
29
+ param :organization_id, :number, :desc => N_("Organization identifier")
30
+ param :content_view_version_id, :number, :desc => N_("Content View Version identifier")
31
+ param :content_view_filter_id, :number, :desc => N_("Content View Filter identifier")
32
+ param :repository_id, :number, :desc => N_("Repository identifier")
33
+ param :environment_id, :number, :desc => N_("Environment identifier")
34
+ param :ids, Array, :desc => N_("Package identifiers to filter content by")
35
+ param :host_id, :number, :desc => N_("Host id to list applicable packages for")
36
+ param :packages_restrict_applicable, :boolean, :desc => N_("Return packages that are applicable to one or more hosts (defaults to true if host_id is specified)")
37
+ param :packages_restrict_upgradable, :boolean, :desc => N_("Return packages that are upgradable on one or more hosts")
38
+ param :packages_restrict_latest, :boolean, :desc => N_("Return only the latest version of each package")
39
+ param :available_for, String, :desc => N_("Return packages that can be added to the specified object. Only the value 'content_view_version' is supported.")
38
40
  param_group :search, ::Katello::Api::V2::ApiController
39
41
  def index
40
42
  super
41
43
  end
42
44
 
45
+ def available_for_content_view_version(version)
46
+ version.available_packages
47
+ end
48
+
43
49
  def custom_index_relation(collection)
44
- if ::Foreman::Cast.to_bool(params[:packages_restrict_upgradable])
45
- if @host
46
- collection = collection.installable_for_hosts([@host])
47
- else
48
- hosts = ::Host::Managed.authorized("view_hosts")
49
- hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
50
+ applicable = ::Foreman::Cast.to_bool(params[:packages_restrict_applicable]) || @host
51
+ upgradable = ::Foreman::Cast.to_bool(params[:packages_restrict_upgradable])
52
+ if applicable || upgradable
53
+ hosts = @host ? [@host] : ::Host::Managed.authorized("view_hosts")
54
+ hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
55
+ if upgradable
50
56
  collection = collection.installable_for_hosts(hosts)
51
- end
52
- elsif ::Foreman::Cast.to_bool(params[:packages_restrict_applicable]) || @host
53
- if @host
54
- collection = collection.applicable_to_hosts([@host])
55
- else
56
- hosts = ::Host::Managed.authorized("view_hosts")
57
- hosts = hosts.where(:organization_id => params[:organization_id]) if params[:organization_id]
57
+ elsif applicable
58
58
  collection = collection.applicable_to_hosts(hosts)
59
59
  end
60
60
  end
61
+ collection
62
+ end
61
63
 
64
+ def final_custom_index_relation(collection)
65
+ # :packages_restrict_latest is intended to filter the result set after all
66
+ # other constraints have been applied, including the scoped_search
67
+ # constraints. If any constraints are applied after this, then a package
68
+ # will not be returned if its latest version does not match those
69
+ # constraints, even if an older version does match those constraints.
70
+ collection = Katello::Rpm.latest(collection) if ::Foreman::Cast.to_bool(params[:packages_restrict_latest])
62
71
  collection
63
72
  end
64
73
 
74
+ private
75
+
65
76
  def find_host
66
77
  if params[:host_id]
67
78
  @host = ::Host::Managed.authorized("view_hosts").find_by(:id => params[:host_id])
@@ -80,7 +80,7 @@ module Katello
80
80
  product = Product.new(product_params.to_h)
81
81
 
82
82
  sync_task(::Actions::Katello::Product::Create, product, @organization)
83
- respond(:resource => product)
83
+ respond_for_create(:resource => product)
84
84
  end
85
85
 
86
86
  api :GET, "/products/:id", N_("Show a product")
@@ -73,6 +73,7 @@ module Katello
73
73
  param :library, :bool, :desc => N_("show repositories in Library and the default content view")
74
74
  param :content_type, RepositoryTypeManager.repository_types.keys, :desc => N_("limit to only repositories of this type")
75
75
  param :name, String, :desc => N_("name of the repository"), :required => false
76
+ param :description, String, :desc => N_("description of the repository")
76
77
  param :available_for, String, :desc => N_("interpret specified object to return only Repositories that can be associated with specified object. Only 'content_view' is supported."),
77
78
  :required => false
78
79
  param_group :search, Api::V2::ApiController
@@ -85,11 +86,11 @@ module Katello
85
86
  options[:csv] = true
86
87
  repos = scoped_search(*base_args, options)
87
88
  csv_response(repos,
88
- [:id, :name, :label, :content_type, :arch, :url, :major, :minor,
89
+ [:id, :name, :description, :label, :content_type, :arch, :url, :major, :minor,
89
90
  :cp_label, :content_label, :pulp_id, :container_repository_name,
90
91
  :download_policy, 'relative_path', 'product.id', 'product.name',
91
92
  'environment_id'],
92
- ['Id', 'Name', 'label', 'Content Type', 'Arch', 'Url', 'Major', 'Minor',
93
+ ['Id', 'Name', 'label', 'Description', 'Content Type', 'Arch', 'Url', 'Major', 'Minor',
93
94
  'Candlepin Label', 'Content Label', 'Pulp Id', 'Container Repository Name',
94
95
  'Download Policy', 'Relative Path', 'Product Id', 'Product Name',
95
96
  'Environment Id'])
@@ -198,7 +199,7 @@ module Katello
198
199
  repository = construct_repo_from_params(repo_params)
199
200
  sync_task(::Actions::Katello::Repository::Create, repository, false, true)
200
201
  repository = Repository.find(repository.id)
201
- respond_for_show(:resource => repository)
202
+ respond_for_create(:resource => repository)
202
203
  end
203
204
 
204
205
  api :GET, "/repositories/repository_types", N_("Show the available repository types")
@@ -460,7 +461,7 @@ module Katello
460
461
  def repository_params
461
462
  keys = [:download_policy, :mirror_on_sync, :arch, :verify_ssl_on_sync, :upstream_password, :upstream_username,
462
463
  :ostree_upstream_sync_depth, :ostree_upstream_sync_policy, :ignore_global_proxy,
463
- :deb_releases, :deb_components, :deb_architectures, {:ignorable_content => []}
464
+ :deb_releases, :deb_components, :deb_architectures, :description, {:ignorable_content => []}
464
465
  ]
465
466
 
466
467
  keys += [:label, :content_type] if params[:action] == "create"
@@ -481,7 +482,7 @@ module Katello
481
482
  end
482
483
 
483
484
  def construct_repo_from_params(repo_params)
484
- repository = @product.add_repo(Hash[repo_params.slice(:label, :name, :url, :content_type, :arch, :unprotected,
485
+ repository = @product.add_repo(Hash[repo_params.slice(:label, :name, :description, :url, :content_type, :arch, :unprotected,
485
486
  :gpg_key, :ssl_ca_cert, :ssl_client_cert, :ssl_client_key,
486
487
  :checksum_type, :download_policy).to_h.map { |k, v| [k.to_sym, v] }])
487
488
  repository.docker_upstream_name = repo_params[:docker_upstream_name] if repo_params[:docker_upstream_name]
@@ -17,7 +17,6 @@ module Katello
17
17
  param :product_id, :number, :required => true, :desc => N_("ID of a product to list repository sets from")
18
18
  param :name, String, :required => false, :desc => N_("Repository set name to search on")
19
19
  param :enabled, :bool, :required => false, :desc => N_("If true, only return repository sets that have been enabled. Defaults to false")
20
- param :with_active_subscription, :bool, :required => false, :desc => N_("If true, only return repository sets that are associated with an active subscriptions")
21
20
  param_group :search, Api::V2::ApiController
22
21
  def index
23
22
  respond(:collection => scoped_search(index_relation, nil, nil, :custom_sort => default_sort,
@@ -93,15 +92,7 @@ module Katello
93
92
  relation = @product.displayable_product_contents
94
93
  end
95
94
 
96
- if ::Foreman::Cast.to_bool(params[:enabled])
97
- relation = relation.enabled(@organization)
98
- elsif ::Foreman::Cast.to_bool(params[:with_active_subscription])
99
- relation = relation.with_valid_subscription(@organization)
100
- else
101
- relation = relation.where(:id => Katello::ProductContent.with_valid_subscription(@organization)).or(
102
- relation.where(:id => Katello::ProductContent.enabled(@organization)))
103
- end
104
-
95
+ relation = relation.enabled(@organization) if ::Foreman::Cast.to_bool(params[:enabled])
105
96
  relation = relation.where(Katello::Content.table_name => {:name => params[:name]}) if params[:name].present?
106
97
  relation.redhat
107
98
  end