Module: Builderator::Util
- Defined in:
- lib/builderator/util.rb,
lib/builderator/util/shell.rb,
lib/builderator/util/packer.rb,
lib/builderator/util/berkshim.rb,
lib/builderator/util/cookbook.rb,
lib/builderator/util/aws_exception.rb,
lib/builderator/util/task_exception.rb,
lib/builderator/util/limit_exception.rb
Defined Under Namespace
Modules: Berkshim, Cookbook, Packer, Shell
Classes: AwsException, LimitException, TaskException
Class Method Summary
collapse
Class Method Details
.asg ⇒ Object
43
44
45
|
# File 'lib/builderator/util.rb', line 43
def asg
@asg ||= Aws::AutoScaling::Client.new(:region => region)
end
|
.ec2 ⇒ Object
39
40
41
|
# File 'lib/builderator/util.rb', line 39
def ec2
@ec2 ||= Aws::EC2::Client.new(:region => region)
end
|
.filter(resources, filters = {}) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/builderator/util.rb', line 14
def filter(resources, filters = {})
resources.select do |_, r|
filters.reduce(true) do |memo, (k, v)|
memo && r[:properties].include?(k.to_s) &&
r[:properties][k.to_s] == v
end
end
end
|
.filter!(resources, filters = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/builderator/util.rb', line 23
def filter!(resources, filters = {})
resources.select! do |_, r|
filters.reduce(true) do |memo, (k, v)|
memo && r[:properties].include?(k.to_s) &&
r[:properties][k.to_s] == v
end
end
resources
end
|
10
11
12
|
# File 'lib/builderator/util.rb', line 10
def from_tags(aws_tags)
{}.tap { |tt| aws_tags.each { |t| tt[t.key.to_s] = t.value } }
end
|
.region(arg = nil) ⇒ Object
34
35
36
37
|
# File 'lib/builderator/util.rb', line 34
def region(arg = nil)
return @region || 'us-east-1' if arg.nil?
@region = arg
end
|
.to_array(arg) ⇒ Object
6
7
8
|
# File 'lib/builderator/util.rb', line 6
def to_array(arg)
arg.is_a?(Array) ? arg : [arg]
end
|
.working_dir(relative = '.') ⇒ Object
47
48
49
|
# File 'lib/builderator/util.rb', line 47
def working_dir(relative = '.')
Pathname.pwd.join(relative).expand_path
end
|