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, #default_text_charset, #default_text_charset?, #deploy, deprecated, #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.



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

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

Instance Method Details

#apiObject



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

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

#appObject



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

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

#check_appObject



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

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

#check_authObject



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

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

#push_appObject



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

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



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

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

#restartObject



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

def restart
  app.restart
end

#setup_key(file, type = nil) ⇒ Object



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

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



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

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