Class: Ufo::DSL::Helper
- Inherits:
-
Object
show all
- Extended by:
- Memoist
- Includes:
- Util
- Defined in:
- lib/ufo/dsl/helper.rb,
lib/ufo/dsl/helper/vars.rb
Defined Under Namespace
Classes: Vars
Instance Method Summary
collapse
Methods included from Util
#default_cluster, #display_params, #execute, #pretty_time, #settings, #task_definition_arns, #user_params
Instance Method Details
#add_project_helpers ⇒ Object
Add helpers from .ufo/helpers folder
14
15
16
17
18
19
20
21
|
# File 'lib/ufo/dsl/helper.rb', line 14
def add_project_helpers
helpers_dir = "#{Ufo.root}/.ufo/helpers"
Dir.glob("#{helpers_dir}/**/*").each do |path|
next unless File.file?(path)
klass = path.gsub(%r{.*\.ufo/helpers/},'').sub(".rb",'').camelize
self.class.send(:include, klass.constantize)
end
end
|
#current_region ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ufo/dsl/helper.rb', line 56
def current_region
default_region = 'us-east-1'
return default_region if ENV['TEST']
return ENV['UFO_AWS_REGION'] if ENV['UFO_AWS_REGION']
return ENV['AWS_REGION'] if ENV['AWS_REGION']
region = `aws configure get region`.strip rescue default_region
region.blank? ? default_region : region
end
|
#dockerfile_port ⇒ Object
25
26
27
28
29
30
|
# File 'lib/ufo/dsl/helper.rb', line 25
def dockerfile_port
dockerfile_path = "#{Ufo.root}/Dockerfile"
if File.exist?(dockerfile_path)
parse_for_dockerfile_port(dockerfile_path)
end
end
|
#env(text) ⇒ Object
Also known as:
env_vars
39
40
41
|
# File 'lib/ufo/dsl/helper.rb', line 39
def env(text)
Vars.new(text: text).env
end
|
#env_file(path) ⇒ Object
44
45
46
|
# File 'lib/ufo/dsl/helper.rb', line 44
def env_file(path)
Vars.new(file: path).env
end
|
#full_image_name ⇒ Object
32
33
34
35
|
# File 'lib/ufo/dsl/helper.rb', line 32
def full_image_name
Docker::Builder.new({}).full_image_name
end
|
#parse_for_dockerfile_port(dockerfile_path) ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/ufo/dsl/helper.rb', line 67
def parse_for_dockerfile_port(dockerfile_path)
lines = IO.read(dockerfile_path).split("\n")
expose_line = lines.find { |l| l =~ /^EXPOSE / }
if expose_line
md = expose_line.match(/EXPOSE (\d+)/)
port = md[1] if md
end
port.to_i if port
end
|
#secrets(text) ⇒ Object
48
49
50
|
# File 'lib/ufo/dsl/helper.rb', line 48
def secrets(text)
Vars.new(text: text, secrets: true).secrets
end
|
#secrets_file(path) ⇒ Object
52
53
54
|
# File 'lib/ufo/dsl/helper.rb', line 52
def secrets_file(path)
Vars.new(file: path, secrets: true).secrets
end
|