Class: DPL::Provider::Openshift

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

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from DPL::Provider

apt_get, #cleanup, context, #create_key, #deploy, #error, experimental, #log, #needs_key?, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup

Constructor Details

#initialize(context, options) ⇒ Openshift

Returns a new instance of Openshift.



6
7
8
9
# File 'lib/dpl/provider/openshift.rb', line 6

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

Instance Method Details

#apiObject



11
12
13
# File 'lib/dpl/provider/openshift.rb', line 11

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

#appObject



19
20
21
# File 'lib/dpl/provider/openshift.rb', line 19

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

#check_appObject



27
28
29
# File 'lib/dpl/provider/openshift.rb', line 27

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

#check_authObject



23
24
25
# File 'lib/dpl/provider/openshift.rb', line 23

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

#push_appObject



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

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



36
37
38
# File 'lib/dpl/provider/openshift.rb', line 36

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

#restartObject



50
51
52
# File 'lib/dpl/provider/openshift.rb', line 50

def restart
  app.restart
end

#setup_key(file, type = nil) ⇒ Object



31
32
33
34
# File 'lib/dpl/provider/openshift.rb', line 31

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



15
16
17
# File 'lib/dpl/provider/openshift.rb', line 15

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