Module: Dogfood::DSL::Schema

Defined in:
lib/dogfood/dsl/schema.rb

Overview

Hand-rolled structural validation of scenario YAML. See SPEC.md 4.10 and 4.7 (the depth-1 nesting limit is enforced here).

Constant Summary collapse

ValidationError =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.validate!(yaml) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dogfood/dsl/schema.rb', line 10

def self.validate!(yaml)
  raise ValidationError, "must be a Hash" unless yaml.is_a?(Hash)

  require_keys!(yaml, "name", "title", "stages", "stages_def")
  validate_name(yaml["name"])
  validate_title(yaml["title"])
  stages = validate_stages(yaml["stages"])
  validate_stages_def(yaml["stages_def"], stages)
  validate_branches(yaml["branches"], stages) if yaml["branches"]
  validate_delays(yaml["delays"]) if yaml["delays"]
  validate_resume(yaml["resume"]) if yaml["resume"]
  validate_fleet_ratio(yaml["fleet_ratio"]) if yaml["fleet_ratio"]

  true
end