class DPL::Provider::Scalingo
Public Class Methods
new(context, options)
click to toggle source
Calls superclass method
# File lib/dpl/provider/scalingo.rb, line 24 def initialize(context, options) super @options = options @remote = options[:remote] || 'scalingo-dpl' @branch = options[:branch] || 'master' @region = options[:region] || 'agora-fr1' @timeout = options[:timeout] || '60' @debug = !options[:debug].nil? end
Public Instance Methods
check_auth()
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 34 def check_auth if token scalingo("login --api-token #{token}") elsif username && @options[:password] scalingo('login', [], "echo -e \"#{username}\n#{@options[:password]}\"") end end
install_deploy_dependencies()
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 9 def install_deploy_dependencies download_url = 'https://cli-dl.scalingo.io/release/scalingo_latest_linux_amd64.tar.gz' command = 'curl' command = "#{command} --silent" if !@debug command = "#{command} --remote-name --location #{download_url}" tar_options = 'v' if @debug tar_options = "#{tar_options}zxf" command = "#{command} && tar -#{tar_options} scalingo_latest_linux_amd64.tar.gz" \ ' && mv scalingo_*_linux_amd64/scalingo .' \ ' && rm scalingo_latest_linux_amd64.tar.gz' \ ' && rm -r scalingo_*_linux_amd64' error "Couldn't install Scalingo CLI." if !context.shell command end
push_app()
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 54 def push_app install_deploy_dependencies if @options[:app] if !scalingo("--app #{@options[:app]} git-setup --remote #{@remote}") error 'Failed to add the Git remote.' end end if !context.shell "git push #{@remote} #{@branch} --force" error "Couldn't push your app." end end
remove_key()
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 48 def remove_key if !scalingo('keys-remove dpl_tmp_key') error "Couldn't remove SSH key." end end
scalingo(command, env = [], input = '')
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 76 def scalingo(command, env = [], input = '') env << "SCALINGO_REGION=#{@region}" if !@region.empty? if @debug env << 'DEBUG=1' else command += ' > /dev/null' end command = "#{env.join(' ')} timeout #{@timeout} ./scalingo #{command}" command = "#{input} | #{command}" if input != '' puts "Execute #{command}" if @debug context.shell command end
setup_key(file, _type = nil)
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 42 def setup_key(file, _type = nil) if !scalingo("keys-add dpl_tmp_key #{file}") error "Couldn't add SSH key." end end
token()
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 72 def token @options[:api_key] || @options[:api_token] end
username()
click to toggle source
# File lib/dpl/provider/scalingo.rb, line 68 def username @options[:username] || @options[:user] end