b0VIM 7.4T2peterlongnguyenPeters-MacBook-Pro.local~peterlongnguyen/Documents/work/pandacluster/src/pandacluster.coffee 3210#"! Utpt[umv=qn$ad t^  L   u M L B   m *  | S H 3  r c b T   2 8#4sWCBm2n&dcUK # object of the AWS template. We wish to add additional strings to this array. # The cloud-config file is stored as an array of strings inside the "UserData"add_unit = (cloud_config, unit) -># Add unit to the cloud-config section of the AWS template. return build_error "Unable to access AWS template stores belonging to CoreOS", error catch error return template_object template_object = JSON.parse (yield get_body response) response = yield https_get template_url try template_url = template_store[channel][virtualization] template_store = parse( read( resolve( __dirname, "templates.cson"))) # This directory has a handy CSON file of URLs for CoreOS's latest CloudFormation templates. virtualization ||= "pv" channel ||= "stable" # Set reasonable defaults for these preferences.pull_cloud_template = async ({channel, virtualization}) -># Pulls the most recent AWS CloudFormation template from CoreOS.get_discovery_url = async -> yield get_body( yield https_get( "https://discovery.etcd.io/new"))# Wrapper for https call to etcd's discovery API. resolve error .on "error", (error) -> resolve data .on "end", -> data = data + chunk .on "data", (chunk) -> response.setEncoding "utf8" data = "" promise (resolve, reject) ->get_body = (response) -># Promise wrapper around response events that read "data" from the response's body. resolve error .on "error", (error) -> resolve response .on "response", (response) -> https.get url promise (resolve, reject) ->https_get = (url) -># Promise wrapper around Node's https module. Makes GET calls into promises. setTimeout callback, duration callback = -> resolve() promise (resolve, reject) ->pause = (duration) -># pause in execution for the specified duration (in ms).# This is a wrap of setTimeout with ES6 technology that forces a non-blocking node_lift method.bind objectlift_object = (object, method) -># Allow "when" to lift AWS module functions, which are non-standard. return build_error "ShellJS failed to execute shell command.", error() if error()? exec commandexecute = (command) -># Create a version of ShellJS's "exec" command with built-in error handling. } details: data if data? code: code if code? status: "success" message: message return {build_success = (message, data, code) -># Create a success object that reports data to user. return error error.details = details if details? error = new Error messagebuild_error = (message, details) -># Build an error object to let the user know something went worng.#================================# Helper Functions#================================mustache = require "mustache"# Template EngineAWS = require "aws-sdk"# Access AWS API{exec, error} = require "shelljs"# ShellJSasync = (require "when/generator").liftnode_lift = (require "when/node").lift{liftAll} = require "when/node"{promise, lift} = require "when"# When Library{where} = require "underscore"{parse} = require "c50n" # .cson file parsing{read, write} = require "fairmont" # Easy file read/write# In-House Libraries{resolve} = require "path"https = require "https"#====================# Modules#====================#===============================================================================# PandaCluster - Awesome Command-Line Tool and Library to Manage CoreOS Clusters#===============================================================================ad_ templatize: templatize return build_error "Apologies. The targeted cluster has not been destroyed.", error