Class: Kybus::CLI::Deployer

Inherits:
Object
  • Object
show all
Defined in:
lib/kybus/cli/bot/deployer.rb

Constant Summary collapse

DEFAULT_CONFIGS =
{
  'repo_path' => '.',
  'output_path' => './.kybusbotcode.zip'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Deployer

Returns a new instance of Deployer.



28
29
30
31
32
33
34
# File 'lib/kybus/cli/bot/deployer.rb', line 28

def initialize(options)
  @params = options
  load_kybusdeploy_file!
  @telegram = ::Kybus::CLI::BotDeployerTelegramConfigurator.new(nil, config_with_options)
  @lambda = ::Kybus::CLI::AWSBotDeployer.new(config_with_options)
  @job_executor = ::Kybus::CLI::AWSBotJobRunnerDeployer.new(config_with_options)
end

Instance Method Details

#compress_repo!Object



50
51
52
53
# File 'lib/kybus/cli/bot/deployer.rb', line 50

def compress_repo!
  code = ::Kybus::AWS::CodePackager.new(config_with_options)
  code.create_or_update!
end

#config_with_optionsObject



46
47
48
# File 'lib/kybus/cli/bot/deployer.rb', line 46

def config_with_options
  @config_with_options ||= DEFAULT_CONFIGS.merge(@config.merge(@params))
end

#deploy_lambda!Object



55
56
57
58
59
# File 'lib/kybus/cli/bot/deployer.rb', line 55

def deploy_lambda!
  @lambda.create_or_update!
  @job_executor.create_or_update!
  @telegram.url = @lambda.url
end

#destroyObject



67
68
69
70
# File 'lib/kybus/cli/bot/deployer.rb', line 67

def destroy
  @lambda.destroy!
  @telegram.destroy!
end

#load_kybusdeploy_file!Object



42
43
44
# File 'lib/kybus/cli/bot/deployer.rb', line 42

def load_kybusdeploy_file!
  @config = YAML.load_file('./kybusbot.yaml')
end

#runObject



61
62
63
64
65
# File 'lib/kybus/cli/bot/deployer.rb', line 61

def run
  compress_repo!
  deploy_lambda!
  @telegram.create_or_update!
end

#run_migrations!Object



36
37
38
39
40
# File 'lib/kybus/cli/bot/deployer.rb', line 36

def run_migrations!
  Rake::Task.clear
  load 'Rakefile'
  Rake::Task['db:migrate'].invoke
end