Class: Broadside::Configuration

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, InvalidConfiguration
Defined in:
lib/broadside/configuration/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InvalidConfiguration

#method_missing

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



34
35
36
37
38
39
40
41
# File 'lib/broadside/configuration/configuration.rb', line 34

def initialize
  @aws = AwsConfiguration.new
  @logger = ::Logger.new(STDOUT)
  @logger.level = ::Logger::INFO
  @logger.datetime_format = '%Y-%m-%d_%H:%M:%S'
  @ssh = {}
  @timeout = 600
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Broadside::InvalidConfiguration

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def application
  @application
end

#awsObject (readonly)

Returns the value of attribute aws.



8
9
10
# File 'lib/broadside/configuration/configuration.rb', line 8

def aws
  @aws
end

#config_fileObject

Returns the value of attribute config_file.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def config_file
  @config_file
end

#default_docker_imageObject

Returns the value of attribute default_docker_image.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def default_docker_image
  @default_docker_image
end

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def logger
  @logger
end

#posthookObject

Returns the value of attribute posthook.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def posthook
  @posthook
end

#prehookObject

Returns the value of attribute prehook.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def prehook
  @prehook
end

#sshObject

Returns the value of attribute ssh.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def ssh
  @ssh
end

#targetsObject

Returns the value of attribute targets.



8
9
10
# File 'lib/broadside/configuration/configuration.rb', line 8

def targets
  @targets
end

#timeoutObject

Returns the value of attribute timeout.



12
13
14
# File 'lib/broadside/configuration/configuration.rb', line 12

def timeout
  @timeout
end

Instance Method Details

#get_target_by_name!(name) ⇒ Object



52
53
54
# File 'lib/broadside/configuration/configuration.rb', line 52

def get_target_by_name!(name)
  @targets.fetch(name) { raise ArgumentError, "Deploy target '#{name}' does not exist!" }
end

#ssh_cmd(ip, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/broadside/configuration/configuration.rb', line 56

def ssh_cmd(ip, options = {})
  cmd = 'ssh -o StrictHostKeyChecking=no'
  cmd << ' -t -t' if options[:tty]
  cmd << " -i #{@ssh[:keyfile]}" if @ssh[:keyfile]
  if (proxy = @ssh[:proxy])
    cmd << ' -o ProxyCommand="ssh -q'
    cmd << " -i #{proxy[:keyfile]}" if proxy[:keyfile]
    cmd << ' '
    cmd << "#{proxy[:user]}@" if proxy[:user]
    cmd << "#{proxy[:host]} nc #{ip} #{proxy[:port]}\""
  end
  cmd << ' '
  cmd << "#{@ssh[:user]}@" if @ssh[:user]
  cmd << ip.to_s
  cmd
end