-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zeitwerk #9287
Zeitwerk #9287
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Foreman | ||
module ReportScanner | ||
class PuppetReportScanner | ||
class << self | ||
def identify_origin(report_data) | ||
'Puppet' if puppet_report?(report_data['logs'] || []) | ||
end | ||
|
||
def add_reporter_data(report, report_data) | ||
# no additional data apart of origin | ||
end | ||
|
||
def puppet_report?(logs) | ||
log = logs.last | ||
log && log['log'].fetch('sources', {}).fetch('source', '') =~ /Puppet/ | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -132,18 +132,9 @@ def load_definitions | |||
end | ||||
end | ||||
|
||||
def known_categories | ||||
unless @known_descendants == Setting.descendants | ||||
@known_descendants = Setting.descendants | ||||
@known_categories = @known_descendants.map(&:name) << 'Setting' | ||||
@values_loaded_at = nil # force all values to be reloaded | ||||
end | ||||
@known_categories | ||||
end | ||||
|
||||
def load_values(ignore_cache: false) | ||||
# we are loading only known STIs as we load settings fairly early the first time and plugin classes might not be loaded yet. | ||||
settings = Setting.unscoped.where(category: known_categories).where.not(value: nil) | ||||
settings = Setting.unscoped.where(category: 'Setting').where.not(value: nil) | ||||
Comment on lines
-135
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My main concern is here. Not sure if we can do this right now, any ideas @ezr-ondrej? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This basically means we will no longer support any other setting then DSL based, which is IMHO time to do. Line 204 in a439e1e
I'd love a separate PR for that, ideally dropping the category column from setting alltogether, for us to be explicit about the fact. I'll be back online on 11th and I'll be happy to take a look into it that week. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ezr-ondrej I don't mind take care about deprecating the Settings, but I don't have much idea where to start ... If you point me to what needs to be done I'll push the PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stejskalleos @ofedoren sorry for the delay it totally slipped my mind when I couldn't get to it that week, sorry! Here is my take on it #9524, my foreman knowledge is bit rusty so I hope I got it right. If I can do some other clean-ups that would elevate some pain from this PR, I'm happy to do so, I believe it would help the project to get this done (but I know it's pain to find and fix all the blockers) |
||||
settings = settings.where('updated_at >= ?', @values_loaded_at) unless ignore_cache || @values_loaded_at.nil? | ||||
settings.each do |s| | ||||
unless (definition = find(s.name)) | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ class Application < Rails::Application | |
Dir["#{Rails.root}/config/routes/**/*.rb"].each do |route_file| | ||
config.paths['config/routes.rb'] << route_file | ||
end | ||
|
||
config.load_defaults 6.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to add # Rails 5 changed this to true
config.active_record.belongs_to_required_by_default = false There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opened #9382 to do this as a separate preparation step. |
||
# Settings in config/environments/* take precedence over those specified here. | ||
# Application configuration should go into files in config/initializers | ||
# -- all .rb files in that directory are automatically loaded. | ||
|
@@ -115,7 +115,7 @@ class Application < Rails::Application | |
config.autoload_paths += %W(#{config.root}/app/models/compute_resources) | ||
config.autoload_paths += %W(#{config.root}/app/models/fact_names) | ||
config.autoload_paths += %W(#{config.root}/app/models/lookup_keys) | ||
config.autoload_paths += %W(#{config.root}/app/models/host_status) | ||
# config.autoload_paths += %W(#{config.root}/app/models/host_status) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is from previous commits. My guess is we can remove this line completely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and all the above IMHO. we should not add subfolders of |
||
config.autoload_paths += %W(#{config.root}/app/models/operatingsystems) | ||
config.autoload_paths += %W(#{config.root}/app/models/parameters) | ||
config.autoload_paths += %W(#{config.root}/app/models/taxonomies) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Rails.autoloaders.main.inflector.inflect( | ||
'ui' => 'UI', | ||
'proxy_api' => 'ProxyAPI', | ||
'sti' => 'STI', | ||
'dhcp' => 'DHCP', | ||
'dns' => 'DNS', | ||
'tftp' => 'TFTP', | ||
'external_ipam' => 'ExternalIPAM', | ||
'bmc' => 'BMC', | ||
'ui_notifications' => 'UINotifications', | ||
'ipam' => 'IPAM', | ||
'ssh' => 'SSH', | ||
'ssh_provision' => 'SSHProvision', | ||
'ssh_execution_provider' => 'SSHExecutionProvider', | ||
'keep_current_request_id' => 'KeepCurrentRequestID', | ||
'ec2' => 'EC2', | ||
'aws' => 'AWS', | ||
'gce' => 'GCE', | ||
'aix' => 'AIX', | ||
'nxos' => 'NXOS', | ||
'vrp' => 'VRP', | ||
'sso' => 'SSO', | ||
'puppet_ca_certificate' => 'PuppetCACertificate', | ||
'url_resolver' => 'URLResolver', | ||
'ztp_record' => 'ZTPRecord', | ||
'aaaa_record' => 'AAAARecord', | ||
'ptr4_record' => 'PTR4Record', | ||
'ptr6_record' => 'PTR6Record' | ||
Comment on lines
+16
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is basically workaround for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We (mainly @stejskalleos) has started to work on exactly this and I believe |
||
) | ||
|
||
Rails.autoloaders.main.ignore( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adamruzicka, @ofedoren Do you guys know what's the difference between Rails.autoloaders.main
=> #<Zeitwerk::Loader:0x00000000073af3e8
@autoloaded_dirs=[],
@autoloads={},
@collapse_dirs=#<Set: {}>,
@collapse_glob_patterns=#<Set: {}>,
@eager_load_exclusions=#<Set: {}>,
@eager_loaded=false,
@ignored_glob_patterns=#<Set: {}>,
@ignored_paths=#<Set: {}>,
@inflector=ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector,
@initialized_at=2022-07-27 15:53:58.924070552 +0200,
@lazy_subdirs={},
@logger=nil,
@mutex=#<Thread::Mutex:0x00000000073aefb0>,
@mutex2=#<Thread::Mutex:0x00000000073aef88>,
@on_load_callbacks={},
@on_setup_callbacks=[],
@on_unload_callbacks={},
@reloading_enabled=false,
@root_dirs={},
@setup=false,
@tag="rails.main",
@to_unload={}>
Rails.autoloaders.once
=> #<Zeitwerk::Loader:0x000000000af8bd80
@autoloaded_dirs=[],
@autoloads={},
@collapse_dirs=#<Set: {}>,
@collapse_glob_patterns=#<Set: {}>,
@eager_load_exclusions=#<Set: {}>,
@eager_loaded=false,
@ignored_glob_patterns=#<Set: {}>,
@ignored_paths=#<Set: {}>,
@inflector=ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector,
@initialized_at=2022-07-27 15:54:07.749815776 +0200,
@lazy_subdirs={},
@logger=nil,
@mutex=#<Thread::Mutex:0x000000000af8b6c8>,
@mutex2=#<Thread::Mutex:0x000000000af8b628>,
@on_load_callbacks={},
@on_setup_callbacks=[],
@on_unload_callbacks={},
@reloading_enabled=false,
@root_dirs={},
@setup=false,
@tag="rails.once",
@to_unload={}> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#config-autoload-paths talks about which paths are managed by which autoloader |
||
Rails.root.join('lib/core_extensions.rb'), | ||
Rails.root.join('lib/generators') | ||
) | ||
Rails.autoloaders.once.ignore( | ||
Rails.root.join('app/registries/foreman/access_permissions.rb'), | ||
Rails.root.join('app/registries/foreman/settings.rb'), | ||
Rails.root.join('app/registries/foreman/settings') | ||
Comment on lines
+36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wondered if these shouldn't be initializers. |
||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #9328 I chose to make CA an acronym and name the file
puppet_ca
instead. Didn't notice this PR until now.