Class: Bicho::Plugins::Novell

Inherits:
Object
  • Object
show all
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

OSCRC_CREDENTIALS =
"https://api.opensuse.org"

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) oscrc_credentials



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bicho/plugins/novell.rb', line 48

def self.oscrc_credentials
  oscrc = IniFile.new(File.join(ENV['HOME'], '.oscrc'))
  if oscrc.has_section?(OSCRC_CREDENTIALS)
    user = oscrc[OSCRC_CREDENTIALS]['user']
    pass = oscrc[OSCRC_CREDENTIALS]['pass']
    if user && pass
      return {:user => user, :password => pass}
    else
      raise "No .oscrc credentials for bnc"
    end
  end
end

Instance Method Details

- (Object) initialize_hook(url, logger)



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bicho/plugins/novell.rb', line 61

def initialize_hook(url, logger)

  return if not url.host.include?('bugzilla.novell.com')

  auth = Novell.oscrc_credentials
  url.user = auth[:user]
  url.password = auth[:password]
  url.host = url.host.gsub(/bugzilla\.novell.com/, 'apibugzilla.novell.com')
  url.path = url.path.gsub(/xmlrpc\.cgi/, 'tr_xmlrpc.cgi')

  logger.debug("#{self} : Rewrote url to '#{url.to_s.gsub(/#{url.user}:#{url.password}/, "USER:PASS")}'")
end

- (Object) to_s



44
45
46
# File 'lib/bicho/plugins/novell.rb', line 44

def to_s
  self.class.to_s
end