Sha256: d933410e201d7374302475bfe83a9472f17f2b3c9f19f4107c0c239f6ed5481a

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

module Rascal
  module Docker
    module Volume
      class Base
        include IOHelper
      end

      class Named < Base
        def initialize(name, container_path)
          @prefixed_name = "#{NAME_PREFIX}#{name}"
          @container_path = container_path
        end

        def to_param
          "#{@prefixed_name}:#{@container_path}"
        end

        def clean
          if exists?
            say "Removing volume #{@prefixed_name}"
            Docker.interface.run(
              'volume',
              'rm',
              @prefixed_name,
            )
          end
        end

        def exists?
          Docker.interface.run(
            'volume',
            'ls',
            '--quiet',
            '--filter', "name=^#{@prefixed_name}$",
            output: :id,
          )
        end
      end

      class Bind < Base
        def initialize(local_path, container_path)
          @local_path = local_path
          @container_path = container_path
        end

        def to_param
          "#{@local_path}:#{@container_path}"
        end

        def clean
          # nothing to do
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rascal-0.3.7 lib/rascal/docker/volume.rb
rascal-0.3.6 lib/rascal/docker/volume.rb
rascal-0.3.5 lib/rascal/docker/volume.rb
rascal-0.3.4 lib/rascal/docker/volume.rb
rascal-0.3.3 lib/rascal/docker/volume.rb
rascal-0.3.2 lib/rascal/docker/volume.rb
rascal-0.3.1 lib/rascal/docker/volume.rb
rascal-0.3.0 lib/rascal/docker/volume.rb
rascal-0.2.1 lib/rascal/docker/volume.rb
rascal-0.2.0 lib/rascal/docker/volume.rb