Sha256: ec54f3f76b28e7400bbf1fd079a4361c1056b5eea279cbc2e41d144e3f5ec792

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'json'
require 'plan-step-class'

class ApplyConfig

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

        # Read the configuration file and make calls out to run

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

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

            injectEnvironmentVariables()

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

    def injectEnvironmentVariables()
        extraConfig = Canzea::config[:catalog_location] + "/env.json"
        if File.exists?(extraConfig)
            puts "-- Reading #{extraConfig}"
            file = File.read(extraConfig)
            envs = JSON.parse(file)
            envs.keys.each { | key |
                puts "#{key} == #{envs[key]}"
                ENV.store(key, envs[key])
            }
        end

    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
canzea-0.1.54 lib/commands/apply-config.rb
canzea-0.1.53 lib/commands/apply-config.rb