Class: Indocker::BuildContextHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/indocker/build_context_helper.rb

Defined Under Namespace

Classes: Container, Containers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, build_server) ⇒ BuildContextHelper

Returns a new instance of BuildContextHelper.



4
5
6
7
8
# File 'lib/indocker/build_context_helper.rb', line 4

def initialize(configuration, build_server)
  @configuration = configuration
  @build_server = build_server
  @cloned_repositories = Hash.new(false)
end

Instance Attribute Details

#build_serverObject (readonly)

Returns the value of attribute build_server.



2
3
4
# File 'lib/indocker/build_context_helper.rb', line 2

def build_server
  @build_server
end

#configurationObject (readonly)

Returns the value of attribute configuration.



2
3
4
# File 'lib/indocker/build_context_helper.rb', line 2

def configuration
  @configuration
end

Instance Method Details

#container_enabled?(container) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/indocker/build_context_helper.rb', line 44

def container_enabled?(container)
  @configuration.enabled_containers.include?(container.name)
end

#containersObject



102
103
104
# File 'lib/indocker/build_context_helper.rb', line 102

def containers
  @containers ||= Containers.new(@configuration)
end

#get_bindingObject



106
107
108
# File 'lib/indocker/build_context_helper.rb', line 106

def get_binding
  binding
end

#global_build_argsObject



40
41
42
# File 'lib/indocker/build_context_helper.rb', line 40

def global_build_args
  @global_build_args = Indocker::ContextArgs.new(nil, @configuration.global_build_args, nil)
end

#image_url(image_sym) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/indocker/build_context_helper.rb', line 10

def image_url(image_sym)
  path = Indocker.image_files.fetch(image_sym) do
    Indocker.logger.error("image :#{image_sym} was not found in configuration :#{@configuration.name}")
    exit 1
  end

  require path

  image = @configuration.images.detect do |i|
    i.name == image_sym
  end

  if image.nil?
    raise ArgumentError.new("image :#{image_sym} was not found in configuration")
  end

  image.registry_url
end

#repository(name) ⇒ Object



34
35
36
37
38
# File 'lib/indocker/build_context_helper.rb', line 34

def repository(name)
  @configuration.repositories.fetch(name) do
    raise ArgumentError.new("repository :#{name} is not defined in configuration")
  end
end

#repository_path(name) ⇒ Object



29
30
31
32
# File 'lib/indocker/build_context_helper.rb', line 29

def repository_path(name)
  repo = repository(name)
  repo.clone_path
end