Class: Shipitron::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/shipitron/cli.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap(app) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/shipitron/cli.rb', line 123

def bootstrap(app)
  setup(
    secrets_file: options[:secrets_file]
  )

  require 'shipitron/client/bootstrap_application'
  result = Client::BootstrapApplication.call(
    application: app,
    region: options[:region],
    cluster_name: options[:cluster_name],
    service_count: options[:service_count],
    task_def_directory: options[:task_def_dir],
    service_directory: options[:service_dir]
  )

  if result.failure?
    result.error_messages.each do |error|
      Logger.fatal error
    end
    Logger.fatal 'Bootstrap failed.'
  end
end

#deploy(app) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/shipitron/cli.rb', line 19

def deploy(app)
  setup(
    config_file: options[:config_file],
    secrets_file: options[:secrets_file],
    global_config_file: options[:global_config_file]
  )

  require 'shipitron/client/deploy_application'
  result = Client::DeployApplication.call(
    application: app,
    simulate: options[:simulate],
    simulate_store_deploy: options[:simulate_store_deploy]
  )

  if result.failure?
    result.error_messages.each do |error|
      Logger.fatal error
    end
    Logger.fatal 'Deploy failed.'
  end
end

#force_deploy(app) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/shipitron/cli.rb', line 45

def force_deploy(app)
  setup(
    config_file: options[:config_file],
    secrets_file: options[:secrets_file]
  )

  require 'shipitron/client/force_deploy'
  result = Client::ForceDeploy.call(
    application: app
  )

  if result.failure?
    result.error_messages.each do |error|
      Logger.fatal error
    end
    Logger.fatal 'Deploy failed.'
  end
end

#server_deployObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/shipitron/cli.rb', line 67

def server_deploy
  setup

  if !ENV.key?("SHIPITRON_DEPLOY_BUCKET") || !ENV.key?("SHIPITRON_DEPLOY_BUCKET_REGION")
    raise "Missing shipitron deploy bucket env vars!"
  end

  require 'shipitron/server/fetch_deploy'
  deploy_options = Server::FetchDeploy.call!(
    deploy_bucket: ENV["SHIPITRON_DEPLOY_BUCKET"],
    deploy_bucket_region: ENV["SHIPITRON_DEPLOY_BUCKET_REGION"],
    deploy_id: options[:deploy_id]
  ).deploy_options

  require 'shipitron/server/transform_cli_args'
  cli_args = Server::TransformCliArgs.call!(
    application: deploy_options[:name],
    repository_url: deploy_options[:repository],
    repository_branch: deploy_options[:repository_branch],
    registry: deploy_options[:registry],
    s3_cache_bucket: deploy_options[:bucket],
    build_cache_location: deploy_options[:build_cache_location],
    image_name: deploy_options[:image_name],
    named_tag: deploy_options[:named_tag],
    skip_push: deploy_options[:skip_push],
    region: deploy_options[:region],
    clusters: deploy_options[:clusters],
    ecs_task_defs: deploy_options[:ecs_task_defs],
    ecs_task_def_templates: deploy_options[:ecs_task_def_templates],
    ecs_services: deploy_options[:ecs_services],
    ecs_service_templates: deploy_options[:ecs_service_templates],
    build_script: deploy_options[:build_script],
    post_builds: deploy_options[:post_builds]
  ).cli_args

  require 'shipitron/server/deploy_application'
  result = Server::DeployApplication.call(
    cli_args
  )

  if result.failure?
    result.error_messages.each do |error|
      Logger.fatal error
    end
    Logger.fatal 'Deploy failed.'
  end
end

#versionObject



7
8
9
10
# File 'lib/shipitron/cli.rb', line 7

def version
  require 'shipitron/version'
  say Shipitron::VERSION.to_s
end