docker-spoon 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/Gemfile.lock +1 -1
  2. data/lib/spoon.rb +16 -14
  3. data/lib/spoon/version.rb +1 -1
  4. metadata +2 -2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- docker-spoon (0.3.0)
4
+ docker-spoon (0.4.0)
5
5
  docker-api (~> 1.11)
6
6
  methadone (~> 1.4.0)
7
7
  rainbow (~> 2.0)
data/lib/spoon.rb CHANGED
@@ -11,7 +11,7 @@ module Spoon
11
11
  version(Spoon::VERSION)
12
12
 
13
13
  main do |instance|
14
- parse_config(options[:config])
14
+
15
15
  D options.inspect
16
16
  if options[:list]
17
17
  instance_list
@@ -55,24 +55,19 @@ module Spoon
55
55
  on("-c", "--config FILE", "Config file to use for spoon options")
56
56
  on("--debug", "Enable debug")
57
57
 
58
+ # Read config file & set options
59
+ eval(File.open(options[:config]).read)
60
+
58
61
  arg(:instance, :optional, "Spoon instance to connect to")
59
62
 
60
63
  use_log_level_option
61
64
 
62
- def self.parse_config(config_file)
63
- eval(File.open(config_file).read)
64
- end
65
-
66
65
  def self.apply_prefix(name)
67
- "spoon-#{name}"
66
+ "#{options[:prefix]}#{name}"
68
67
  end
69
68
 
70
69
  def self.remove_prefix(name)
71
- if name.start_with? "/"
72
- name[7..-1]
73
- else
74
- name[6..-1]
75
- end
70
+ name.gsub(/\/?#{options[:prefix]}/, '')
76
71
  end
77
72
 
78
73
  def self.image_build
@@ -84,7 +79,9 @@ module Spoon
84
79
 
85
80
  docker_url
86
81
  build_opts = { 't' => options[:image], 'rm' => true }
87
- Docker::Image.build_from_dir(options[:builddir], build_opts) do |chunk|
82
+ docker_connection = ::Docker::Connection.new(options[:url], :read_timeout => 3000)
83
+
84
+ Docker::Image.build_from_dir(options[:builddir], build_opts, docker_connection) do |chunk|
88
85
  print_docker_response(chunk)
89
86
  end
90
87
  end
@@ -138,16 +135,21 @@ module Spoon
138
135
  def self.instance_list
139
136
  docker_url
140
137
  puts "List of available spoon containers:"
141
- container_list = get_all_containers
138
+ container_list = get_all_containers.sort { |c1, c2| c1.info["Names"].first.to_s <=> c2.info["Names"].first.to_s }
142
139
  container_list.each do |container|
143
140
  name = container.info["Names"].first.to_s
144
141
  if name.start_with? "/#{options[:prefix]}"
145
142
  running = is_running?(container) ? Rainbow("Running").green : Rainbow("Stopped").red
146
- puts "#{remove_prefix(name)} [ #{running} ]".rjust(40)
143
+ puts "#{remove_prefix(name)} [ #{running} ]".rjust(40) + " " + Rainbow(image_name(container)).yellow
147
144
  end
148
145
  end
149
146
  end
150
147
 
148
+ def self.image_name(container)
149
+ env = Hash[container.json['Config']['Env'].collect { |v| v.split('=') }]
150
+ return env['IMAGE_NAME'] || container.json['Config']['Image'].split(':').first
151
+ end
152
+
151
153
  def self.strip_slash(name)
152
154
  if name.start_with? "/"
153
155
  name[1..-1]
data/lib/spoon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spoon
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-spoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-24 00:00:00.000000000 Z
12
+ date: 2014-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler