Method: ConfCtl::Machine#health_checks

Defined in:
lib/confctl/machine.rb

#health_checksObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/confctl/machine.rb', line 119

def health_checks
  return @health_checks if @health_checks

  @health_checks = []

  meta['healthChecks'].each do |type, checks|
    case type
    when 'systemd'
      next if !checks['enable'] || spin != 'nixos'

      if checks['systemProperties'].any?
        @health_checks << HealthChecks::Systemd::Properties.new(
          self,
          property_checks: checks['systemProperties'].map do |v|
            HealthChecks::Systemd::PropertyCheck.new(v)
          end
        )
      end

      checks['unitProperties'].each do |unit_name, prop_checks|
        health_checks << HealthChecks::Systemd::Properties.new(
          self,
          pattern: unit_name,
          property_checks: prop_checks.map do |v|
            HealthChecks::Systemd::PropertyCheck.new(v)
          end
        )
      end

    when 'builderCommands', 'machineCommands'
      checks.each do |cmd|
        health_checks << HealthChecks::RunCommand.new(
          self,
          HealthChecks::RunCommand::Command.new(self, cmd),
          remote: type == 'machineCommands'
        )
      end

    else
      raise "Unsupported health-check type #{type.inspect}"
    end
  end

  @health_checks
end