Sha256: efa9b9e7d89029b62ee9be1943548e1cf164a5c9c84a3d5ef1a0c118214b2ceb

Contents?: true

Size: 1.21 KB

Versions: 13

Compression:

Stored size: 1.21 KB

Contents

require "vagrant/util/busy"
require "vagrant/util/subprocess"

module VagrantPlugins
  module DockerProvider
    module Executor
      # The Local executor executes a Docker client that is running
      # locally.
      class Local
        def execute(*cmd, **opts, &block)
          # Append in the options for subprocess
          cmd << { notify: [:stdout, :stderr] }

          interrupted  = false
          int_callback = ->{ interrupted = true }
          result = ::Vagrant::Util::Busy.busy(int_callback) do
            ::Vagrant::Util::Subprocess.execute(*cmd, &block)
          end

          result.stderr.gsub!("\r\n", "\n")
          result.stdout.gsub!("\r\n", "\n")

          if result.exit_code != 0 && !interrupted
            raise Errors::ExecuteError,
              command: cmd.inspect,
              stderr: result.stderr,
              stdout: result.stdout
          end

          if opts
            if opts[:with_stderr]
              return result.stdout + " " + result.stderr
            else
              return result.stdout
            end
          end
        end

        def windows?
          ::Vagrant::Util::Platform.windows? || ::Vagrant::Util::Platform.wsl?
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/providers/docker/executor/local.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.3.3.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.3.2.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.19.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.18.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.16.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.14.0 plugins/providers/docker/executor/local.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.10.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.9.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.8.0 plugins/providers/docker/executor/local.rb
vagrant-unbundled-2.2.7.0 plugins/providers/docker/executor/local.rb