Class: Indocker::Images::Image
- Inherits:
-
Object
- Object
- Indocker::Images::Image
- Defined in:
- lib/indocker/images/image.rb
Constant Summary collapse
- DOCKERFILE =
"Dockerfile"
Instance Attribute Summary collapse
-
#build_args ⇒ Object
readonly
Returns the value of attribute build_args.
-
#compile ⇒ Object
readonly
Returns the value of attribute compile.
-
#compile_rpaths ⇒ Object
readonly
Returns the value of attribute compile_rpaths.
-
#dependent_images ⇒ Object
readonly
Returns the value of attribute dependent_images.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_dependent_image(image) ⇒ Object
- #after_build ⇒ Object
- #before_build ⇒ Object
- #build_context ⇒ Object
- #compile?(path) ⇒ Boolean
- #dockerfile ⇒ Object
- #image_name ⇒ Object
-
#initialize(name) ⇒ Image
constructor
A new instance of Image.
- #local_registry_url ⇒ Object
- #registry ⇒ Object
- #registry_url ⇒ Object
- #set_after_build(proc) ⇒ Object
- #set_before_build(proc) ⇒ Object
- #set_build_args(opts) ⇒ Object
- #set_build_context(path) ⇒ Object
- #set_compile(flag_or_rpaths) ⇒ Object
- #set_dockerfile(path) ⇒ Object
- #set_registry(registry) ⇒ Object
- #set_tag(tag) ⇒ Object
- #tag ⇒ Object
Constructor Details
#initialize(name) ⇒ Image
Returns a new instance of Image.
6 7 8 9 10 11 |
# File 'lib/indocker/images/image.rb', line 6 def initialize(name) @compile = false @name = name @dependent_images = [] @build_args = {} end |
Instance Attribute Details
#build_args ⇒ Object (readonly)
Returns the value of attribute build_args.
4 5 6 |
# File 'lib/indocker/images/image.rb', line 4 def build_args @build_args end |
#compile ⇒ Object (readonly)
Returns the value of attribute compile.
4 5 6 |
# File 'lib/indocker/images/image.rb', line 4 def compile @compile end |
#compile_rpaths ⇒ Object (readonly)
Returns the value of attribute compile_rpaths.
4 5 6 |
# File 'lib/indocker/images/image.rb', line 4 def compile_rpaths @compile_rpaths end |
#dependent_images ⇒ Object (readonly)
Returns the value of attribute dependent_images.
4 5 6 |
# File 'lib/indocker/images/image.rb', line 4 def dependent_images @dependent_images end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/indocker/images/image.rb', line 4 def name @name end |
Instance Method Details
#add_dependent_image(image) ⇒ Object
109 110 111 |
# File 'lib/indocker/images/image.rb', line 109 def add_dependent_image(image) @dependent_images.push(image) if !@dependent_images.include?(image) end |
#after_build ⇒ Object
90 91 92 |
# File 'lib/indocker/images/image.rb', line 90 def after_build @after_build end |
#before_build ⇒ Object
82 83 84 |
# File 'lib/indocker/images/image.rb', line 82 def before_build @before_build end |
#build_context ⇒ Object
74 75 76 |
# File 'lib/indocker/images/image.rb', line 74 def build_context @build_context end |
#compile?(path) ⇒ Boolean
41 42 43 44 45 46 47 |
# File 'lib/indocker/images/image.rb', line 41 def compile?(path) return true if path.include?(DOCKERFILE) return false if !@compile return true if @compile_rpaths.empty? return true if @compile_rpaths.any? { |rpath| path.include?(rpath) } return false end |
#dockerfile ⇒ Object
66 67 68 |
# File 'lib/indocker/images/image.rb', line 66 def dockerfile @dockerfile || (raise ArgumentError.new("Dockerfile path is not set for image :#{@name}")) end |
#image_name ⇒ Object
13 14 15 |
# File 'lib/indocker/images/image.rb', line 13 def image_name "#{@name}_image" end |
#local_registry_url ⇒ Object
104 105 106 107 |
# File 'lib/indocker/images/image.rb', line 104 def local_registry_url url = File.join(registry.repository_name.to_s, image_name) "#{url}:#{tag}" end |
#registry ⇒ Object
33 34 35 |
# File 'lib/indocker/images/image.rb', line 33 def registry @registry || (raise ArgumentError.new("registry is not set for image :#{@name}")) end |
#registry_url ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/indocker/images/image.rb', line 94 def registry_url url = if registry.is_local? File.join(registry.repository_name.to_s, image_name) else File.join(registry.url, registry.repository_name.to_s, image_name) end "#{url}:#{tag}" end |
#set_after_build(proc) ⇒ Object
86 87 88 |
# File 'lib/indocker/images/image.rb', line 86 def set_after_build(proc) @after_build = proc end |
#set_before_build(proc) ⇒ Object
78 79 80 |
# File 'lib/indocker/images/image.rb', line 78 def set_before_build(proc) @before_build = proc end |
#set_build_args(opts) ⇒ Object
25 26 27 |
# File 'lib/indocker/images/image.rb', line 25 def set_build_args(opts) @build_args = opts end |
#set_build_context(path) ⇒ Object
70 71 72 |
# File 'lib/indocker/images/image.rb', line 70 def set_build_context(path) @build_context = path end |
#set_compile(flag_or_rpaths) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/indocker/images/image.rb', line 49 def set_compile(flag_or_rpaths) @compile_rpaths = [] if flag_or_rpaths == false @compile = false return end @compile = true if flag_or_rpaths.is_a?(Array) @compile_rpaths = flag_or_rpaths end nil end |
#set_dockerfile(path) ⇒ Object
37 38 39 |
# File 'lib/indocker/images/image.rb', line 37 def set_dockerfile(path) @dockerfile = path end |
#set_registry(registry) ⇒ Object
29 30 31 |
# File 'lib/indocker/images/image.rb', line 29 def set_registry(registry) @registry = registry end |
#set_tag(tag) ⇒ Object
17 18 19 |
# File 'lib/indocker/images/image.rb', line 17 def set_tag(tag) @tag = tag end |
#tag ⇒ Object
21 22 23 |
# File 'lib/indocker/images/image.rb', line 21 def tag @tag || (raise ArgumentError.new("tag is not set for image :#{@name}")) end |