Module: HolePunch
- Defined in:
- lib/holepunch/logger.rb,
lib/holepunch.rb,
lib/holepunch/cli.rb,
lib/holepunch/dsl.rb,
lib/holepunch/ec2.rb,
lib/holepunch/version.rb,
lib/holepunch/definition.rb
Overview
Copyright © 2014 Undead Labs, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defined Under Namespace
Modules: Logger Classes: BaseDSL, CLI, DSL, Definition, EC2, EnvNotDefinedError, GroupDSL, GroupDoesNotExistError, GroupError, HolePunchError, LoggerOutputStdio, Permission, SecurityGroup, SecurityGroupsFileError, SecurityGroupsFileNotFoundError, Service, ServiceDSL, ServiceDoesNotExistError
Constant Summary collapse
- VERSION =
'1.3.0'
Class Method Summary collapse
-
.apply(filename, env, opts = {}) ⇒ Object
Applies the given SecurityGroups file to EC2.
- .cidr?(value) ⇒ Boolean
-
.defined?(filename, env, groups) ⇒ Boolean
Tests if a list of security groups are all defined in the SecurityGroups file.
- .read_file(file) ⇒ Object
-
.select_undefined(filename, env, groups) ⇒ Object
Checks a list of security groups against the SecurityGroups file and returns an array of the groups that are undefined.
-
.service_groups(filename, env, name) ⇒ Array<String>
Examines the given SecurityGroups file for the given service and returns a list of the security groups that make up that service.
Class Method Details
.apply(filename, env, opts = {}) ⇒ Object
Applies the given SecurityGroups file to EC2.
48 49 50 51 52 |
# File 'lib/holepunch.rb', line 48 def apply(filename, env, opts = {}) definition = DSL.evaluate(filename, env) ec2 = EC2.new(opts) ec2.apply(definition) end |
.cidr?(value) ⇒ Boolean
100 101 102 |
# File 'lib/holepunch.rb', line 100 def cidr?(value) value.to_s =~ /\d+\.\d+\.\d+\.\d+\/\d+/ end |
.defined?(filename, env, groups) ⇒ Boolean
Tests if a list of security groups are all defined in the SecurityGroups file.
60 61 62 63 64 65 |
# File 'lib/holepunch.rb', line 60 def defined?(filename, env, groups) definition = DSL.evaluate(filename, env) groups.all? do |group_id| definition.groups.include?(group_id) end end |
.read_file(file) ⇒ Object
105 106 107 108 109 |
# File 'lib/holepunch.rb', line 105 def read_file(file) content = File.open(file, 'rb') do |io| io.read end end |
.select_undefined(filename, env, groups) ⇒ Object
Checks a list of security groups against the SecurityGroups file and returns an array of the groups that are undefined.
73 74 75 76 77 78 |
# File 'lib/holepunch.rb', line 73 def select_undefined(filename, env, groups) definition = DSL.evaluate(filename, env) groups.reject do |group_id| definition.groups.include?(group_id) end end |
.service_groups(filename, env, name) ⇒ Array<String>
Examines the given SecurityGroups file for the given service and returns a list of the security groups that make up that service.
88 89 90 91 92 93 |
# File 'lib/holepunch.rb', line 88 def service_groups(filename, env, name) definition = DSL.evaluate(filename, env) service = definition.services[name] raise ServiceDoesNotExistError, "service '#{name}' not found" if service.nil? service.groups end |