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, environment) ⇒ PushFromLocal

Returns a new instance of PushFromLocal.



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

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

Instance Method Details

#run(_) ⇒ Object



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 27

def run(_)
  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



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

def usage
  [command_name,
   "Push the contents of final_app to the #{environment} host specified in credentials.yml"]
end