Class: DPL::Provider::Openshift

Inherits:
DPL::Provider show all
Defined in:
lib/dpl/provider/openshift.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, options) ⇒ Openshift

Returns a new instance of Openshift.



8
9
10
11
# File 'lib/dpl/provider/openshift.rb', line 8

def initialize(context, options)
  super
  @deployment_branch = options[:deployment_branch]
end

Instance Method Details

#apiObject



13
14
15
# File 'lib/dpl/provider/openshift.rb', line 13

def api
  @api ||= ::RHC::Rest::Client.new(:user => option(:user), :password => option(:password), :server => 'openshift.redhat.com')
end

#appObject



21
22
23
# File 'lib/dpl/provider/openshift.rb', line 21

def app
  @app ||= api.find_application(option(:domain), option(:app))
end

#check_appObject



29
30
31
# File 'lib/dpl/provider/openshift.rb', line 29

def check_app
  log "found app #{app.name}"
end

#check_authObject



25
26
27
# File 'lib/dpl/provider/openshift.rb', line 25

def check_auth
  log "authenticated as %s" % user
end

#push_appObject



42
43
44
45
46
47
48
49
50
# File 'lib/dpl/provider/openshift.rb', line 42

def push_app
  if @deployment_branch
    log "deployment_branch detected: #{@deployment_branch}"
    app.deployment_branch = @deployment_branch
    context.shell "git push #{app.git_url} -f #{app.deployment_branch}"
  else
    context.shell "git push #{app.git_url} -f"
  end
end

#remove_keyObject



38
39
40
# File 'lib/dpl/provider/openshift.rb', line 38

def remove_key
  api.delete_key(option(:key_name))
end

#restartObject



52
53
54
# File 'lib/dpl/provider/openshift.rb', line 52

def restart
  app.restart
end

#setup_key(file, type = nil) ⇒ Object



33
34
35
36
# File 'lib/dpl/provider/openshift.rb', line 33

def setup_key(file, type = nil)
  specified_type, content, comment = File.read(file).split
  api.add_key(option(:key_name), content, type || specified_type)
end

#userObject



17
18
19
# File 'lib/dpl/provider/openshift.rb', line 17

def user
  @user ||= api.user.
end