Class: Mrsk::Configuration::Role
- Inherits:
-
Object
- Object
- Mrsk::Configuration::Role
- Defined in:
- lib/mrsk/configuration/role.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #cmd ⇒ Object
- #env ⇒ Object
- #env_args ⇒ Object
- #health_check_args ⇒ Object
- #health_check_cmd ⇒ Object
- #health_check_interval ⇒ Object
- #hosts ⇒ Object
-
#initialize(name, config:) ⇒ Role
constructor
A new instance of Role.
- #label_args ⇒ Object
- #labels ⇒ Object
- #option_args ⇒ Object
- #primary_host ⇒ Object
- #running_traefik? ⇒ Boolean
Constructor Details
#initialize(name, config:) ⇒ Role
Returns a new instance of Role.
6 7 8 |
# File 'lib/mrsk/configuration/role.rb', line 6 def initialize(name, config:) @name, @config = name.inquiry, config end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/mrsk/configuration/role.rb', line 4 def name @name end |
Instance Method Details
#cmd ⇒ Object
60 61 62 |
# File 'lib/mrsk/configuration/role.rb', line 60 def cmd specializations["cmd"] end |
#env ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/mrsk/configuration/role.rb', line 26 def env if config.env && config.env["secret"] merged_env_with_secrets else merged_env end end |
#env_args ⇒ Object
34 35 36 |
# File 'lib/mrsk/configuration/role.rb', line 34 def env_args argumentize_env_with_secrets env end |
#health_check_args ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mrsk/configuration/role.rb', line 38 def health_check_args if health_check_cmd.present? optionize({ "health-cmd" => health_check_cmd, "health-interval" => health_check_interval }) else [] end end |
#health_check_cmd ⇒ Object
46 47 48 49 50 51 |
# File 'lib/mrsk/configuration/role.rb', line 46 def health_check_cmd = specializations["healthcheck"] || {} = config.healthcheck.merge() if running_traefik? ["cmd"] || http_health_check(port: ["port"], path: ["path"]) end |
#health_check_interval ⇒ Object
53 54 55 56 57 58 |
# File 'lib/mrsk/configuration/role.rb', line 53 def health_check_interval = specializations["healthcheck"] || {} = config.healthcheck.merge() if running_traefik? ["interval"] || "1s" end |
#hosts ⇒ Object
14 15 16 |
# File 'lib/mrsk/configuration/role.rb', line 14 def hosts @hosts ||= extract_hosts_from_config end |
#label_args ⇒ Object
22 23 24 |
# File 'lib/mrsk/configuration/role.rb', line 22 def label_args argumentize "--label", labels end |
#labels ⇒ Object
18 19 20 |
# File 'lib/mrsk/configuration/role.rb', line 18 def labels default_labels.merge(traefik_labels).merge(custom_labels) end |
#option_args ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/mrsk/configuration/role.rb', line 64 def option_args if args = specializations["options"] optionize args else [] end end |
#primary_host ⇒ Object
10 11 12 |
# File 'lib/mrsk/configuration/role.rb', line 10 def primary_host hosts.first end |
#running_traefik? ⇒ Boolean
72 73 74 |
# File 'lib/mrsk/configuration/role.rb', line 72 def running_traefik? name.web? || specializations["traefik"] end |