Sha256: 77efcf0190f922a77afd1b657b80e1655c9870229db239b62e5e7d7c9beffddd

Contents?: true

Size: 553 Bytes

Versions: 7

Compression:

Stored size: 553 Bytes

Contents

require 'multi_json'

module Serverspec::Type
  class DockerBase < Base
    def exist?
      get_inspection.success?
    end

    def [](key)
      value = inspection
      key.split('.').each do |k|
        is_index = k.start_with?('[') && k.end_with?(']')
        value = value[is_index ? k.to_i : k]
      end
      value
    end

    def inspection
      @inspection ||= ::MultiJson.load(get_inspection.stdout)[0]
    end

    private
    def get_inspection
      @get_inspection ||= @runner.run_command("docker inspect #{@name}")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
serverspec-2.37.1 lib/serverspec/type/docker_base.rb
serverspec-2.37.0 lib/serverspec/type/docker_base.rb
serverspec-2.36.1 lib/serverspec/type/docker_base.rb
serverspec-2.36.0 lib/serverspec/type/docker_base.rb
serverspec-2.35.0 lib/serverspec/type/docker_base.rb
serverspec-2.34.0 lib/serverspec/type/docker_base.rb
serverspec-2.33.0 lib/serverspec/type/docker_base.rb