Sha256: 9c3ca02ac0a20331b3b7a7c165ec26a45df4ec3315ac9c782d8edcaec3d6da6b

Contents?: true

Size: 1.52 KB

Versions: 20

Compression:

Stored size: 1.52 KB

Contents

module DPL
  class Provider
    class CloudFoundry < Provider

      def initial_go_tools_install
        context.shell 'test x$TRAVIS_OS_NAME = "xlinux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz'
      end

      def check_auth
        initial_go_tools_install
        context.shell "./cf api #{option(:api)} #{'--skip-ssl-validation' if options[:skip_ssl_validation]}"
        options[:client_id] ? check_client_auth : check_basic_auth
      end

      def check_app
        if options[:manifest]
          error 'Application must have a manifest.yml for unattended deployment' unless File.exists? options[:manifest]
        end
      end

      def needs_key?
        false
      end

      def push_app
        error 'Failed to push app' unless context.shell("./cf push#{manifest}")

      ensure
        context.shell "./cf logout"
      end

      def cleanup
      end

      def uncleanup
      end

      def manifest
        options[:manifest].nil? ? "" : " -f #{options[:manifest]}"
      end

      private

      def check_basic_auth
        context.shell "./cf login -u #{option(:username)} -p #{option(:password)} -o '#{option(:organization)}' -s '#{option(:space)}'"
      end

      def check_client_auth
        context.shell "./cf auth #{option(:client_id)} #{option(:client_secret)} --client-credentials"
        context.shell "./cf target -o '#{option(:organization)}' -s '#{option(:space)}'"
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
dpl-cloud_foundry-1.10.4 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.5.travis.3062.5 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3055.5 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3054.5 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3053.5 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3047.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3040.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3032.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3031.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3030.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.3.travis.3021.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.4.travis.3022.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.3 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.3.travis.3020.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.3.travis.3017.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.3.travis.3014.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.2 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.3.travis.3002.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.2.travis.2993.6 lib/dpl/provider/cloud_foundry.rb
dpl-cloud_foundry-1.10.2.travis.2992.6 lib/dpl/provider/cloud_foundry.rb