Class: Indocker::Configurations::Configuration
- Inherits:
-
Object
- Object
- Indocker::Configurations::Configuration
- Defined in:
- lib/indocker/configurations/configuration.rb
Instance Attribute Summary collapse
-
#artifact_servers ⇒ Object
readonly
Returns the value of attribute artifact_servers.
-
#build_servers ⇒ Object
readonly
Returns the value of attribute build_servers.
-
#confirm_deployment ⇒ Object
readonly
Returns the value of attribute confirm_deployment.
-
#containers ⇒ Object
readonly
Returns the value of attribute containers.
-
#env_files ⇒ Object
readonly
Returns the value of attribute env_files.
-
#global_build_args ⇒ Object
readonly
Returns the value of attribute global_build_args.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#networks ⇒ Object
readonly
Returns the value of attribute networks.
-
#registries ⇒ Object
readonly
Returns the value of attribute registries.
-
#repositories ⇒ Object
readonly
Returns the value of attribute repositories.
-
#volumes ⇒ Object
readonly
Returns the value of attribute volumes.
Instance Method Summary collapse
- #add_build_server(build_server) ⇒ Object
- #add_container(container) ⇒ Object
- #add_image(image) ⇒ Object
- #build_dir ⇒ Object
- #container(name) ⇒ Object
- #container_enabled?(container) ⇒ Boolean
- #enabled_containers ⇒ Object
- #get_binding ⇒ Object
- #hostname(container, number) ⇒ Object
-
#initialize(name) ⇒ Configuration
constructor
A new instance of Configuration.
- #next_build_server ⇒ Object
- #servers ⇒ Object
- #set_artifact_servers(artifact, servers) ⇒ Object
- #set_confirm_deployment(flag) ⇒ Object
- #set_enabled_containers(list) ⇒ Object
- #set_env_file(alias_name, env_file) ⇒ Object
- #set_global_build_args(hash) ⇒ Object
- #set_registry(alias_name, registry) ⇒ Object
- #set_repository(alias_name, repository) ⇒ Object
Constructor Details
#initialize(name) ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/indocker/configurations/configuration.rb', line 15 def initialize(name) @name = name @repositories = {} @registries = {} @env_files = {} @build_servers = [] @images = [] @volumes = [] @networks = [] @containers = [] @artifact_servers = {} @confirm_deployment = false end |
Instance Attribute Details
#artifact_servers ⇒ Object (readonly)
Returns the value of attribute artifact_servers.
12 13 14 |
# File 'lib/indocker/configurations/configuration.rb', line 12 def artifact_servers @artifact_servers end |
#build_servers ⇒ Object (readonly)
Returns the value of attribute build_servers.
5 6 7 |
# File 'lib/indocker/configurations/configuration.rb', line 5 def build_servers @build_servers end |
#confirm_deployment ⇒ Object (readonly)
Returns the value of attribute confirm_deployment.
13 14 15 |
# File 'lib/indocker/configurations/configuration.rb', line 13 def confirm_deployment @confirm_deployment end |
#containers ⇒ Object (readonly)
Returns the value of attribute containers.
8 9 10 |
# File 'lib/indocker/configurations/configuration.rb', line 8 def containers @containers end |
#env_files ⇒ Object (readonly)
Returns the value of attribute env_files.
11 12 13 |
# File 'lib/indocker/configurations/configuration.rb', line 11 def env_files @env_files end |
#global_build_args ⇒ Object (readonly)
Returns the value of attribute global_build_args.
6 7 8 |
# File 'lib/indocker/configurations/configuration.rb', line 6 def global_build_args @global_build_args end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
7 8 9 |
# File 'lib/indocker/configurations/configuration.rb', line 7 def images @images end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/indocker/configurations/configuration.rb', line 2 def name @name end |
#networks ⇒ Object (readonly)
Returns the value of attribute networks.
10 11 12 |
# File 'lib/indocker/configurations/configuration.rb', line 10 def networks @networks end |
#registries ⇒ Object (readonly)
Returns the value of attribute registries.
4 5 6 |
# File 'lib/indocker/configurations/configuration.rb', line 4 def registries @registries end |
#repositories ⇒ Object (readonly)
Returns the value of attribute repositories.
3 4 5 |
# File 'lib/indocker/configurations/configuration.rb', line 3 def repositories @repositories end |
#volumes ⇒ Object (readonly)
Returns the value of attribute volumes.
9 10 11 |
# File 'lib/indocker/configurations/configuration.rb', line 9 def volumes @volumes end |
Instance Method Details
#add_build_server(build_server) ⇒ Object
81 82 83 84 85 |
# File 'lib/indocker/configurations/configuration.rb', line 81 def add_build_server(build_server) if !@build_servers.include?(build_server) @build_servers.push(build_server) end end |
#add_container(container) ⇒ Object
95 96 97 |
# File 'lib/indocker/configurations/configuration.rb', line 95 def add_container(container) @containers.push(container) end |
#add_image(image) ⇒ Object
91 92 93 |
# File 'lib/indocker/configurations/configuration.rb', line 91 def add_image(image) @images.push(image) end |
#build_dir ⇒ Object
111 112 113 |
# File 'lib/indocker/configurations/configuration.rb', line 111 def build_dir "/tmp/#{@name}" end |
#container(name) ⇒ Object
41 42 43 |
# File 'lib/indocker/configurations/configuration.rb', line 41 def container(name) @containers.detect {|c| c.name == name} end |
#container_enabled?(container) ⇒ Boolean
53 54 55 |
# File 'lib/indocker/configurations/configuration.rb', line 53 def container_enabled?(container) @enabled_containers.include?(container.name) end |
#enabled_containers ⇒ Object
49 50 51 |
# File 'lib/indocker/configurations/configuration.rb', line 49 def enabled_containers @enabled_containers || (raise ArgumentError.new("enabled container list was not specified in configuration")) end |
#get_binding ⇒ Object
119 120 121 |
# File 'lib/indocker/configurations/configuration.rb', line 119 def get_binding binding end |
#hostname(container, number) ⇒ Object
115 116 117 |
# File 'lib/indocker/configurations/configuration.rb', line 115 def hostname(container, number) Indocker::ContainerHelper.hostname(@name, container, number) end |
#next_build_server ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/indocker/configurations/configuration.rb', line 99 def next_build_server @current_position ||= 0 build_server = @build_servers[@current_position] @current_position += 1 if @current_position >= @build_servers.size - 1 @current_position = 0 end build_server end |
#servers ⇒ Object
29 30 31 |
# File 'lib/indocker/configurations/configuration.rb', line 29 def servers @containers.map(&:servers).flatten.uniq end |
#set_artifact_servers(artifact, servers) ⇒ Object
33 34 35 |
# File 'lib/indocker/configurations/configuration.rb', line 33 def set_artifact_servers(artifact, servers) @artifact_servers[artifact] = servers end |
#set_confirm_deployment(flag) ⇒ Object
37 38 39 |
# File 'lib/indocker/configurations/configuration.rb', line 37 def set_confirm_deployment(flag) @confirm_deployment = !!flag end |
#set_enabled_containers(list) ⇒ Object
45 46 47 |
# File 'lib/indocker/configurations/configuration.rb', line 45 def set_enabled_containers(list) @enabled_containers = list end |
#set_env_file(alias_name, env_file) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/indocker/configurations/configuration.rb', line 73 def set_env_file(alias_name, env_file) if @env_files.has_key?(alias_name) raise ArgumentError.new("alias name :#{alias_name} is already used by env file: #{@env_files[alias_name].inspect}") end @env_files[alias_name] = env_file end |
#set_global_build_args(hash) ⇒ Object
87 88 89 |
# File 'lib/indocker/configurations/configuration.rb', line 87 def set_global_build_args(hash) @global_build_args = hash end |
#set_registry(alias_name, registry) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/indocker/configurations/configuration.rb', line 65 def set_registry(alias_name, registry) if @registries.has_key?(alias_name) raise ArgumentError.new("alias name :#{alias_name} is already used by registry: #{@registries[alias_name].inspect}") end @registries[alias_name] = registry end |
#set_repository(alias_name, repository) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/indocker/configurations/configuration.rb', line 57 def set_repository(alias_name, repository) if @repositories.has_key?(alias_name) raise ArgumentError.new("alias name :#{alias_name} is already used by repository: #{@repositories[alias_name].inspect}") end @repositories[alias_name] = repository end |