Class: Sensu::Settings::Validator

Inherits:
Object
  • Object
show all
Includes:
Rules, Validators
Defined in:
lib/sensu/settings/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sensu::Settings::Validators::Extension

#validate_extension

Methods included from Sensu::Settings::Validators::API

#validate_api, #validate_api_authentication, #validate_api_endpoints

Methods included from Sensu::Settings::Validators::Client

#validate_client, #validate_client_deregistration, #validate_client_deregistration_handlers, #validate_client_http_socket, #validate_client_keepalive, #validate_client_keepalive_handlers, #validate_client_keepalive_thresholds, #validate_client_keepalives, #validate_client_redact, #validate_client_registration, #validate_client_registration_handlers, #validate_client_safe_mode, #validate_client_signature, #validate_client_socket, #validate_client_subscriptions

Methods included from Sensu::Settings::Validators::Handler

#validate_handler, #validate_handler_filtering, #validate_handler_severities, #validate_handler_type, #validate_pipe_handler, #validate_set_handler, #validate_socket_handler, #validate_transport_handler

Methods included from Sensu::Settings::Validators::Mutator

#validate_mutator

Methods included from Sensu::Settings::Validators::Filter

#validate_filter, #validate_filter_when

Methods included from Sensu::Settings::Validators::Check

#validate_check, #validate_check_aggregate, #validate_check_cron, #validate_check_execution, #validate_check_flap_detection, #validate_check_handling, #validate_check_hook_execution, #validate_check_hooks, #validate_check_name, #validate_check_proxy_requests, #validate_check_scheduling, #validate_check_source, #validate_check_subdue, #validate_check_truncate_output, #validate_check_ttl

Methods included from Sensu::Settings::Validators::TimeWindow

#validate_time_window_condition, #validate_time_windows, #validate_time_windows_days

Methods included from Sensu::Settings::Validators::Transport

#validate_transport

Methods included from Sensu::Settings::Validators::Tessen

#validate_tessen

Methods included from Rules

#either_are_set?, #items_must_be_strings, #must_be_a_hash, #must_be_a_hash_if_set, #must_be_a_numeric, #must_be_a_numeric_if_set, #must_be_a_string, #must_be_a_string_if_set, #must_be_an_array, #must_be_an_array_if_set, #must_be_an_integer, #must_be_an_integer_if_set, #must_be_boolean, #must_be_boolean_if_set, #must_be_either, #must_be_either_if_set, #must_be_time, #must_match_regex

Constructor Details

#initializeValidator

Returns a new instance of Validator.


15
16
17
# File 'lib/sensu/settings/validator.rb', line 15

def initialize
  @failures = []
end

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures


13
14
15
# File 'lib/sensu/settings/validator.rb', line 13

def failures
  @failures
end

Instance Method Details

#reset!Object Also known as: reset


42
43
44
45
46
# File 'lib/sensu/settings/validator.rb', line 42

def reset!
  failure_count = @failures.size
  @failures = []
  failure_count
end

#run(settings, service = nil) ⇒ Array

Run the validator.

Parameters:

  • settings (Hash)

    sensu settings to validate.

  • service (String) (defaults to: nil)

    sensu service to validate for.

Returns:

  • (Array)

    validation failures.


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sensu/settings/validator.rb', line 24

def run(settings, service=nil)
  validate_sensu(settings[:sensu])
  validate_transport(settings[:transport])
  validate_categories(settings)
  case service
  when "server"
    validate_tessen(settings[:tessen])
  when "client"
    validate_client(settings[:client])
  when "api"
    validate_api(settings[:api])
  when "rspec"
    validate_client(settings[:client])
    validate_api(settings[:api])
  end
  @failures
end