sparkleformation / sparkle_formation

Ruby orchestration templating library built with unicorns and rainbows
http://www.sparkleformation.io
Apache License 2.0
222 stars 47 forks source link

Not able to get value but getting reference #247

Closed bsushant-athena closed 6 years ago

bsushant-athena commented 6 years ago

Hi, In my usecase I've some parameters which user provides and then accordingly I've to decide whether to choose A or B. But when I'm accessing this A or B I get reference instead of value.

conditions do
    is_small_gw                equals!(ref!(:gateway_mode), 'small')
  end

  gwn_mem_usage = if!(
    :is_small_gw,
    1.4,
    5.5
  )

And in other file I need to access that variable.

files('/etc/prometheus/prometheus.rules') do
    context do
      GWN_MEM_USAGE               ref!(:gwn_mem_usage)
    end
    content join!(
       File.read('sparkleformation/files/prometheus/b.rules'),
       a_rules
    )
  end

The error I get is

ERROR: Miasma::Error::ApiError::RequestError: Bad Request - ValidationError: Template format error: Unresolved resource dependencies [GwnMemUsage] in the Resources block of the template

So how can I access this variable inside the context as a value?

chrisroberts commented 6 years ago

Hi there. In this case you are just using a defined variable to set the value, not referencing a resource within the template, so using ref! is not required. You can just do:

GWN_MEM_USAGE gwn_mem_usage

Cheers!

bsushant-athena commented 6 years ago

@chrisroberts I already did that but I'm still not getting the value. When I tried puts!(gwn_mem_usage) ..I get empty response