Class: PicsolveDockerBuilder::Composer::Image

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/picsolve_docker_builder/composer/image.rb

Overview

Represents an image in the registry

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#base_dir, #config_path, #create_logger, #default_config, #log, #read_config, #validate_config

Constructor Details

#initialize(name, config, composer) ⇒ Image

Returns a new instance of Image.



10
11
12
13
14
15
16
# File 'lib/picsolve_docker_builder/composer/image.rb', line 10

def initialize(name, config, composer)
  log.info "Image name=#{name} config=#{config}"
  @config = config
  @name = name
  @composer = composer
  log.info "repo_tag_uniqe is #{repo_tag_unique}"
end

Instance Attribute Details

#composerObject (readonly)

Returns the value of attribute composer.



9
10
11
# File 'lib/picsolve_docker_builder/composer/image.rb', line 9

def composer
  @composer
end

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/picsolve_docker_builder/composer/image.rb', line 9

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/picsolve_docker_builder/composer/image.rb', line 9

def name
  @name
end

Instance Method Details

#hashObject



63
64
65
# File 'lib/picsolve_docker_builder/composer/image.rb', line 63

def hash
  repo_tag_hash_unique[:hash]
end

#kubernetesObject



22
23
24
# File 'lib/picsolve_docker_builder/composer/image.rb', line 22

def kubernetes
  composer.kubernetes
end

#portsObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/picsolve_docker_builder/composer/image.rb', line 34

def ports
  config['ports'].map do |port|
    port_split = port.split(/:/)
    {
      'port' => port_split[1].to_i
    }
  end
rescue StandardError
  []
end

#ports_rcObject



45
46
47
48
49
50
51
52
53
# File 'lib/picsolve_docker_builder/composer/image.rb', line 45

def ports_rc
  p = []
  ports.each do |port|
    p << {
      'containerPort' => port['port']
    }
  end
  p
end

#rcObject



26
27
28
# File 'lib/picsolve_docker_builder/composer/image.rb', line 26

def rc
  @rc ||= kubernetes.rc self
end

#repo_tagObject



18
19
20
# File 'lib/picsolve_docker_builder/composer/image.rb', line 18

def repo_tag
  config['image']
end

#repo_tag_hash_uniqueObject



55
56
57
# File 'lib/picsolve_docker_builder/composer/image.rb', line 55

def repo_tag_hash_unique
  @repo_tag_hash_unique ||= Registry.repo_tag_unique(config['image'])
end

#repo_tag_uniqueObject



59
60
61
# File 'lib/picsolve_docker_builder/composer/image.rb', line 59

def repo_tag_unique
  repo_tag_hash_unique[:tag_unique]
end

#serviceObject



30
31
32
# File 'lib/picsolve_docker_builder/composer/image.rb', line 30

def service
  @service ||= kubernetes.service self
end