Sha256: 45c61c01393d22b648f1d79fda9a6a98a9da891fb953c9a2b73b99a64fc959bc

Contents?: true

Size: 1.33 KB

Versions: 223

Compression:

Stored size: 1.33 KB

Contents

module DPL
  class Provider
    class Openshift < Provider
      requires 'httpclient', version: '~> 2.4.0'
      requires 'rhc'

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

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

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

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

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

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

      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

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

      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

      def restart
        app.restart
      end

    end
  end
end

Version data entries

223 entries across 223 versions & 1 rubygems

Version Path
dpl-1.8.18.travis.1563.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1561.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1558.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1553.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1552.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1551.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1544.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1543.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1530.3 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1529.4 lib/dpl/provider/openshift.rb
dpl-1.8.13.travis.1528.4 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1527.4 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1518.4 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1496.4 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1492.4 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1489.4 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1472.4 lib/dpl/provider/openshift.rb
dpl-1.8.17 lib/dpl/provider/openshift.rb
dpl-1.8.18.travis.1465.4 lib/dpl/provider/openshift.rb
dpl-1.8.17.travis.1464.4 lib/dpl/provider/openshift.rb