Class: Inspec::Resources::DockerService

Inherits:
Object
  • Object
show all
Includes:
DockerObject
Defined in:
lib/resources/docker_service.rb

Instance Method Summary collapse

Methods included from DockerObject

#exist?, #id

Constructor Details

#initialize(opts = {}) ⇒ DockerService

Returns a new instance of DockerService.



32
33
34
35
36
37
# File 'lib/resources/docker_service.rb', line 32

def initialize(opts = {})
  # do sanitizion of input values
  o = opts.dup
  o = { name: opts } if opts.is_a?(String)
  @opts = sanitize_options(o)
end

Instance Method Details

#image ⇒ Object



43
44
45
# File 'lib/resources/docker_service.rb', line 43

def image
  object_info.images[0] if object_info.entries.size == 1
end

#image_name ⇒ Object



47
48
49
# File 'lib/resources/docker_service.rb', line 47

def image_name
  parse_components_from_image(image)[:image_name] if object_info.entries.size == 1
end

#mode ⇒ Object



59
60
61
# File 'lib/resources/docker_service.rb', line 59

def mode
  object_info.modes[0] if object_info.entries.size == 1
end

#name ⇒ Object



39
40
41
# File 'lib/resources/docker_service.rb', line 39

def name
  object_info.names[0] if object_info.entries.size == 1
end

#ports ⇒ Object



67
68
69
# File 'lib/resources/docker_service.rb', line 67

def ports
  object_info.ports[0] if object_info.entries.size == 1
end

#replicas ⇒ Object



63
64
65
# File 'lib/resources/docker_service.rb', line 63

def replicas
  object_info.replicas[0] if object_info.entries.size == 1
end

#repo ⇒ Object



51
52
53
# File 'lib/resources/docker_service.rb', line 51

def repo
  parse_components_from_image(image)[:repo] if object_info.entries.size == 1
end

#tag ⇒ Object



55
56
57
# File 'lib/resources/docker_service.rb', line 55

def tag
  parse_components_from_image(image)[:tag] if object_info.entries.size == 1
end

#to_s ⇒ Object



71
72
73
74
# File 'lib/resources/docker_service.rb', line 71

def to_s
  service = @opts[:name] || @opts[:id]
  "Docker Service #{service}"
end