Sha256: 611917887859e80e3a845870aeae2f27dd29d97b7291ef989d13210283ae1639

Contents?: true

Size: 1.96 KB

Versions: 79

Compression:

Stored size: 1.96 KB

Contents

module DPL
  class Provider
    class BluemixCloudFoundry < Provider

      # NOTE: Much of this class is duplicated from CloudFoundry.
      # This is by design. By duplicating a manageable amount of
      # code here, we prevent this provider and its gem `dpl-bluemix_cloud_foundry`
      # from having a dependency on `dpl-cloudfoundry`.
      # Having less dependency is desirable when we install this gem
      # from source.

      REGIONS = Hash.new {"api.ng.bluemix.net"}.update(
        "eu-gb" => "api.eu-gb.bluemix.net",
        "eu-de" => "api.eu-de.bluemix.net",
        "au-syd" => "api.au-syd.bluemix.net"
      )

      def initial_go_tools_install
        context.shell 'test $(uname) = "Linux" && 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
        set_api
        initial_go_tools_install
        context.shell "./cf api #{option(:api)} #{'--skip-ssl-validation' if options[:skip_ssl_validation]}"
        context.shell "./cf login -u #{option(:username)} -p #{option(:password)} -o #{option(:organization)} -s #{option(:space)}"
      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#{app_name}#{manifest}")

      ensure
        context.shell "./cf logout"
      end

      def cleanup
      end

      def uncleanup
      end

      def app_name
        options[:app_name].nil? ? "" : " '#{options[:app_name]}'"
      end

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

      def set_api
        region = options[:region] || "ng"
        options[:api] = options[:api] || REGIONS[region]
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 2 rubygems

Version Path
dpl-cloud_foundry-1.10.11.travis.3497.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.10 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.10 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.9 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.9 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.9.travis.3280.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.9.travis.3280.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.9.travis.3258.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.9.travis.3258.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.8 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.8 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.8.travis.3236.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.8.travis.3236.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.8.travis.3216.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.8.travis.3216.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.7 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.7 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-bluemix_cloud_foundry-1.10.8.travis.3178.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.8.travis.3178.5 lib/dpl/provider/bluemix_cloud_foundry.rb
dpl-cloud_foundry-1.10.7.travis.3177.5 lib/dpl/provider/bluemix_cloud_foundry.rb