Class: DPL::Provider::Openshift
- Inherits:
-
DPL::Provider
- Object
- DPL::Provider
- DPL::Provider::Openshift
- Defined in:
- lib/dpl/provider/openshift.rb
Instance Method Summary collapse
- #api ⇒ Object
- #app ⇒ Object
- #check_app ⇒ Object
- #check_auth ⇒ Object
-
#initialize(context, options) ⇒ Openshift
constructor
A new instance of Openshift.
- #push_app ⇒ Object
- #remove_key ⇒ Object
- #restart ⇒ Object
- #setup_key(file, type = nil) ⇒ Object
- #user ⇒ Object
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, ) super @deployment_branch = [:deployment_branch] end |
Instance Method Details
#api ⇒ Object
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 |
#app ⇒ Object
21 22 23 |
# File 'lib/dpl/provider/openshift.rb', line 21 def app @app ||= api.find_application(option(:domain), option(:app)) end |
#check_app ⇒ Object
29 30 31 |
# File 'lib/dpl/provider/openshift.rb', line 29 def check_app log "found app #{app.name}" end |
#check_auth ⇒ Object
25 26 27 |
# File 'lib/dpl/provider/openshift.rb', line 25 def check_auth log "authenticated as %s" % user end |
#push_app ⇒ Object
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_key ⇒ Object
38 39 40 |
# File 'lib/dpl/provider/openshift.rb', line 38 def remove_key api.delete_key(option(:key_name)) end |
#restart ⇒ Object
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 |
#user ⇒ Object
17 18 19 |
# File 'lib/dpl/provider/openshift.rb', line 17 def user @user ||= api.user.login end |