katello 4.1.0.rc2.1 → 4.1.0.rc2.2

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c3ca9aa522c8826e59a58d05088e583f7c3534927eca263c2f02cb8a1ebbc40
4
- data.tar.gz: a4934230cbbd27a3fe4c56df4ae496053cfcc58737ad915fcf9a320b32a9fce7
3
+ metadata.gz: 2b5fdc201af935cf74af29ff64e8b4ac30918984308a428615d4297780bf714e
4
+ data.tar.gz: df90a5fee570cae2ff2a3b9978fa91062a3d6dc8b1b704460780d6ef4141cc7a
5
5
  SHA512:
6
- metadata.gz: 8938e80bc139117c1a4cec2de936657049a7cde59fa3380b5ab7e627f9e44f4359955e39c7003fea5f6ca8e0bd8af1c4ff8881ef1b143c64da1686ffc8a1a348
7
- data.tar.gz: 8d53413bfc591eb020ed5aba779727858e607c32379755ced239da48f91c0bf00227db9b61b728d1d1f784297a8c06e86d2550c17e406c24cef82d3e19c658e0
6
+ metadata.gz: 805ab590d81e32061ad21253b114e354189d8fa7379564a6bfa2b5f33215b3ed3715ee6d693b1ee61d709fa66f0fc72536efe1dcc51970b48de7f45390491674
7
+ data.tar.gz: a268def3988ff20934d0d218562e4b8f980457b5576803e9065a9f7b263a7371690ec510a40afa0719785868b8a3b7c31118e18a443d40ecf1ca002b474f7b99
@@ -0,0 +1,22 @@
1
+ module Actions
2
+ module Katello
3
+ module ContentViewVersion
4
+ class AutoCreateRedhatRepositories < Actions::Base
5
+ def plan(organization:, metadata:)
6
+ helper = ::Katello::Pulp3::ContentViewVersion::ImportableRepositories.
7
+ new(organization: organization,
8
+ metadata: metadata, redhat: true)
9
+ helper.generate!
10
+ sequence do
11
+ helper.creatable.each do |root|
12
+ plan_action(::Actions::Katello::RepositorySet::EnableRepository, root[:product], root[:content], root[:substitutions])
13
+ end
14
+ helper.updatable.each do |root|
15
+ plan_action(::Actions::Katello::Repository::Update, root[:repository], root[:options])
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -26,6 +26,7 @@ module Actions
26
26
  sequence do
27
27
  plan_action(AutoCreateProducts, organization: content_view.organization, metadata: metadata)
28
28
  plan_action(AutoCreateRepositories, organization: content_view.organization, metadata: metadata)
29
+ plan_action(AutoCreateRedhatRepositories, organization: content_view.organization, metadata: metadata)
29
30
  plan_action(ResetContentViewRepositoriesFromMetadata, content_view: content_view, metadata: metadata)
30
31
  plan_action(::Actions::Katello::ContentView::Publish, content_view, description,
31
32
  path: path,
@@ -10,7 +10,7 @@ module Katello
10
10
 
11
11
  encrypts :upstream_password
12
12
 
13
- IGNORABLE_CONTENT_UNIT_TYPES = %w(rpm drpm srpm distribution erratum).freeze
13
+ IGNORABLE_CONTENT_UNIT_TYPES = %w(srpm).freeze
14
14
  CHECKSUM_TYPES = %w(sha1 sha256).freeze
15
15
 
16
16
  OSTREE_UPSTREAM_SYNC_POLICY_LATEST = "latest".freeze
@@ -61,12 +61,12 @@ module Katello
61
61
  gpg
62
62
  end
63
63
 
64
- def self.metadata_map(metadata, product_only: false, custom_only: false)
64
+ def self.metadata_map(metadata, product_only: false, custom_only: false, redhat_only: false)
65
65
  # Create a map that looks like -> {[product, repo]: {name: 'Foo Repo', label:.....}}
66
66
  # these values should be curated from the metadata.
67
67
  metadata_map = {}
68
68
  metadata[:repositories].values.each do |repo|
69
- next if custom_only && repo[:redhat]
69
+ next if (custom_only && repo[:redhat]) || (redhat_only && !repo[:redhat])
70
70
  if product_only
71
71
  metadata_map[repo[:product][:label]] = repo[:product]
72
72
  else
@@ -19,8 +19,9 @@ module Katello
19
19
  ensure_importing_cvv_does_not_exist!
20
20
  ensure_from_cvv_exists!
21
21
  end
22
+ ensure_manifest_imported!
22
23
  ensure_metadata_matches_repos_in_library!
23
- ensure_redhat_repositories_metadata_are_in_the_library!
24
+ ensure_redhat_products_metadata_are_in_the_library!
24
25
  end
25
26
 
26
27
  def ensure_pulp_importable!
@@ -57,6 +58,14 @@ module Katello
57
58
  end
58
59
  end
59
60
 
61
+ def ensure_manifest_imported!
62
+ rh_repos = ::Katello::Pulp3::ContentViewVersion::Import.metadata_map(metadata, redhat_only: true)
63
+ if rh_repos.any? && !content_view.organization.manifest_imported?
64
+ fail _("No manifest found. Import a manifest with the appropriate subscriptions "\
65
+ "before importing content.")
66
+ end
67
+ end
68
+
60
69
  def repos_in_library
61
70
  ::Katello::Pulp3::ContentViewVersion::Import.
62
71
  repositories_in_library(content_view.organization)
@@ -67,6 +76,7 @@ module Katello
67
76
  end
68
77
 
69
78
  def ensure_metadata_matches_repos_in_library!
79
+ metadata_map = ::Katello::Pulp3::ContentViewVersion::Import.metadata_map(metadata)
70
80
  interested_repos = ::Katello::Pulp3::ContentViewVersion::Import.
71
81
  intersecting_repos_library_and_metadata(organization: organization,
72
82
  metadata: metadata)
@@ -86,19 +96,34 @@ module Katello
86
96
  end
87
97
  end
88
98
 
89
- def ensure_redhat_repositories_metadata_are_in_the_library!
90
- # repos_in_library look like [["prod1", "repo1", "Anonymous"], ["prod2", "repo2", "Red Hat"]]
91
- rh_repos_in_library = repos_in_library.redhat
92
- product_repos_in_library = rh_repos_in_library.map { |repo| [repo.product.label, repo.label] }
93
- product_repos_in_metadata = metadata[:repositories].values.map { |repo| [repo[:product][:label], repo[:label]] if repo[:redhat] }
94
- product_repos_in_metadata.compact!
95
-
96
- # product_repos_in_library & product_repos_in_metadata look like [["prod1", "repo1", false], ["prod2", "repo2", false]]
97
- product_repos_not_in_library = product_repos_in_metadata - product_repos_in_library
98
- unless product_repos_not_in_library.blank?
99
- repos_in_import = generate_product_repo_i18n_string(product_repos_not_in_library)
100
- fail _("The following repositories provided in the import metadata are either not available in the Library or are of incorrect Respository Type. "\
101
- "Please add or enable the repositories before importing\n "\
99
+ def ensure_redhat_products_metadata_are_in_the_library!
100
+ products_in_library = ::Katello::Product.in_org(organization).redhat.pluck(:label)
101
+
102
+ # Map products to repositories in the metadata
103
+ # {product_label: [repositories with this product]}
104
+ products_in_metadata_map = {}
105
+
106
+ metadata[:repositories].values.each do |repo|
107
+ next unless repo[:redhat]
108
+ products_in_metadata_map[repo[:product][:label]] ||= []
109
+ products_in_metadata_map[repo[:product][:label]] << repo
110
+ end
111
+
112
+ products_not_in_library = products_in_metadata_map.keys - products_in_library
113
+
114
+ unless products_not_in_library.blank?
115
+ # make a list of [product_name, repo_name] pairs to report to the user
116
+ product_repos = []
117
+ products_not_in_library.each do |prod|
118
+ products_in_metadata_map[prod].each do |repo|
119
+ product_name = metadata[:products][prod][:name]
120
+ repo_name = repo[:name]
121
+ product_repos << [product_name, repo_name]
122
+ end
123
+ end
124
+
125
+ repos_in_import = generate_product_repo_i18n_string(product_repos)
126
+ fail _("The organization's manifest does not contain the subscriptions required to enable the following repositories.\n "\
102
127
  "%{repos}" % { content_view: content_view.name, repos: repos_in_import.join("")}
103
128
  )
104
129
  end
@@ -2,20 +2,25 @@ module Katello
2
2
  module Pulp3
3
3
  module ContentViewVersion
4
4
  class ImportableRepositories
5
- attr_accessor :creatable, :updatable, :organization, :metadata
5
+ attr_reader :creatable, :updatable, :organization, :metadata, :redhat
6
6
 
7
- def initialize(organization:, metadata:)
8
- self.organization = organization
9
- self.metadata = metadata
10
- self.creatable = []
11
- self.updatable = []
7
+ def initialize(organization:, metadata:, redhat: false)
8
+ @organization = organization
9
+ @metadata = metadata
10
+ @creatable = []
11
+ @updatable = []
12
+ @redhat = redhat
13
+ end
14
+
15
+ def product_content_by_label(content_label)
16
+ ::Katello::Content.find_by_label(content_label)
12
17
  end
13
18
 
14
19
  def repositories_in_library
15
20
  return @repositories_in_library unless @repositories_in_library.blank?
16
-
21
+ repo_type = redhat ? :redhat : :custom
17
22
  # fetch a list of [product, repo] pairs for every non-redhat library repo
18
- product_repos_in_library = Import.repositories_in_library(organization).custom.
23
+ product_repos_in_library = Import.repositories_in_library(organization).send(repo_type).
19
24
  pluck("#{Katello::Product.table_name}.label",
20
25
  "#{Katello::RootRepository.table_name}.label")
21
26
  @repositories_in_library = Set.new(product_repos_in_library.compact)
@@ -27,7 +32,7 @@ module Katello
27
32
  # They are ready to be created
28
33
  # updatable: repo that are both in the metadata and library.
29
34
  # These may contain updates to the repo and hence ready to be updated.
30
- metadata_map = Import.metadata_map(metadata, custom_only: true)
35
+ metadata_map = Import.metadata_map(metadata, custom_only: !redhat, redhat_only: redhat)
31
36
  metadata_map.keys.each do |product_label, repo_label|
32
37
  product = Katello::Product.in_org(organization).find_by(label: product_label)
33
38
  fail _("Unable to find product '%s' in organization '%s'" % [product_label, organization.name]) if product.blank?
@@ -37,10 +42,18 @@ module Katello
37
42
  else
38
43
  params[:gpg_key_id] = organization.gpg_keys.find_by(name: params[:gpg_key][:name]).id
39
44
  end
40
- params = params.except(:redhat, :product, :gpg_key)
45
+ content = params[:content]
46
+ params = params.except(:redhat, :product, :gpg_key, :content)
41
47
  if repositories_in_library.include? [product_label, repo_label]
42
48
  repo = ::Katello::RootRepository.find_by(product: product, label: repo_label)
43
49
  updatable << { repository: repo, options: params.except(:label, :name, :content_type) }
50
+ elsif redhat
51
+ product_content = product_content_by_label(content[:label])
52
+ substitutions = {
53
+ basearch: params[:arch],
54
+ releasever: params[:minor]
55
+ }
56
+ creatable << { product: product, content: product_content, substitutions: substitutions }
44
57
  else
45
58
  creatable << { repository: product.add_repo(params) }
46
59
  end
@@ -46,6 +46,7 @@ module Katello
46
46
  :checksum_type, :os_versions, :major, :minor).
47
47
  merge(product: generate_product_metadata(repo.product),
48
48
  gpg_key: generate_gpg_metadata(repo.gpg_key),
49
+ content: generate_content_metadata(repo.content),
49
50
  redhat: repo.redhat?)
50
51
  end
51
52
 
@@ -60,6 +61,11 @@ module Katello
60
61
  gpg.slice(:name, :content_type, :content)
61
62
  end
62
63
 
64
+ def generate_content_metadata(content)
65
+ return {} if content.blank?
66
+ { id: content.cp_content_id, label: content.label }
67
+ end
68
+
63
69
  def zip_gpg_keys(entities)
64
70
  # this goes through each repo/product
65
71
  # identifies gpg keys
@@ -12,7 +12,6 @@
12
12
  * @requires DownloadPolicy
13
13
  * @requires OstreeUpstreamSyncPolicy
14
14
  * @requires Architecture
15
- * @requires YumContentUnits
16
15
  * @requires HttpProxyPolicy
17
16
  * @requires OSVersions
18
17
  *
@@ -20,14 +19,15 @@
20
19
  * Provides the functionality for the repository details info page.
21
20
  */
22
21
  angular.module('Bastion.repositories').controller('RepositoryDetailsInfoController',
23
- ['$scope', '$q', 'translate', 'Notification', 'ContentCredential', 'CurrentOrganization', 'Checksum', 'DownloadPolicy', 'YumContentUnits', 'OstreeUpstreamSyncPolicy', 'Architecture', 'HttpProxy', 'HttpProxyPolicy', 'OSVersions',
24
- function ($scope, $q, translate, Notification, ContentCredential, CurrentOrganization, Checksum, DownloadPolicy, YumContentUnits, OstreeUpstreamSyncPolicy, Architecture, HttpProxy, HttpProxyPolicy, OSVersions) {
22
+ ['$scope', '$q', 'translate', 'Notification', 'ContentCredential', 'CurrentOrganization', 'Checksum', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', 'HttpProxy', 'HttpProxyPolicy', 'OSVersions',
23
+ function ($scope, $q, translate, Notification, ContentCredential, CurrentOrganization, Checksum, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture, HttpProxy, HttpProxyPolicy, OSVersions) {
25
24
  $scope.organization = CurrentOrganization;
26
25
 
27
26
  $scope.progress = {uploading: false};
28
27
 
29
28
  $scope.repository.$promise.then(function () {
30
29
  $scope.uploadURL = 'katello/api/v2/repositories/' + $scope.repository.id + '/upload_content';
30
+ $scope.repository['ignore_srpms'] = $scope.repository['ignorable_content'].includes("srpm");
31
31
  });
32
32
 
33
33
  $scope.gpgKeys = function () {
@@ -89,6 +89,13 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
89
89
 
90
90
  $scope.save = function (repository, saveUpstreamAuth) {
91
91
  var deferred = $q.defer();
92
+ if (repository.content_type === 'yum' && typeof repository.ignore_srpms !== 'undefined') {
93
+ if (repository['ignore_srpms']) {
94
+ repository['ignorable_content'] = ["srpm"];
95
+ } else {
96
+ repository['ignorable_content'] = [];
97
+ }
98
+ }
92
99
 
93
100
  if (!saveUpstreamAuth) {
94
101
  repository['upstream_username'] = null;
@@ -106,6 +113,7 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
106
113
  repository.os_versions = $scope.osVersionsParam();
107
114
  repository.$update(function (response) {
108
115
  deferred.resolve(response);
116
+ $scope.repository.ignore_srpms = $scope.repository.ignorable_content.includes("srpm");
109
117
  if (!_.isEmpty(response["docker_tags_whitelist"])) {
110
118
  repository.commaTagsWhitelist = repository["docker_tags_whitelist"].join(", ");
111
119
  } else {
@@ -171,7 +179,6 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
171
179
  $scope.checksums = Checksum.checksums;
172
180
  $scope.downloadPolicies = DownloadPolicy.downloadPolicies;
173
181
  $scope.ostreeUpstreamSyncPolicies = OstreeUpstreamSyncPolicy.syncPolicies;
174
- $scope.ignorableYumContentUnits = YumContentUnits.units;
175
182
 
176
183
  $scope.checksumTypeDisplay = function (checksum) {
177
184
  return Checksum.checksumType(checksum);
@@ -211,20 +211,11 @@
211
211
  </span>
212
212
 
213
213
  <span ng-if="repository.content_type === 'yum'">
214
- <dt translate>Ignorable Content</dt>
215
- <dd bst-edit-custom="repository.ignorable_content"
216
- readonly="denied('edit_products', product)"
214
+ <dt translate>Ignore SRPMs</dt>
215
+ <dd bst-edit-checkbox="repository.ignore_srpms"
216
+ formatter="booleanToYesNo"
217
217
  on-save="save(repository)"
218
- formatter="yumIgnorableContentFilter"
219
- formatter-options="repository"
220
- >
221
- <div translate>Use Ctrl-click to multi-select/deselect items.</div>
222
- <select id="ignorable_content"
223
- name="ignorable_content"
224
- multiple="true"
225
- ng-model="repository.ignorable_content"
226
- ng-options="id as name for (id, name) in ignorableYumContentUnits">
227
- </select>
218
+ readonly="denied('edit_products', product)">
228
219
  </dd>
229
220
  </span>
230
221
 
@@ -18,15 +18,14 @@
18
18
  * @requires Architecture
19
19
  * @requires RepositoryTypesService
20
20
  * @requires OSVersions
21
- * @requires YumContentUnits
22
21
  * #requires HttpProxyPolicy
23
22
  *
24
23
  * @description
25
24
  * Controls the creation of an empty Repository object for use by sub-controllers.
26
25
  */
27
26
  angular.module('Bastion.repositories').controller('NewRepositoryController',
28
- ['$scope', '$sce', 'Repository', 'Product', 'ContentCredential', 'FormUtils', 'translate', 'Notification', 'ApiErrorHandler', 'BastionConfig', 'Checksum', 'YumContentUnits', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', 'RepositoryTypesService', 'HttpProxy', 'HttpProxyPolicy', 'OSVersions',
29
- function ($scope, $sce, Repository, Product, ContentCredential, FormUtils, translate, Notification, ApiErrorHandler, BastionConfig, Checksum, YumContentUnits, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture, RepositoryTypesService, HttpProxy, HttpProxyPolicy, OSVersions) {
27
+ ['$scope', '$sce', 'Repository', 'Product', 'ContentCredential', 'FormUtils', 'translate', 'Notification', 'ApiErrorHandler', 'BastionConfig', 'Checksum', 'DownloadPolicy', 'OstreeUpstreamSyncPolicy', 'Architecture', 'RepositoryTypesService', 'HttpProxy', 'HttpProxyPolicy', 'OSVersions',
28
+ function ($scope, $sce, Repository, Product, ContentCredential, FormUtils, translate, Notification, ApiErrorHandler, BastionConfig, Checksum, DownloadPolicy, OstreeUpstreamSyncPolicy, Architecture, RepositoryTypesService, HttpProxy, HttpProxyPolicy, OSVersions) {
30
29
 
31
30
  function success() {
32
31
  Notification.setSuccessMessage(translate('Repository %s successfully created.').replace('%s', $scope.repository.name));
@@ -80,7 +79,6 @@ angular.module('Bastion.repositories').controller('NewRepositoryController',
80
79
  $scope.checksums = Checksum.checksums;
81
80
  $scope.downloadPolicies = DownloadPolicy.downloadPolicies;
82
81
  $scope.ostreeUpstreamSyncPolicies = OstreeUpstreamSyncPolicy.syncPolicies;
83
- $scope.ignorableYumContentUnits = YumContentUnits.units;
84
82
 
85
83
  $scope.$watch('repository.name', function () {
86
84
  if ($scope.repositoryForm && $scope.repositoryForm.name) {
@@ -125,6 +123,11 @@ angular.module('Bastion.repositories').controller('NewRepositoryController',
125
123
  }
126
124
  if (repository.content_type === 'yum') {
127
125
  repository.os_versions = $scope.osVersionsParam();
126
+ if ($scope.repositoryForm.ignore_srpms.$modelValue) {
127
+ repository.ignorable_content = ["srpm"];
128
+ } else {
129
+ repository.ignorable_content = [];
130
+ }
128
131
  }
129
132
  if (repository.content_type !== 'yum') {
130
133
  repository['download_policy'] = '';
@@ -175,17 +175,14 @@
175
175
 
176
176
  </div>
177
177
 
178
- <div bst-form-group label="{{ 'Ignorable Content' | translate }}" ng-if="repository.content_type === 'yum'">
179
- <select id="ignorable_content"
180
- name="ignorable_content"
181
- multiple="true"
182
- ng-model="repository.ignorable_content"
183
- ng-options="id as name for (id, name) in ignorableYumContentUnits">
184
- </select>
178
+ <div class="checkbox" ng-if="repository.content_type === 'yum'">
179
+ <label>
180
+ <input id="ignore_srpms" name="ignore_srpms" ng-model="repository.ignore_srpms" type="checkbox"/>
181
+ <span translate>Ignore SRPMs</span>
182
+ </label>
185
183
 
186
184
  <p class="help-block">
187
- <span translate>Select content units to ignore while synchronizing this repository.</span><br />
188
- <span translate>Use Ctrl-click to multi-select/deselect items.</span>
185
+ <span translate>Selecting this option will exclude SRPMs from repository synchronization.</span><br />
189
186
  </p>
190
187
  </div>
191
188
 
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "4.1.0.rc2.1".freeze
2
+ VERSION = "4.1.0.rc2.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0.rc2.1
4
+ version: 4.1.0.rc2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - N/A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-24 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -865,6 +865,7 @@ files:
865
865
  - app/lib/actions/katello/content_view_environment/reassign_objects.rb
866
866
  - app/lib/actions/katello/content_view_version/after_promote_hook.rb
867
867
  - app/lib/actions/katello/content_view_version/auto_create_products.rb
868
+ - app/lib/actions/katello/content_view_version/auto_create_redhat_repositories.rb
868
869
  - app/lib/actions/katello/content_view_version/auto_create_repositories.rb
869
870
  - app/lib/actions/katello/content_view_version/before_promote_hook.rb
870
871
  - app/lib/actions/katello/content_view_version/create_repos.rb