Class: Bookbinder::Commands::PushFromLocal

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

Constant Summary collapse

CredentialKeyError =
Class.new(RuntimeError)
FeedbackConfigError =
Class.new(RuntimeError)
REQUIRED_AWS_KEYS =
%w(access_key secret_key green_builds_bucket)
REQUIRED_CF_KEYS =
%w(username password api_endpoint organization app_name)

Instance Method Summary collapse

Methods included from Naming

#command_for?, #command_type, #flag?

Constructor Details

#initialize(streams, logger, configuration_fetcher) ⇒ PushFromLocal

Returns a new instance of PushFromLocal.



15
16
17
18
19
# File 'lib/bookbinder/commands/push_from_local.rb', line 15

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

Instance Method Details

#run(cli_arguments) ⇒ Object



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

def run(cli_arguments)
  @environment = cli_arguments.first
  validate
  deployment = Deploy::Deployment.new(
    app_dir: './final_app',
    aws_credentials: credentials[:aws],
    book_repo: config.book_repo,
    build_number: ENV['BUILD_NUMBER'],
    cf_credentials: credentials[:cloud_foundry]
  )
  archive = Deploy::Archive.new(
    logger: @logger,
    key: deployment.aws_access_key,
    secret: deployment.aws_secret_key
  )
  Deploy::Distributor.build(
    streams,
    archive,
    deployment
  ).distribute
  0
end

#usageObject



21
22
23
24
# File 'lib/bookbinder/commands/push_from_local.rb', line 21

def usage
  ["push_local_to <environment>",
   "Push the contents of final_app to the specified environment using the credentials.yml"]
end