Class: KubernetesSchemas::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/kubernetes_schemas.rb

Instance Method Summary collapse

Constructor Details

#initialize(schemas) ⇒ Validator

Returns a new instance of Validator.



20
21
22
# File 'lib/kubernetes_schemas.rb', line 20

def initialize(schemas)
  @schemas = schemas
end

Instance Method Details

#validate(resource) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/kubernetes_schemas.rb', line 24

def validate(resource)
  if schema = @schemas["#{resource["apiVersion"]}/#{resource["kind"]}"]
    schema.validate(resource).map { |e| stringify(e) }
  else
    []
  end
end