qb 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/exe/qb +3 -0
- data/lib/qb/ansible.rb +5 -3
- data/lib/qb/ansible/{cmds → cmd}/playbook.rb +19 -5
- data/lib/qb/cli/play.rb +5 -5
- data/lib/qb/cli/run.rb +1 -1
- data/lib/qb/cli/setup.rb +3 -3
- data/lib/qb/docker/image.rb +8 -26
- data/lib/qb/docker/image/name.rb +20 -8
- data/lib/qb/package/version.rb +15 -3
- data/lib/qb/package/version/from.rb +42 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 023cb0a8d6ea38e59c77d21236f4c95944843093
|
4
|
+
data.tar.gz: 7d307bb9c37772b4dd06a0d9f1f3af694c5425d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25520e571a52e90950dfff2263d4e57154900adb42f63fea546fa1967b175f45bdebd276145a5741f2001ebfbf1791b4065e28cda4b63588a70eeabc81a1cf53
|
7
|
+
data.tar.gz: 3de536eadddf790d77ea0d3e97af2a1d6c03c39d179e45bc96b259f3302ccf3d6eda933731d89f7f370558d02b7166744127712013af220ca40b305c428274e9
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/exe/qb
CHANGED
data/lib/qb/ansible.rb
CHANGED
@@ -12,14 +12,20 @@ require 'qb/util/bundler'
|
|
12
12
|
require 'qb/ipc/stdio/server'
|
13
13
|
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
module QB::Ansible::Cmds; end
|
15
|
+
# Namespace
|
16
|
+
# ========================================================================
|
18
17
|
|
18
|
+
module QB
|
19
|
+
module Ansible
|
20
|
+
module Cmd
|
21
|
+
|
22
|
+
|
23
|
+
# Definitions
|
24
|
+
# ========================================================================
|
19
25
|
|
20
26
|
# A command object that runs a playbook with all the QB specialness.
|
21
27
|
#
|
22
|
-
class
|
28
|
+
class Playbook < Cmds
|
23
29
|
DEFAULT_PLAYBOOK_PATH = '.qb-playbook.yml'
|
24
30
|
|
25
31
|
# Default executable to use, just uses a bare `ansible-playbook`, letting
|
@@ -241,4 +247,12 @@ class QB::Ansible::Cmds::Playbook < ::Cmds
|
|
241
247
|
|
242
248
|
# end protected
|
243
249
|
|
244
|
-
end # class
|
250
|
+
end # class Playbook
|
251
|
+
|
252
|
+
|
253
|
+
# Namespace
|
254
|
+
# ========================================================================
|
255
|
+
|
256
|
+
end # module Cmd
|
257
|
+
end # module Ansible
|
258
|
+
end # module QB
|
data/lib/qb/cli/play.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# =====================================================================
|
3
3
|
|
4
4
|
# package
|
5
|
-
require 'qb/ansible/
|
5
|
+
require 'qb/ansible/cmd/playbook'
|
6
6
|
|
7
7
|
|
8
8
|
# Declarations
|
@@ -14,9 +14,9 @@ module QB; end
|
|
14
14
|
# Definitions
|
15
15
|
# =======================================================================
|
16
16
|
|
17
|
-
module QB::CLI
|
17
|
+
module QB::CLI
|
18
18
|
|
19
|
-
# Play an Ansible playbook (like `state.yml`) in the QB environment
|
19
|
+
# Play an Ansible playbook (like `state.yml`) in the QB environment
|
20
20
|
# (sets up path env vars, IO streams, etc.).
|
21
21
|
#
|
22
22
|
# @param [Array<String>] args
|
@@ -46,7 +46,7 @@ module QB::CLI
|
|
46
46
|
raise_on_not_found: false
|
47
47
|
|
48
48
|
# If we did find an Ansible config, we're going to want to run in that
|
49
|
-
# directory and add it to the role search path so that we merge it's
|
49
|
+
# directory and add it to the role search path so that we merge it's
|
50
50
|
# values into our env vars (otherwise they would override the config
|
51
51
|
# values).
|
52
52
|
unless ansible_cfg_path.nil?
|
@@ -54,7 +54,7 @@ module QB::CLI
|
|
54
54
|
chdir = ansible_cfg_path.dirname
|
55
55
|
end
|
56
56
|
|
57
|
-
cmd = QB::Ansible::
|
57
|
+
cmd = QB::Ansible::Cmd::Playbook.new \
|
58
58
|
chdir: chdir,
|
59
59
|
playbook_path: playbook_path
|
60
60
|
|
data/lib/qb/cli/run.rb
CHANGED
@@ -243,7 +243,7 @@ module QB::CLI
|
|
243
243
|
# stick the role path in front to make sure we get **that** role
|
244
244
|
env.roles_path.unshift role.path.expand_path.dirname
|
245
245
|
|
246
|
-
cmd = QB::Ansible::
|
246
|
+
cmd = QB::Ansible::Cmd::Playbook.new \
|
247
247
|
env: env,
|
248
248
|
playbook: playbook,
|
249
249
|
role_options: options,
|
data/lib/qb/cli/setup.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
require 'pathname'
|
6
6
|
|
7
7
|
# package
|
8
|
-
require 'qb/ansible/
|
8
|
+
require 'qb/ansible/cmd/playbook'
|
9
9
|
|
10
10
|
|
11
11
|
# Refinements
|
@@ -24,7 +24,7 @@ module QB; end
|
|
24
24
|
# Definitions
|
25
25
|
# =======================================================================
|
26
26
|
|
27
|
-
module QB::CLI
|
27
|
+
module QB::CLI
|
28
28
|
|
29
29
|
# Play `//dev/setup.yml`
|
30
30
|
#
|
@@ -65,7 +65,7 @@ module QB::CLI
|
|
65
65
|
raise "Can't find QB setup playbook at `#{ playbook_path.to_s }`"
|
66
66
|
end
|
67
67
|
|
68
|
-
cmd = QB::Ansible::
|
68
|
+
cmd = QB::Ansible::Cmd::Playbook.new \
|
69
69
|
chdir: project_root,
|
70
70
|
extra_vars: {
|
71
71
|
project_root: project_root,
|
data/lib/qb/docker/image.rb
CHANGED
@@ -44,25 +44,6 @@ class Image < QB::Data::Immutable
|
|
44
44
|
# ======================================================================
|
45
45
|
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
def self.with_name name, &block
|
50
|
-
block.call \
|
51
|
-
case name
|
52
|
-
when QB::Docker::Image::Name
|
53
|
-
name
|
54
|
-
when String
|
55
|
-
QB::Docker::Image::Name.from_s name
|
56
|
-
when Hash
|
57
|
-
QB::Docker::Image::Name.from_data name
|
58
|
-
else
|
59
|
-
raise NRSER::TypeError.new \
|
60
|
-
"Not sure what to do with ", name,
|
61
|
-
name: name
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
47
|
def self.names **opts
|
67
48
|
QB::Docker::CLI.image_names **opts
|
68
49
|
end
|
@@ -84,11 +65,15 @@ class Image < QB::Data::Immutable
|
|
84
65
|
end
|
85
66
|
end
|
86
67
|
|
68
|
+
private_class_method :run_cmd
|
69
|
+
|
87
70
|
|
88
71
|
def self.run_cmd! cmd, stream: true
|
89
72
|
run_cmd cmd, stream: stream, raise_on_fail: true
|
90
73
|
end
|
91
74
|
|
75
|
+
private_class_method :run_cmd!
|
76
|
+
|
92
77
|
|
93
78
|
def self.build! name:,
|
94
79
|
path:,
|
@@ -136,7 +121,8 @@ class Image < QB::Data::Immutable
|
|
136
121
|
pull: nil,
|
137
122
|
build: nil,
|
138
123
|
force: false,
|
139
|
-
push: false
|
124
|
+
push: false,
|
125
|
+
tags: []
|
140
126
|
|
141
127
|
name = QB::Docker::Image::Name.from name
|
142
128
|
|
@@ -156,9 +142,7 @@ class Image < QB::Data::Immutable
|
|
156
142
|
logger.info "Forcing build...",
|
157
143
|
name: name.to_s
|
158
144
|
|
159
|
-
build! name: name, **build
|
160
|
-
|
161
|
-
QB::Docker::CLI.push?( name: name ) if push
|
145
|
+
build! name: name, push: push, tags: tags, **build
|
162
146
|
|
163
147
|
return
|
164
148
|
end
|
@@ -183,9 +167,7 @@ class Image < QB::Data::Immutable
|
|
183
167
|
name: name.to_s,
|
184
168
|
path: build[:path]
|
185
169
|
|
186
|
-
build! name: name, **build
|
187
|
-
|
188
|
-
QB::Docker::CLI.push( name: name ) if push
|
170
|
+
build! name: name, push: push, tags: tags, **build
|
189
171
|
|
190
172
|
end # .ensure_present!
|
191
173
|
|
data/lib/qb/docker/image/name.rb
CHANGED
@@ -169,15 +169,20 @@ class Name < QB::Data::Immutable
|
|
169
169
|
end # .exists?
|
170
170
|
|
171
171
|
|
172
|
+
def self.all
|
173
|
+
QB::Docker::CLI.image_names load: true, only_named: true
|
174
|
+
end
|
175
|
+
|
176
|
+
|
172
177
|
# @see QB::Docker::CLI.image_names
|
173
178
|
#
|
174
|
-
|
175
|
-
|
176
|
-
|
179
|
+
def self.list **attrs
|
180
|
+
return all if attrs.empty?
|
181
|
+
|
182
|
+
type = t.attrs attrs
|
183
|
+
all.select { |name| type === name }
|
177
184
|
end # .list
|
178
185
|
|
179
|
-
singleton_class.send :alias_method, :all, :list
|
180
|
-
|
181
186
|
|
182
187
|
# Props
|
183
188
|
# ======================================================================
|
@@ -208,6 +213,7 @@ class Name < QB::Data::Immutable
|
|
208
213
|
# @return [String?]
|
209
214
|
# String is non-empty.
|
210
215
|
prop :repository,
|
216
|
+
aliases: [ :repo ],
|
211
217
|
type: t.non_empty_str?
|
212
218
|
|
213
219
|
|
@@ -217,6 +223,7 @@ class Name < QB::Data::Immutable
|
|
217
223
|
# @return [String?]
|
218
224
|
# String is non-empty.
|
219
225
|
prop :registry_server,
|
226
|
+
aliases: [ :reg ],
|
220
227
|
type: t.non_empty_str?
|
221
228
|
|
222
229
|
|
@@ -238,8 +245,7 @@ class Name < QB::Data::Immutable
|
|
238
245
|
source: :to_s
|
239
246
|
|
240
247
|
|
241
|
-
invariant t.attrs( registry_server: t.nil, port: t.nil )
|
242
|
-
t.attrs( registry_server: ~t.nil, port: ~t.nil )
|
248
|
+
invariant ~t.attrs( registry_server: t.nil, port: ~t.nil )
|
243
249
|
|
244
250
|
|
245
251
|
# Instance Methods
|
@@ -272,7 +278,13 @@ class Name < QB::Data::Immutable
|
|
272
278
|
|
273
279
|
|
274
280
|
def host
|
275
|
-
|
281
|
+
return unless registry_server
|
282
|
+
|
283
|
+
if port
|
284
|
+
"#{ registry_server }:#{ port }"
|
285
|
+
else
|
286
|
+
registry_server
|
287
|
+
end
|
276
288
|
end
|
277
289
|
|
278
290
|
|
data/lib/qb/package/version.rb
CHANGED
@@ -344,6 +344,11 @@ class Version < QB::Util::Resource
|
|
344
344
|
alias_method :dirty?, :build_dirty?
|
345
345
|
|
346
346
|
|
347
|
+
def level?
|
348
|
+
is_a? QB::Package::Version::Leveled
|
349
|
+
end
|
350
|
+
|
351
|
+
|
347
352
|
# Derived Properties
|
348
353
|
# ---------------------------------------------------------------------
|
349
354
|
|
@@ -417,9 +422,12 @@ class Version < QB::Util::Resource
|
|
417
422
|
|
418
423
|
# Return a new {QB::Package::Version} with build information added.
|
419
424
|
#
|
425
|
+
#
|
426
|
+
#
|
420
427
|
# @return [QB::Package::Version]
|
421
428
|
#
|
422
429
|
def build_version *build, branch: nil, ref: nil, time: nil, dirty: nil
|
430
|
+
build.map! &:to_s
|
423
431
|
|
424
432
|
repo_segments = [
|
425
433
|
branch,
|
@@ -428,12 +436,16 @@ class Version < QB::Util::Resource
|
|
428
436
|
(self.class.to_time_segment(time) if dirty && time),
|
429
437
|
].compact
|
430
438
|
|
431
|
-
if repo_segments.empty?
|
439
|
+
if build.empty? && repo_segments.empty?
|
432
440
|
raise ArgumentError,
|
433
|
-
"Need to provide at least one
|
441
|
+
"Need to provide at least one arg: build, branch, ref, dirty."
|
442
|
+
end
|
443
|
+
|
444
|
+
unless repo_segments.empty?
|
445
|
+
build = [*build, repo_segments.join( '-' )]
|
434
446
|
end
|
435
447
|
|
436
|
-
merge raw: nil, build:
|
448
|
+
merge raw: nil, build: build
|
437
449
|
end
|
438
450
|
|
439
451
|
|
@@ -192,15 +192,17 @@ module QB::Package::Version::From
|
|
192
192
|
|
193
193
|
identifier_for_ref = method :identifier_for
|
194
194
|
|
195
|
-
if
|
195
|
+
if source.include?( '-' ) &&
|
196
|
+
source.include?( '+' ) &&
|
197
|
+
source.index( '-' ) < source.index( '+' )
|
196
198
|
release_str, _, rest = source.partition '-'
|
197
199
|
pre_str, _, build_str = rest.partition '+'
|
198
|
-
elsif source.include?( '-' )
|
199
|
-
release_str, _, pre_str = source.partition '-'
|
200
|
-
build_str = ''
|
201
200
|
elsif source.include?( '+' )
|
202
201
|
release_str, _, build_str = source.partition '+'
|
203
202
|
pre_str = ''
|
203
|
+
elsif source.include?( '-' )
|
204
|
+
release_str, _, pre_str = source.partition '-'
|
205
|
+
build_str = ''
|
204
206
|
else
|
205
207
|
release_str = source
|
206
208
|
pre_str = build_str = ''
|
@@ -303,4 +305,40 @@ module QB::Package::Version::From
|
|
303
305
|
end
|
304
306
|
end
|
305
307
|
|
308
|
+
|
309
|
+
# Load a {QB::Package::Version} from a file.
|
310
|
+
#
|
311
|
+
# Just reads the file and passes the contents to {.string}.
|
312
|
+
#
|
313
|
+
# @param [String | Pathname | IO] file
|
314
|
+
# File path or handle to read from.
|
315
|
+
#
|
316
|
+
# @return [QB::Package::Version]
|
317
|
+
#
|
318
|
+
def self.file path
|
319
|
+
string File.read( path )
|
320
|
+
end
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
def self.repo repo_or_path, add_build: true
|
325
|
+
repo = t.match repo_or_path,
|
326
|
+
QB::Repo, repo_or_path,
|
327
|
+
t.path, QB::Repo.method( :from_path )
|
328
|
+
|
329
|
+
version_path = repo.root_path / 'VERSION'
|
330
|
+
file_version = file version_path
|
331
|
+
|
332
|
+
if add_build &&
|
333
|
+
file_version.level? &&
|
334
|
+
file_version.dev?
|
335
|
+
file_version.build_version \
|
336
|
+
branch: repo.branch,
|
337
|
+
ref: repo.head_short,
|
338
|
+
dirty: !repo.clean?
|
339
|
+
else
|
340
|
+
file_version
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
306
344
|
end # module QB::Package::Version::From
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -281,7 +281,7 @@ files:
|
|
281
281
|
- lib/python/qb/strings.py
|
282
282
|
- lib/qb.rb
|
283
283
|
- lib/qb/ansible.rb
|
284
|
-
- lib/qb/ansible/
|
284
|
+
- lib/qb/ansible/cmd/playbook.rb
|
285
285
|
- lib/qb/ansible/config_file.rb
|
286
286
|
- lib/qb/ansible/env.rb
|
287
287
|
- lib/qb/ansible/env/devel.rb
|