Method: Controlplane#apply_template

Defined in:
lib/core/controlplane.rb

#apply_template(data) ⇒ Object

apply



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/core/controlplane.rb', line 407

def apply_template(data) # rubocop:disable Metrics/MethodLength
  Tempfile.create do |f|
    f.write(data)
    f.rewind
    cmd = "cpln apply #{gvc_org} --file #{f.path}"
    if Shell.tmp_stderr
      cmd += " 2> #{Shell.tmp_stderr.path}" if Shell.should_hide_output?

      Shell.debug("CMD", cmd)

      result = Shell.cmd(cmd)
      parse_apply_result(result[:output]) if result[:success]
    else
      Shell.debug("CMD", cmd)

      result = Shell.cmd(cmd)
      if result[:success]
        parse_apply_result(result[:output])
      else
        Shell.abort("Command exited with non-zero status.")
      end
    end
  end
end