Sha256: 63f0a1d54a73e4ee5c0b5e0a8addea3b916dc97239be154fc5b199dac282442c
Contents?: true
Size: 1.48 KB
Versions: 6
Compression:
Stored size: 1.48 KB
Contents
require 'shellwords' module CIDE # Simple docker client helper module Docker # Generates a valid id for docker from any string def self.id(str) "#{str}".downcase.gsub(/[^a-z0-9\-_.]/, '_') end # Raised when a docker command exits with a status higher than zero class Error < StandardError attr_reader :exitstatus def initialize(exitstatus) @exitstatus = exitstatus super("Failed with exitstatus #{exitstatus}") end end class VersionError < StandardError; end def docker(*args, **opts) setup_docker ret = run Shellwords.join(['docker'] + args), opts exitstatus = $?.exitstatus fail Error, exitstatus if exitstatus > 0 ret end protected def setup_docker @setup_docker ||= ( if `uname`.strip == 'Darwin' && !ENV['DOCKER_HOST'] unless system('which boot2docker >/dev/null 2>&1') puts 'make sure boot2docker is installed and running' puts puts '> brew install boot2docker' exit 1 end `boot2docker shellinit 2>/dev/null` .lines .grep(/export (\w+)=(.*)/) { ENV[$1] = $2.strip } end # Check docker version unless `docker version 2>/dev/null` =~ /Client version: ([^\s]+)/ fail VersionError, 'Unknown docker version' end fail VersionError, "Docker version #{$1} too old" if $1 < '1.5.0' true ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
cide-0.6.1 | lib/cide/docker.rb |
cide-0.6.0 | lib/cide/docker.rb |
cide-0.5.0 | lib/cide/docker.rb |
cide-0.4.1 | lib/cide/docker.rb |
cide-0.4.0 | lib/cide/docker.rb |
cide-0.2.0 | lib/cide/docker.rb |