Class: Jack::Deploy

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/jack/deploy.rb

Instance Method Summary collapse

Methods included from Util

#app_name_convention, #aws_bin, #check_aws_setup, #confirm, #eb, #eb_base_flags, #eb_bin, #ensure_folder_exist, #get_answer, #get_region, #prerequisites, #settings, #sh

Constructor Details

#initialize(options = {}) ⇒ Deploy

Returns a new instance of Deploy.



5
6
7
8
9
10
# File 'lib/jack/deploy.rb', line 5

def initialize(options={})
  @options = options
  @root = options[:root] || '.'
  @env_name = options[:env_name]
  @app_name = options[:app] || app_name_convention(@env_name)
end

Instance Method Details

#deployObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/jack/deploy.rb', line 28

def deploy
  # EB_OPTIONS are passed through to the underlying eb deploy command
  #
  # optional arguments:
  #   -h, --help            show this help message and exit
  #   --debug               toggle debug output
  #   --quiet               suppress all output
  #   -v, --verbose         toggle verbose output
  #   --profile PROFILE     use a specific profile from your credential file
  #   -r REGION, --region REGION
  #                         use a specific region
  #   --no-verify-ssl       do not verify AWS SSL certificates
  #   --modules [MODULES [MODULES ...]]
  #                         modules to deploy
  #   -g ENV_GROUP_SUFFIX, --env-group-suffix ENV_GROUP_SUFFIX
  #                         group suffix
  #   --version VERSION     existing version label to deploy
  #   -l LABEL, --label LABEL
  #                         label name which version will be given
  #   -m MESSAGE, --message MESSAGE
  #                         description for version
  #   -nh, --nohang         return immediately, do not wait for deploy to be
  #                         completed
  #   --staged              deploy files staged in git rather than the HEAD commit
  #   --timeout TIMEOUT     timeout period in minutes
  #   --source SOURCE       source of code to deploy directly; example
  #                         source_location/repo/branch
  #   -p, --process         enable preprocessing of the application version
  command = "#{eb_bin} deploy#{eb_base_flags} #{@env_name} #{ENV['EB_OPTIONS']}"
  sh(command)
end

#environment_exists?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/jack/deploy.rb', line 22

def environment_exists?
  return true if @options[:noop]
  r = eb.describe_environments(application_name: @app_name)
  r.environments.collect(&:environment_name).include?(@env_name)
end

#runObject



12
13
14
15
16
17
18
19
20
# File 'lib/jack/deploy.rb', line 12

def run
  unless @options[:noop] || environment_exists?
    UI.say("ERROR: Environment #{@env_name} does not appear to exist. Are you sure it exists?")
    exit 1 unless ENV['TEST']
  end

  prerequisites
  deploy
end