Class: Dpl::Providers::Convox

Inherits:
Dpl::Provider show all
Defined in:
lib/dpl/providers/convox.rb

Constant Summary

Constants inherited from Dpl::Provider

Dpl::Provider::FOLDS, Dpl::Provider::STAGES

Instance Attribute Summary

Attributes inherited from Dpl::Provider

#key_name, #repo_name

Instance Method Summary collapse

Methods inherited from Dpl::Provider

#before_finish, #before_init, #before_install, #before_prepare, #before_setup, #chmod, #cleanup, #cmd, #compact, #err, #error, #escape, examples, #expand, #file?, #finish?, #fold, #fold?, #info, #initialize, install_deps, install_deps?, #mkdir_p, move_files, #msg, #mv, #only, #open, #opt_for, #opt_key, #opts_for, #print, #quote, #read, #remove_dpl_dir, #rm_rf, #run, #run_cmd, #run_cmds, #run_stage, #run_stage?, #script, #setup_dpl_dir, #setup_git_config, #setup_git_http_user_agent, #setup_git_ssh, #setup_ssh_key, #shell, #sq, #ssh_keygen, #symbolize, #try_ssh_access, #uncleanup, unmove_files, validate_runtimes, #wait_for_ssh_access, #warn

Methods included from Dpl::Provider::Dsl

#apt, #apt?, #cmds, #errs, #full_name, #gem, #gem?, #keep, #move, #msgs, #needs, #needs?, #node_js, #npm, #npm?, #opt, #path, #pip, #pip?, #python, #ruby_pre?, #ruby_version, #runtimes, #status, #strs, #summary, #user_agent, #vars

Methods included from Squiggle

#sq

Methods included from Assets

#asset

Methods included from Env

included, #opts

Methods included from ConfigFile

included, #opts

Methods included from Interpolate

#interpolate, #obfuscate, #vars

Methods included from Memoize

included

Constructor Details

This class inherits a constructor from Dpl::Provider

Instance Method Details

#deployObject



71
72
73
74
# File 'lib/dpl/providers/convox.rb', line 71

def deploy
  shell :set_env, echo: false unless env.empty?
  shell promote? ? :deploy : :build, echo: false
end

#descriptionObject



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/dpl/providers/convox.rb', line 94

def description
  description? ? super : JSON.dump(
    repo_slug: repo_slug,
    git_commit_sha: git_sha,
    git_commit_message: git_commit_msg,
    git_commit_author: git_author_name,
    git_tag: git_tag,
    branch: git_branch,
    travis_build_id: ENV['TRAVIS_BUILD_ID'],
    travis_build_number: ENV['TRAVIS_BUILD_NUMBER'],
    pull_request: ENV['TRAVIS_PULL_REQUEST']
  )
end

#envObject



82
83
84
85
# File 'lib/dpl/providers/convox.rb', line 82

def env
  env = env_names.concat(super || [])
  env.map { |str| escape(str) }.join(' ')
end

#env_fileObject



87
88
89
90
91
92
# File 'lib/dpl/providers/convox.rb', line 87

def env_file
  return [] unless env_file?
  error :env_file unless file?(super)
  lines = read(super).split("\n").map(&:strip)
  lines.reject(&:empty?)
end

#env_namesObject



76
77
78
79
80
# File 'lib/dpl/providers/convox.rb', line 76

def env_names
  env = super || []
  env = env.map { |str| "#{str}=#{ENV[str]}" }
  env_file.concat(env)
end

#env_varsObject



112
113
114
115
116
117
118
119
120
# File 'lib/dpl/providers/convox.rb', line 112

def env_vars
  {
    CONVOX_HOST: host,
    CONVOX_PASSWORD: password,
    CONVOX_APP: app,
    CONVOX_RACK: rack,
    CONVOX_CLI: 'convox'
  }
end

#exportObject



108
109
110
# File 'lib/dpl/providers/convox.rb', line 108

def export
  env_vars.each { |key, value| ENV[key.to_s] = value.to_s }
end

#installObject



49
50
51
52
53
# File 'lib/dpl/providers/convox.rb', line 49

def install
  script :install
  shell :update if update_cli?
  export
end

#loginObject



55
56
57
# File 'lib/dpl/providers/convox.rb', line 55

def 
  shell :login
end

#prepareObject



65
66
67
68
69
# File 'lib/dpl/providers/convox.rb', line 65

def prepare
  Array(super).each do |cmd|
    cmd.casecmp('restart').zero? ? restart : run_cmd(cmd)
  end
end

#validateObject



59
60
61
62
63
# File 'lib/dpl/providers/convox.rb', line 59

def validate
  shell :validate, assert: false and return
  error :missing unless create?
  shell :create
end