Class: Xplenty::Kensa::AllCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/xplenty/kensa/check.rb

Overview

On Testing:

I've opted to not write tests for this
due to the simple nature it's currently in.
If this becomes more complex in even the
least amount, find me (blake) and I'll
help get tests in.

Instance Attribute Summary

Attributes inherited from Check

#data, #screen

Instance Method Summary collapse

Methods inherited from Check

#call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url

Constructor Details

This class inherits a constructor from Xplenty::Kensa::Check

Instance Method Details

#call!Object



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/xplenty/kensa/check.rb', line 486

def call!
  args = data[:args]
  run ProvisionCheck, data

  response = data[:provision_response]
  data.merge!(:id => response["id"])
  config = response["config"] || Hash.new

  if args
    screen.message "\n\n"
    screen.message "Starting #{args.first}..."
    screen.message "\n\n"

    run_in_env(config) { system(*args) }
    error("run exited abnormally, expected 0, got #{$?.to_i}") unless $?.to_i == 0

    screen.message "\n"
    screen.message "End of #{args.first}\n"
  end

  data[:plan] ||= 'foo'
  run PlanChangeCheck, data
  run DeprovisionCheck, data
end

#run_in_env(env) ⇒ Object



511
512
513
514
515
# File 'lib/xplenty/kensa/check.rb', line 511

def run_in_env(env)
  env.each {|key, value| ENV[key] = value }
  yield
  env.keys.each {|key| ENV.delete(key) }
end