Sha256: 5077459a5a00f05600eff26eac5c000b74ae90a2ebe5b9346da74b39ea1067ae
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
class AppRb::Config def initialize(yml) @body = yml end def tool_version; @body["tool_version"]; end def app; @body["app"]; end def consul; @body["consul"]; end def registry; @body["registry"]; end def user; @body["user"]; end def image; @body["image"]; end def env; @body["env"] || {}; end def pre_deploy; @body["pre_deploy"] || []; end def deploy; @body["deploy"] || {}; end def cron; @body["cron"] || {}; end def run; @body["run"] || {}; end def slack_url; @body["slack_url"]; end def slack_channel; @body["slack_channel"]; end def slack?; slack_url && slack_channel; end def nodes(constraint = nil) constraint ||= {} out = __nodes if constraint["name"] out = out.select { |n| Array(constraint["name"]).index(n.name) } end out.shuffle end private Node = Struct.new(:name, :ip) def __nodes @__nodes ||= JSON.load(AppRb::Util.just_cmd("curl -s #{@body["consul"]}/v1/catalog/nodes")).sort_by { |n| n["Node"] }.map { |n| Node.new(n["Node"], n["Address"]) } end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
app-rb-0.8.0 | lib/app-rb/config.rb |
app-rb-0.7.0 | lib/app-rb/config.rb |
app-rb-0.6.0 | lib/app-rb/config.rb |
app-rb-0.5.0 | lib/app-rb/config.rb |