Class: Bicho::Plugins::Novell
- Inherits:
-
Object
- Object
- Bicho::Plugins::Novell
- Defined in:
- lib/bicho/plugins/novell.rb
Overview
Novell bugzilla is behind ichain
Plugin that rewrites the bugzilla API url to the Novell internal endpoint without ichain.
Also, it takes your credentials from your oscrc.
Constant Summary collapse
- OSCRC_CREDENTIALS =
'https://api.opensuse.org'- DEFAULT_OSCRC_PATH =
File.join(ENV['HOME'], '.oscrc')
- DOMAINS =
['bugzilla.novell.com', 'bugzilla.suse.com'].freeze
- XMLRPC_DOMAINS =
['apibugzilla.novell.com', 'apibugzilla.suse.com'].freeze
Class Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #to_s ⇒ Object
- #transform_api_url_hook(url, logger) ⇒ Object
- #transform_site_url_hook(url, _logger) ⇒ Object
- #transform_xmlrpc_client_hook(client, logger) ⇒ Object
Class Attribute Details
.oscrc_path ⇒ Object
51 52 53 |
# File 'lib/bicho/plugins/novell.rb', line 51 def self.oscrc_path @oscrc_path ||= DEFAULT_OSCRC_PATH end |
Class Method Details
.oscrc_credentials ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bicho/plugins/novell.rb', line 59 def self.oscrc_credentials oscrc = IniFile.load(oscrc_path) urls = [OSCRC_CREDENTIALS] urls << "#{OSCRC_CREDENTIALS}/" unless OSCRC_CREDENTIALS.end_with?('/') urls.each do |section| next unless oscrc.has_section?(section) user = oscrc[section]['user'] pass = oscrc[section]['pass'] return { user: user, password: pass } if user && pass end raise "No valid .oscrc credentials for Novell/SUSE bugzilla (#{oscrc_path})" end |
Instance Method Details
#to_s ⇒ Object
55 56 57 |
# File 'lib/bicho/plugins/novell.rb', line 55 def to_s self.class.to_s end |
#transform_api_url_hook(url, logger) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/bicho/plugins/novell.rb', line 81 def transform_api_url_hook(url, logger) return url unless DOMAINS.map { |domain| url.host&.include?(domain) }.any? begin url = url.clone url.host = url.host.gsub(/bugzilla\.novell.com/, 'apibugzilla.novell.com') url.host = url.host.gsub(/bugzilla\.suse.com/, 'apibugzilla.suse.com') url.scheme = 'https' logger.debug("#{self} : Rewrote url to '#{url}'") rescue StandardError => e logger.warn e end url end |
#transform_site_url_hook(url, _logger) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/bicho/plugins/novell.rb', line 72 def transform_site_url_hook(url, _logger) case url.to_s when 'bnc', 'novell' then 'https://bugzilla.novell.com' when 'bsc', 'suse' then 'https://bugzilla.suse.com' when 'boo', 'opensuse' then 'https://bugzilla.opensuse.org' else url end end |
#transform_xmlrpc_client_hook(client, logger) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bicho/plugins/novell.rb', line 97 def transform_xmlrpc_client_hook(client, logger) return unless XMLRPC_DOMAINS.map { |domain| client.http.address.include?(domain) }.any? auth = Novell.oscrc_credentials client.user = auth[:user] client.password = auth[:password] logger.debug("#{self} : updated XMLRPC client with oscrc auth information") rescue StandardError => e logger.error e end |