Module: Spacelift::Policy

Defined in:
lib/spacelift/policy/policy.rb,
lib/spacelift/policy/cli.rb,
lib/spacelift/policy/rule.rb,
lib/spacelift/policy/error.rb,
lib/spacelift/policy/version.rb,
lib/spacelift/policy/violation.rb

Overview

Policy is the module that hosts all the other resources in this library, and provides helper methods to deal with the Collection singleton.

Defined Under Namespace

Classes: CLI, Collection, Error, Rule, Violation

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.define {|Collection.instance| ... } ⇒ Object

Yields:



11
12
13
# File 'lib/spacelift/policy/policy.rb', line 11

def define
  yield Collection.instance
end

.enforce(source) ⇒ Object



15
16
17
18
19
20
# File 'lib/spacelift/policy/policy.rb', line 15

def enforce(source)
  input = JSON.parse(source, object_class: OpenStruct)

  changes = input.resource_changes
  changes ? Collection.instance.process(changes) : []
end