Sha256: ebd321441faef6f67a98f46327da46cec2b0b4f28bf5bb339b0a2757afacfee0

Contents?: true

Size: 1.54 KB

Versions: 26

Compression:

Stored size: 1.54 KB

Contents

module DPL
  class Provider
    class Openshift < Provider
      requires 'httpclient', version: '~> 2.4.0'
      requires 'net-ssh',    load: 'net/ssh',    version: '~> 2.9.2' # Anything higher requires Ruby 2.x
      requires 'net-ssh-gateway', load: 'net/ssh/gateway',    version: '~> 1.3.0' # 2.0.0 requires net-ssh 4.0.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

26 entries across 26 versions & 2 rubygems

Version Path
dpl-1.8.48.travis.2486.5 lib/dpl/provider/openshift.rb
dpl-1.8.47 lib/dpl/provider/openshift.rb
dpl-1.8.47.travis.2485.5 lib/dpl/provider/openshift.rb
dpl-1.8.47.travis.2484.5 lib/dpl/provider/openshift.rb
dpl-1.8.47.travis.2483.5 lib/dpl/provider/openshift.rb
dpl-1.8.47.travis.2459.3 lib/dpl/provider/openshift.rb
dpl-1.8.47.travis.2458.3 lib/dpl/provider/openshift.rb
dpl-1.8.46 lib/dpl/provider/openshift.rb
dpl-1.8.47.travis.2456.5 lib/dpl/provider/openshift.rb
dpl-1.8.46.travis.2455.5 lib/dpl/provider/openshift.rb
dpl-1.8.46.travis.2454.5 lib/dpl/provider/openshift.rb
dpl-1.8.46.travis.2451.5 lib/dpl/provider/openshift.rb
dpl-1.8.46.travis.2449.5 lib/dpl/provider/openshift.rb
dpl-1.8.46.travis.2444.5 lib/dpl/provider/openshift.rb
dpl-1.8.45 lib/dpl/provider/openshift.rb
dpl-1.8.46.travis.2418.5 lib/dpl/provider/openshift.rb
dpl-1.8.45.travis.2417.5 lib/dpl/provider/openshift.rb
dpl-1.8.44 lib/dpl/provider/openshift.rb
dpl-1.8.45.travis.2398.5 lib/dpl/provider/openshift.rb
dpl-1.8.44.travis.2397.5 lib/dpl/provider/openshift.rb