Class: Dockerploy::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/dockerploy/configuration.rb

Constant Summary collapse

NoEnvError =
Class.new(StandardError)
FileNotFound =
Class.new(StandardError)
DEFAULT_CONFIG_FILE =
'docker/config.yml'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.

Raises:



9
10
11
12
13
14
15
16
17
18
# File 'lib/dockerploy/configuration.rb', line 9

def initialize(options = {})
  @config_file = options.fetch(:config_file, DEFAULT_CONFIG_FILE)
  @env = options.fetch(:env)
  @env = @env.to_sym if @env
  raise FileNotFound unless File.exist?(@config_file)
  config = YAML.load_file(@config_file).symbolize_keys
  @application_name = config.fetch(:application_name)
  @docker_host = config.fetch(:docker_host)
  @image_name = config.fetch(:image_name)
end

Instance Attribute Details

#application_nameObject (readonly)

Returns the value of attribute application_name.



7
8
9
# File 'lib/dockerploy/configuration.rb', line 7

def application_name
  @application_name
end

#docker_hostObject (readonly)

Returns the value of attribute docker_host.



7
8
9
# File 'lib/dockerploy/configuration.rb', line 7

def docker_host
  @docker_host
end

#envObject (readonly)

Returns the value of attribute env.



7
8
9
# File 'lib/dockerploy/configuration.rb', line 7

def env
  @env
end

#image_nameObject (readonly)

Returns the value of attribute image_name.



7
8
9
# File 'lib/dockerploy/configuration.rb', line 7

def image_name
  @image_name
end

Instance Method Details

#after_all_hooksObject



63
64
65
66
# File 'lib/dockerploy/configuration.rb', line 63

def after_all_hooks
  return {} if options[:hooks].nil? || options[:hooks][:after_deploy].nil?
  options[:hooks][:after_deploy]
end

#after_hooksObject

Raises:



68
69
70
71
72
73
74
# File 'lib/dockerploy/configuration.rb', line 68

def after_hooks
  raise NoEnvError if @env.nil?
  return {} if options[@env].nil?
  hooks = options[@env][:hooks]
  return {} if hooks.nil? || hooks[:after_deploy].nil?
  hooks[:after_deploy]
end

#before_all_hooksObject



50
51
52
53
# File 'lib/dockerploy/configuration.rb', line 50

def before_all_hooks
  return {} if options[:hooks].nil? || options[:hooks][:before_deploy].nil?
  options[:hooks][:before_deploy]
end

#before_hooksObject

Raises:



55
56
57
58
59
60
61
# File 'lib/dockerploy/configuration.rb', line 55

def before_hooks
  raise NoEnvError if @env.nil?
  return {} if options[@env].nil?
  hooks = options[@env][:hooks]
  return {} if hooks.nil? || hooks[:before_deploy].nil?
  hooks[:before_deploy]
end

#branchObject

Raises:



35
36
37
38
# File 'lib/dockerploy/configuration.rb', line 35

def branch
  raise NoEnvError if @env.nil?
  options[@env][:branch]
end

#env_fileObject

Raises:



30
31
32
33
# File 'lib/dockerploy/configuration.rb', line 30

def env_file
  raise NoEnvError if @env.nil?
  options[@env][:env_file]
end

#image_tagObject

Raises:



45
46
47
48
# File 'lib/dockerploy/configuration.rb', line 45

def image_tag
  raise NoEnvError if @env.nil?
  options[@env][:image_tag]
end

#serversObject

Raises:



20
21
22
23
# File 'lib/dockerploy/configuration.rb', line 20

def servers
  raise NoEnvError if @env.nil?
  options[@env][:servers]
end

#tagging?Boolean

Returns:

  • (Boolean)

Raises:



40
41
42
43
# File 'lib/dockerploy/configuration.rb', line 40

def tagging?
  raise NoEnvError if @env.nil?
  options[@env][:tagging]
end

#volumesObject

Raises:



25
26
27
28
# File 'lib/dockerploy/configuration.rb', line 25

def volumes
  raise NoEnvError if @env.nil?
  options[@env][:volumes]
end