Sha256: d7396027bf499da66f9a223fad267799fdbb9b62ec4889d430e370118347127f

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'json'
require 'logger'
require 'canzea/commands/add-env'
require 'canzea/plan-step-class'

class ApplyConfig
    def initialize ()
        @log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
    end

    def do (gitRoot, test = false, stepNum = nil, task = nil)
        ps = PlanStep.new

        # Read the configuration file and make calls out to run

        log "Processing #{gitRoot}/configure.json"

        steps = JSON.parse(File.read("#{gitRoot}/configure.json"))


        index = 1
        steps["steps"].each { | step |

            # Needs to be after each step because new env vars could be set (i.e./ CONSUL_URL)
            AddEnv.new.injectEnvironmentVariables()

            ref = "Step #{index.to_s.rjust(2, "0")} / #{steps['steps'].length}"

            role = step['role']
            solution = step['solution']

            ENV['ES_STEP'] = "#{index}";

            if (stepNum == nil or index >= Integer(stepNum))
                log "  [#{ref}] Configure for #{role} and #{solution}"
                ps.runPhaseConfigure role, solution, test, (task == nil ? 1:task), ref
                task = 1
            else
                log "  [#{ref}] Configure for #{role} and #{solution} SKIP"
            end
            index = index + 1
        }
    end

    def log (msg)
        puts msg
        @log.info(msg)
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
escli-1.0.3 lib/canzea/commands/apply-config.rb
escli-1.0.2 lib/canzea/commands/apply-config.rb
escli-1.0.1 lib/canzea/commands/apply-config.rb
escli-1.0.0 lib/canzea/commands/apply-config.rb