Class: Feta::Plugins::SUSE

Inherits:
Object
  • Object
show all
Defined in:
lib/feta/plugins/suse.rb

Overview

Rewrites the fate.novell.com url to the right keeper server and inserts the osc credentials from .oscrc

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.oscrc_credentialsObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/feta/plugins/suse.rb', line 43

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

#initialize_hook(url, logger, headers) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/feta/plugins/suse.rb', line 60

def initialize_hook(url, logger, headers)
  return if not url.host.include?('fate.novell.com')
  auth = SUSE.oscrc_credentials
  url.host = url.host.gsub(/fate\.novell.com/, 'keeper.novell.com')
  url.user = auth[:user]
  url.password = auth[:password]
  url.path = '/sxkeeper' if url.path.empty?
  logger.debug("#{self} : Rewrote url to '#{url.to_s.gsub(/#{url.user}:#{url.password}/, "USER:PASS")}'")
end

#orderObject



56
57
58
# File 'lib/feta/plugins/suse.rb', line 56

def order
  1
end

#to_sObject



39
40
41
# File 'lib/feta/plugins/suse.rb', line 39

def to_s
  self.class.to_s
end