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



73
74
75
76
# File 'lib/dpl/providers/convox.rb', line 73

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

#descriptionObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/dpl/providers/convox.rb', line 97

def description
  if description?
    super
  else
    JSON.dump(
      repo_slug:,
      git_commit_sha: git_sha,
      git_commit_message: git_commit_msg,
      git_commit_author: git_author_name,
      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
end

#envObject



84
85
86
87
# File 'lib/dpl/providers/convox.rb', line 84

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

#env_fileObject



89
90
91
92
93
94
95
# File 'lib/dpl/providers/convox.rb', line 89

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



78
79
80
81
82
# File 'lib/dpl/providers/convox.rb', line 78

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

#env_varsObject



119
120
121
122
123
124
125
126
127
# File 'lib/dpl/providers/convox.rb', line 119

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

#exportObject



115
116
117
# File 'lib/dpl/providers/convox.rb', line 115

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

#installObject



51
52
53
54
55
# File 'lib/dpl/providers/convox.rb', line 51

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

#loginObject



57
58
59
# File 'lib/dpl/providers/convox.rb', line 57

def 
  shell :login
end

#prepareObject



67
68
69
70
71
# File 'lib/dpl/providers/convox.rb', line 67

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

#validateObject



61
62
63
64
65
# File 'lib/dpl/providers/convox.rb', line 61

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