Class: ForemanDeployments::StackParser

Inherits:
Object
  • Object
show all
Defined in:
app/lib/foreman_deployments/stack_parser.rb

Constant Summary collapse

TAG_DOMAIN =
'deployments.theforeman.org,2015'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry = nil) ⇒ StackParser

Returns a new instance of StackParser.



39
40
41
# File 'app/lib/foreman_deployments/stack_parser.rb', line 39

def initialize(registry = nil)
  @registry = registry || ForemanDeployments.registry
end

Class Method Details

.parse(stack_definition) ⇒ Object



63
64
65
# File 'app/lib/foreman_deployments/stack_parser.rb', line 63

def self.parse(stack_definition)
  StackParser.new.parse(stack_definition)
end

Instance Method Details

#parse(stack_definition) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/lib/foreman_deployments/stack_parser.rb', line 43

def parse(stack_definition)
  stack_definition = prepare_stack(stack_definition)

  begin
    parsed_stack = SafeYAML.load(stack_definition.to_s, nil,
                                 :whitelisted_tags => init_whitelisted_tags,
                                 :raise_on_unknown_tag => true)
  rescue RuntimeError => e
    raise wrap_exception(e)
  end

  unless parsed_stack.is_a? Hash
    fail(StackParseException, _('Stack definition is invalid'))
  end

  definition = ForemanDeployments::StackDefinition.new(parsed_stack)
  definition.accept(ReferenceVisitor.new)
  definition
end