Class: Inspec::Resources::DockerService

Inherits:
Object
  • Object
show all
Includes:
DockerObject
Defined in:
lib/inspec/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/inspec/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

#imageObject



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

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

#image_nameObject



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

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

#modeObject



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

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

#nameObject



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

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

#portsObject



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

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

#replicasObject



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

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

#repoObject



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

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

#resource_idObject



76
77
78
# File 'lib/inspec/resources/docker_service.rb', line 76

def resource_id
  object_info.ids[0] || @opts[:id] || @opts[:name] || ""
end

#tagObject



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

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

#to_sObject



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

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