Class: Bookbinder::Commands::PushToProd

Inherits:
Object
  • Object
show all
Includes:
Naming
Defined in:
lib/bookbinder/commands/push_to_prod.rb

Constant Summary collapse

MissingRequiredKeyError =
Class.new(RuntimeError)

Instance Method Summary collapse

Methods included from Naming

#command_for?, #command_type, #flag?

Constructor Details

#initialize(streams, logger, configuration_fetcher, app_dir) ⇒ PushToProd

Returns a new instance of PushToProd.



12
13
14
15
16
17
# File 'lib/bookbinder/commands/push_to_prod.rb', line 12

def initialize(streams, logger, configuration_fetcher, app_dir)
  @streams = streams
  @logger = logger
  @configuration_fetcher = configuration_fetcher
  @app_dir = app_dir
end

Instance Method Details

#run(build_number) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bookbinder/commands/push_to_prod.rb', line 24

def run((build_number))
  streams[:warn].puts "Warning: You are pushing to production."
  validate
  deployment = Deploy::Deployment.new(
    app_dir: app_dir,
    build_number: build_number,
    aws_credentials: credentials[:aws],
    cf_credentials: credentials[:cloud_foundry],
    book_repo: config.book_repo,
  )
  archive = Deploy::Archive.new(
    logger: @logger,
    key: deployment.aws_access_key,
    secret: deployment.aws_secret_key
  )
  archive.download(download_dir: deployment.app_dir,
                   bucket: deployment.green_builds_bucket,
                   build_number: deployment.build_number,
                   namespace: deployment.namespace)
  Deploy::Distributor.build(streams, archive, deployment).distribute
  0
end

#usageObject



19
20
21
22
# File 'lib/bookbinder/commands/push_to_prod.rb', line 19

def usage
  ["push_to_prod [build_#]",
   "Push latest or <build_#> from your S3 bucket to the production host specified in credentials.yml"]
end