Skip to content

Commit

Permalink
Merge branch 'master' into depfu/update/ffaker-2.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
felixsch authored Jan 11, 2024
2 parents 5c8aa57 + 9145722 commit 442db9e
Show file tree
Hide file tree
Showing 44 changed files with 11,880 additions and 16,695 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.1)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
awesome_print (1.9.2)
Expand Down Expand Up @@ -152,7 +152,7 @@ GEM
mustache (1.1.1)
mysql2 (0.5.5)
nenv (0.3.0)
nio4r (2.5.9)
nio4r (2.7.0)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
Expand All @@ -169,7 +169,7 @@ GEM
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.7)
puma (5.6.7)
puma (5.6.8)
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.8)
Expand Down Expand Up @@ -199,7 +199,7 @@ GEM
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.5)
rexml (3.2.6)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
Expand Down Expand Up @@ -304,7 +304,7 @@ GEM
activesupport (>= 3)
railties (>= 3)
yard (~> 0.9.20)
webmock (3.18.1)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ dist: clean man

@rm -rf $(NAME)-$(VERSION)/config/rmt.yml
@rm -rf $(NAME)-$(VERSION)/config/rmt.local.yml
@rm -rf $(NAME)-$(VERSION)/config/secrets.yml.*
@rm -rf $(NAME)-$(VERSION)/config/system_uuid

# don't package test tasks (fails to load because of rspec dependency)
Expand Down
13 changes: 13 additions & 0 deletions app/services/repository_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ def create_repository!(product, url, attributes, custom: false)
repository
end

def update_repository!(repo_data)
uri = URI(repo_data[:url])
auth_token = uri.query

Repository.find_by!(scc_id: repo_data[:id]).update!(
auth_token: auth_token,
enabled: repo_data[:enabled],
autorefresh: repo_data[:autorefresh],
external_url: "#{uri.scheme}://#{uri.host}#{uri.path}",
local_path: Repository.make_local_path(uri)
)
end

def attach_product!(product, repository)
RepositoriesServicesAssociation.find_or_create_by!(
service_id: product.service.id,
Expand Down
11 changes: 11 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,16 @@ class Application < Rails::Application
g.test_framework :rspec
end

# Rails initialization process requires a secret key base present in either:
# - SECRET_KEY_BASE env
# - credentials.secret_key_base
# - secrets.secret_key_base
#
# Else the boot process will be halted. RMT does not use any of those
# facilities. Hardcoding it here keeps rails happy and allows the boot
# process to continue.
config.require_master_key = false
config.read_encrypted_secrets = false
config.secret_key_base = 'rmt-does-not-use-this'
end
end
5 changes: 0 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
config.read_encrypted_secrets = true

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
Expand Down
1 change: 1 addition & 0 deletions config/initializers/strong_migrations.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# rubocop:disable Style/NumericLiterals
unless Rails.env.production?
StrongMigrations.start_after = 20200205123840
StrongMigrations.lock_timeout_limit = 0
end
# rubocop:enable Style/NumericLiterals
32 changes: 0 additions & 32 deletions config/secrets.yml

This file was deleted.

23 changes: 12 additions & 11 deletions db/migrate/20230814105634_move_hw_info_to_systems_table.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
class MoveHwInfoToSystemsTable < ActiveRecord::Migration[6.1]
def up
safety_assured do
execute "update systems as s inner join hw_infos hw on s.id=hw.system_id \
set system_information = json_object(\
'cpus', hw.cpus, \
'sockets', hw.sockets, \
'hypervisor', nullif(hw.hypervisor, ''), \
'arch', nullif(hw.arch, ''), \
'uuid', nullif(hw.uuid, ''), \
'cloud_provider', nullif(hw.cloud_provider, ''));"
change_column :systems, :instance_data, :text

execute "UPDATE systems AS s INNER JOIN hw_infos hw ON s.id=hw.system_id \
SET s.system_information = json_object( \
'cpus', hw.cpus, \
'sockets', hw.sockets, \
'hypervisor', nullif(hw.hypervisor, ''), \
'arch', nullif(hw.arch, ''), \
'uuid', nullif(hw.uuid, ''), \
'cloud_provider', nullif(hw.cloud_provider, '')), \
s.instance_data = hw.instance_data;"
end
end

def down
safety_assured do
execute 'update systems set system_information = json_object();'
end
change_column :systems, :instance_data, :string
end
end
5 changes: 2 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_07_11_152732) do
ActiveRecord::Schema.define(version: 2023_08_14_105634) do

create_table "activations", charset: "utf8", force: :cascade do |t|
t.bigint "service_id", null: false
Expand Down Expand Up @@ -51,7 +51,6 @@
t.datetime "updated_at", null: false
t.text "instance_data", comment: "Additional client information, e.g. instance identity document"
t.string "cloud_provider"
t.boolean "proxy_byos", default: false
t.index ["hypervisor"], name: "index_hw_infos_on_hypervisor"
t.index ["system_id"], name: "index_hw_infos_on_system_id", unique: true
end
Expand Down Expand Up @@ -163,7 +162,7 @@
t.boolean "proxy_byos", default: false
t.string "system_token"
t.text "system_information", size: :long
t.string "instance_data"
t.text "instance_data"
t.index ["login", "password", "system_token"], name: "index_systems_on_login_and_password_and_system_token", unique: true
t.index ["login", "password"], name: "index_systems_on_login_and_password"
t.check_constraint "json_valid(`system_information`)", name: "system_information"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def destroy
protected

def system_params
params.permit(:login, :password, :hostname, :proxy_byos, :system_token, :registered_at, :created_at, :last_seen_at)
params.permit(:login, :password, :hostname, :proxy_byos, :system_token, :registered_at, :created_at, :last_seen_at, :instance_data)
end

def authenticate
Expand Down
2 changes: 1 addition & 1 deletion lib/rmt/cli/repos_custom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def add(url, name)

error = nil
if Repository.find_by(external_url: url)
error = _('A repository by the URL %{url} already exists.') % { url: url }
error = _('A repository by the URL %{url} already exists (ID %{id}).') % { url: url, id: Repository.find_by(external_url: url).friendly_id }
elsif Repository.find_by(friendly_id: options.id.to_s)
# When given an ID by a user, don't append to it to make a unique ID.
error = _('A repository by the ID %{id} already exists.') % { id: friendly_id }
Expand Down
13 changes: 3 additions & 10 deletions lib/rmt/scc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def sync
@logger.info(_('Downloading data from SCC'))
scc_api_client = SUSE::Connect::Api.new(Settings.scc.username, Settings.scc.password)

@logger.info(_('Updating products'))
data = scc_api_client.list_products
@logger.info(_('Updating products'))
data.each { |item| create_product(item) }
data.each { |item| migration_paths(item) }

Expand Down Expand Up @@ -132,8 +132,8 @@ def credentials_set?

def update_repositories(repos)
@logger.info _('Updating repositories')
repos.each do |item|
update_auth_token_enabled_attr(item)
repos.each do |repo|
repository_service.update_repository!(repo)
end
end

Expand Down Expand Up @@ -191,13 +191,6 @@ def create_service(item, product)
end
end

def update_auth_token_enabled_attr(item)
uri = URI(item[:url])
auth_token = uri.query

Repository.find_by!(scc_id: item[:id]).update! auth_token: auth_token, enabled: item[:enabled]
end

def migration_paths(item)
product = get_product(item[:id])
ProductPredecessorAssociation.where(product_id: product.id).destroy_all
Expand Down
4 changes: 4 additions & 0 deletions lib/suse/connect/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ def list_orders
end

def list_products
@logger.info(_('Loading product data from SCC'))
make_paginated_request(:get, "#{connect_api}/organizations/products")
end

def list_products_unscoped
@logger.info(_('Loading product data from SCC'))
make_paginated_request(:get, "#{connect_api}/organizations/products/unscoped")
end

def list_repositories
@logger.info(_('Loading repository data from SCC'))
make_paginated_request(:get, "#{connect_api}/organizations/repositories")
end

def list_subscriptions
@logger.info(_('Loading subscription data from SCC'))
make_paginated_request(:get, "#{connect_api}/organizations/subscriptions")
end

Expand Down
18 changes: 0 additions & 18 deletions lib/tasks/encrypted_key.rake

This file was deleted.

Loading

0 comments on commit 442db9e

Please sign in to comment.