dockit 1.8.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +2 -2
  3. data/VERSION +1 -1
  4. data/lib/dockit.rb +26 -17
  5. data/lib/dockit/cli.rb +29 -20
  6. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef7365a09071c0358f23ed17ed670b15bd9f3f91
4
- data.tar.gz: 062246eb13c406ba75125f815d95b45b0bc17268
3
+ metadata.gz: c028879bc5c35215d74edc86f94c914e6995ae74
4
+ data.tar.gz: a3ff836fa1b0459a361e201fee8e0c9a3be75029
5
5
  SHA512:
6
- metadata.gz: d71b2c9f2af87dd739037fe54dee9de742b4de441f47f5f83c7e21381a6ce14b60a39f046e855794a825445dc64ddb2e84d134e28eb84a836c84c71ef513578e
7
- data.tar.gz: 71fdb7a5879d9ec895bfe9f60315d7720d020b11ba76e27d761e9b94738be8624e621152303c0ba52d8adb164f2632ef5abac8a02a28cb752f3eb716b0e2c746
6
+ metadata.gz: e2b680e81a2939e67248af511bf995e76b52c81bb3dcc6021e1e0ead4861f12d0ed2809c23e76b6c6621e4712ff3986d04da829cac76725349070bdb49db8022
7
+ data.tar.gz: f4cfdfa504680b59061780d8610d6fa5779ebb1e34a938f0162e3e9244ca528561d03a2a724c010a023548bb03d2f705a3306bd96399a2826d5efb41d43bb0f3
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
- FROM cybercode/alpine-ruby:2.2
2
- ENV DOCKER_VERSION=1.9.1 BIN=/usr/local/bin/docker
1
+ FROM cybercode/alpine-ruby:2.3
2
+ ENV DOCKER_VERSION=1.11.1 BIN=/usr/local/bin/docker
3
3
 
4
4
  RUN apk --update add curl ruby-json && curl -sSL -o $BIN \
5
5
  https://get.docker.com/builds/Linux/x86_64/docker-$DOCKER_VERSION \
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.0
1
+ 2.0.1
data/lib/dockit.rb CHANGED
@@ -16,28 +16,37 @@ module Dockit
16
16
  def debug(msg)
17
17
  $stderr.puts "DEBUG: " + msg.join(' ')
18
18
  end
19
-
20
- def self.print_chunk(chunk)
21
- begin
22
- chunk = JSON.parse(chunk)
23
- rescue Docker::Error::UnexpectedResponseError => e
24
- $stderr.puts "Response parse error:", e.message, chunk
19
+ class << self
20
+ # new docker app (xhyve) returns multi-line (multiple JSON hash) chunks.
21
+ # So, split them up before trying to parse them.
22
+ def print_chunk(chunk)
23
+ chunk.each_line { |c| print_one_chunk(c) }
25
24
  end
26
25
 
27
- progress = chunk['progress']
28
- id = progress ? '' : chunk['id']
29
- $stdout.puts(
30
- if chunk['errorDetail']
31
- 'ERROR: ' + chunk['errorDetail']['message']
32
- elsif chunk['stream']
33
- chunk['stream']
34
- else
35
- [chunk['status'], id, progress, progress ? "\r" : "\n"].join(' ')
26
+ private
27
+ def print_one_chunk(chunk)
28
+ begin
29
+ chunk = JSON.parse(chunk)
30
+ rescue Docker::Error::UnexpectedResponseError => e
31
+ $stderr.puts "Unexpected response:", e.message, chunk
32
+ rescue JSON::ParserError
33
+ $stderr.puts "Parse Error: #{chunk}"
36
34
  end
37
- )
35
+
36
+ progress = chunk['progress']
37
+ id = progress ? '' : chunk['id']
38
+ $stdout.puts(
39
+ if chunk['errorDetail']
40
+ 'ERROR: ' + chunk['errorDetail']['message']
41
+ elsif chunk['stream']
42
+ chunk['stream']
43
+ else
44
+ [chunk['status'], id, progress, progress ? "\r" : "\n"].join(' ')
45
+ end
46
+ )
47
+ end
38
48
  end
39
49
  end
40
-
41
50
  # This class encapsulates the environment used in the Dockit cli.
42
51
  # The class has three main attributes:
43
52
  #
data/lib/dockit/cli.rb CHANGED
@@ -1,7 +1,10 @@
1
+ # coding: utf-8
1
2
  require 'io/console'
2
3
  require 'thor'
3
4
  require 'dockit'
4
5
 
6
+ GIT_BRANCH=`git symbolic-ref --short HEAD 2>/dev/null`.chomp
7
+
5
8
  class SubCommand < Thor
6
9
  no_commands do
7
10
  # invoke command against the Dockit.yaml for the given service.
@@ -124,17 +127,21 @@ class Default < Thor
124
127
  option :images , type: :boolean, default: true , desc: "remove danging images"
125
128
  option :containers, type: :boolean, default: true , desc: "remove exited containers"
126
129
  option :volumes , type: :boolean, default: true , desc: 'remove dangling volumes'
127
- option :force , type: :boolean, default: false, desc: "stop and remove all"
128
- option 'except-containers', type: :array, desc: "container names to leave if :force", aliases: %[C]
129
- option 'except-images', type: :array, desc: "image tags (name:version) to leave if :force", aliases: %[I]
130
-
130
+ option 'force-containers', type: :boolean, default: false,
131
+ desc: 'stop and remove all containers', aliases: %[f]
132
+ option 'except-containers', type: :array,
133
+ desc: "container names to leave if 'force-containers' true", aliases: %[C]
134
+ option 'force-images', type: :boolean, default: false, desc: 'remove ALL volumes'
135
+ option 'except-images', type: :array,
136
+ desc: "image tags (name:version) to leave if 'force-images' true", aliases: %[I]
131
137
  def cleanup
132
- force = options[:force]
133
138
  Dockit::Container.clean(
134
- force: force, except: options['except-containers']) if options[:containers]
139
+ force: options['force-containers'], except: options['except-containers']
140
+ ) if options[:containers]
135
141
 
136
142
  Dockit::Image.clean(
137
- force: force, except: options['except-images']) if options[:images]
143
+ force: options['force-images'], except: options['except-images']
144
+ ) if options[:images]
138
145
 
139
146
  if options[:volumes] && Docker.version['ApiVersion'].to_f >= 1.21
140
147
  Dockit::Volume.clean
@@ -149,6 +156,7 @@ class Default < Thor
149
156
  say s.config.instance_variable_get('@config').to_yaml
150
157
  end
151
158
  end
159
+
152
160
  desc 'push REGISTRY [SERVICE]', 'push image for SERVICE to REGSITRY'
153
161
  option :force, type: :boolean, desc: 'overwrite current lastest version'
154
162
  option :tag, desc: 'repos tag (defaults to "latest")', aliases: ['t']
@@ -175,32 +183,29 @@ class Default < Thor
175
183
  end
176
184
 
177
185
  desc 'git-build', 'build from git (gem) repository'
178
- option :branch, desc: '<tree-ish> git reference', default: 'master'
179
- option :gem, type: :boolean, desc: "update Gemfiles export"
186
+ option :branch, desc: '<tree-ish> git reference', default: GIT_BRANCH
180
187
  option :package, type: :boolean, desc: "update package config export"
181
188
  long_desc <<-LONGDESC
182
189
  Dockit.yaml keys used:
183
190
  \x5 repos_path: optional treeish path
184
191
  \x5 repos: repository location
185
- \x5 package: optional (default 'Gemfile*')
192
+ \x5 package: optional
186
193
 
187
194
  `dockit git-build` will export {branch}:repos_path from the
188
195
  repository location specified in the :repos key to 'repos.tar.gz'
189
196
 
190
- The '--package' option will export the files in the :package key (or
191
- Gemfile*) in Dockit.yaml separately to 'package.tar.gz'. This is docker
192
- best practice for building rails apps.
197
+ The '--package' option will export the files in the :package key in
198
+ Dockit.yaml separately to 'package.tar.gz'. This is docker best practice
199
+ for building rails apps.
193
200
 
194
- *Note* The default (Gemfile*) will be removed in version 2.0.
195
-
196
- The deprecated '--gem' option is will export the packages to
197
- 'gemfile.tar.gz'.
201
+ *Breaking change (2.0)* ~branch~ now defaults to the *current* local
202
+ branch, not ~master~.
198
203
  LONGDESC
199
204
 
200
205
  def git_build(service=nil)
201
206
  exec(service) do |s|
202
207
  unless repos = s.config.get(:repos)
203
- say "'repos' not defined in config file. Exiting", :red
208
+ say "'repos' not defined in config file. Exiting", :red
204
209
  exit 1
205
210
  end
206
211
  path = s.config.get(:repos_path)
@@ -212,8 +217,12 @@ class Default < Thor
212
217
  say "Exporting in #{Dir.pwd}", :green
213
218
  say "<- #{repos} #{treeish}", :green
214
219
 
215
- if options.gem || options.package
216
- packages = s.config.get(:package) || 'Gemfile*'
220
+ if options.package
221
+ unless packages = s.config.get(:package)
222
+ say "'packages' not defined in config file. Exiting…", :red
223
+ exit 1
224
+ end
225
+
217
226
  archive = options.gem ? 'gemfile.tar.gz' : 'package.tar.gz'
218
227
  say "-> #{archive}", :green
219
228
  export(repos, treeish, archive, packages)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Frankel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.5.1
195
+ rubygems_version: 2.6.4
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: A configuration manager and builder for docker projects.
@@ -207,3 +207,4 @@ test_files:
207
207
  - spec/dockit/simple.yaml
208
208
  - spec/dockit_spec.rb
209
209
  - spec/spec_helper.rb
210
+ has_rdoc: