File: docker_container.rb

package info (click to toggle)
ruby-serverspec 2.42.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 980 kB
  • sloc: ruby: 4,835; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Serverspec::Type
  class DockerContainer < DockerBase
    def running?
      inspection['State']['Running'] && !inspection['State']['Restarting']
    end

    def has_volume?(container_path, host_path)
      if (inspection['Mounts'])
        check_volume(container_path, host_path)
      else
        check_volume_pre_1_8(container_path, host_path)
      end
    end

    private
    def check_volume(container_path, host_path)
      inspection['Mounts'].find {|mount|
        mount['Destination'] == container_path &&
        mount['Source'] == host_path
      }
    end

    def check_volume_pre_1_8(container_path, host_path)
      inspection['Volumes'][container_path] == host_path
    end
  end
end