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, #commit_msg, context, #create_key, #deploy, #detect_encoding?, #encoding_for, #error, experimental, #log, #needs_key?, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn

Constructor Details

#initialize(context, options) ⇒ Openshift

Returns a new instance of Openshift.



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

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

Instance Method Details

#apiObject



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

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

#appObject



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

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

#check_appObject



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

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

#check_authObject



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

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

#push_appObject



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

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



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

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

#restartObject



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

def restart
  app.restart
end

#setup_key(file, type = nil) ⇒ Object



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

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



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

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