Class: Mrsk::Configuration::Role

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/mrsk/configuration/role.rb', line 4

def name
  @name
end

Instance Method Details

#cmdObject



60
61
62
# File 'lib/mrsk/configuration/role.rb', line 60

def cmd
  specializations["cmd"]
end

#envObject



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_argsObject



34
35
36
# File 'lib/mrsk/configuration/role.rb', line 34

def env_args
  argumentize_env_with_secrets env
end

#health_check_argsObject



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_cmdObject



46
47
48
49
50
51
# File 'lib/mrsk/configuration/role.rb', line 46

def health_check_cmd
  options = specializations["healthcheck"] || {}
  options = config.healthcheck.merge(options) if running_traefik?

  options["cmd"] || http_health_check(port: options["port"], path: options["path"])
end

#health_check_intervalObject



53
54
55
56
57
58
# File 'lib/mrsk/configuration/role.rb', line 53

def health_check_interval
  options = specializations["healthcheck"] || {}
  options = config.healthcheck.merge(options) if running_traefik?

  options["interval"] || "1s"
end

#hostsObject



14
15
16
# File 'lib/mrsk/configuration/role.rb', line 14

def hosts
  @hosts ||= extract_hosts_from_config
end

#label_argsObject



22
23
24
# File 'lib/mrsk/configuration/role.rb', line 22

def label_args
  argumentize "--label", labels
end

#labelsObject



18
19
20
# File 'lib/mrsk/configuration/role.rb', line 18

def labels
  default_labels.merge(traefik_labels).merge(custom_labels)
end

#option_argsObject



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_hostObject



10
11
12
# File 'lib/mrsk/configuration/role.rb', line 10

def primary_host
  hosts.first
end

#running_traefik?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/mrsk/configuration/role.rb', line 72

def running_traefik?
  name.web? || specializations["traefik"]
end