wash 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.
- checksums.yaml +4 -4
- data/lib/wash.rb +2 -2
- data/lib/wash/entry.rb +58 -4
- data/lib/wash/method.rb +3 -3
- data/lib/wash/streamer.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaae396f56664799c39570eef26c32861301ac233717133cb9cf00a3bb889262
|
4
|
+
data.tar.gz: e618c3d78d9dcff5aeb2a3cbaa3642a66a947026bd25176d2cfd692f9a14e76c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe1ee4d30afcd383893007022ffbd306ac6c324ca67ce8387d77faf407abd0a7f184c86428473f101358f4d99d743716e24b9161e3352a50fe55b0b0f4809bc
|
7
|
+
data.tar.gz: 7d1b888019d19babb129227b77996be16e16e7994e7c6d4b8627bf3f735277fc0afa0e5e7eb1a5c95c38937347d6f3bf6c12cf6250b5eabfe8288081b9226cb7
|
data/lib/wash.rb
CHANGED
@@ -9,7 +9,7 @@ module Wash
|
|
9
9
|
@pretty_print = true
|
10
10
|
end
|
11
11
|
|
12
|
-
# enable_entry_schemas enables {Entry schema}[https://puppetlabs.github.io/wash/docs
|
12
|
+
# enable_entry_schemas enables {Entry schema}[https://puppetlabs.github.io/wash/docs/external-plugins#entry-schemas]
|
13
13
|
# support. See {Wash::Entry}'s documentation for more details on
|
14
14
|
# the available Entry schema helpers.
|
15
15
|
def self.enable_entry_schemas
|
@@ -126,7 +126,7 @@ module Wash
|
|
126
126
|
private_class_method :print_json
|
127
127
|
|
128
128
|
def self.parse_json(json)
|
129
|
-
JSON.parse(json
|
129
|
+
JSON.parse(json, symbolize_names: true)
|
130
130
|
end
|
131
131
|
private_class_method :parse_json
|
132
132
|
|
data/lib/wash/entry.rb
CHANGED
@@ -66,7 +66,7 @@ module Wash
|
|
66
66
|
# end
|
67
67
|
# end
|
68
68
|
#
|
69
|
-
# Note that Wash.run uses
|
69
|
+
# Note that Wash.run uses Class#allocate when it reconstructs the entries, so
|
70
70
|
# it does not call the initialize method.
|
71
71
|
def state(field, *fields)
|
72
72
|
@state ||= []
|
@@ -187,6 +187,11 @@ module Wash
|
|
187
187
|
end
|
188
188
|
visited[type_id][:children] = @child_klasses
|
189
189
|
@child_klasses.each do |child_klass|
|
190
|
+
if child_klass == VOLUMEFS
|
191
|
+
visited[child_klass] = {}
|
192
|
+
next
|
193
|
+
end
|
194
|
+
|
190
195
|
child_klass = const_get(child_klass)
|
191
196
|
if visited[child_klass.send(:type_id)]
|
192
197
|
next
|
@@ -237,6 +242,10 @@ module Wash
|
|
237
242
|
end
|
238
243
|
end
|
239
244
|
|
245
|
+
# Name of the volume filesystem type in Wash. Use with `parent_of` when
|
246
|
+
# returning `volumefs` in your `list` method.
|
247
|
+
VOLUMEFS = '__volume::fs__'
|
248
|
+
|
240
249
|
# All entries have a name. Note that the name is always
|
241
250
|
# included in the entry's state hash.
|
242
251
|
attr_accessor :name
|
@@ -244,7 +253,7 @@ module Wash
|
|
244
253
|
# Contains the entry's partial metadata.
|
245
254
|
attr_accessor :partial_metadata
|
246
255
|
|
247
|
-
def to_json(
|
256
|
+
def to_json(jstate = {})
|
248
257
|
unless @name && @name.size > 0
|
249
258
|
unless singleton
|
250
259
|
raise "A nameless entry is being serialized. The entry is an instance of #{type_id}"
|
@@ -268,6 +277,8 @@ module Wash
|
|
268
277
|
# supporting more overloaded methods
|
269
278
|
block_readable = self.method(:read).arity > 0
|
270
279
|
[:read, block_readable]
|
280
|
+
elsif method == :exec && @transport
|
281
|
+
[:exec, { transport: @transport[0], options: @transport[1] }]
|
271
282
|
else
|
272
283
|
method
|
273
284
|
end
|
@@ -290,9 +301,9 @@ module Wash
|
|
290
301
|
end
|
291
302
|
hash[:state] = to_hash(state).merge(klass: type_id, name: @name).to_json
|
292
303
|
if Wash.send(:pretty_print?)
|
293
|
-
JSON.pretty_generate(hash)
|
304
|
+
JSON.pretty_generate(hash, jstate)
|
294
305
|
else
|
295
|
-
JSON.generate(hash)
|
306
|
+
JSON.generate(hash, jstate)
|
296
307
|
end
|
297
308
|
end
|
298
309
|
|
@@ -343,6 +354,49 @@ module Wash
|
|
343
354
|
@cache_ttls = @cache_ttls.merge(ttls)
|
344
355
|
end
|
345
356
|
|
357
|
+
# volumefs creates the `volume::fs` entry as specified in Wash's external plugin docs.
|
358
|
+
#
|
359
|
+
# @example
|
360
|
+
# class Foo
|
361
|
+
# parent_of VOLUMEFS
|
362
|
+
# def list
|
363
|
+
# [volumefs('fs', maxdepth: 5), Bar.new]
|
364
|
+
# end
|
365
|
+
# end
|
366
|
+
#
|
367
|
+
# @param [String] name The name to use for the child representing the remote filesystem.
|
368
|
+
# @param [Hash] options Options to configure the filesystem.
|
369
|
+
# - maxdepth: How deep to walk the remote filesystem when needed. This is a trade-off
|
370
|
+
# between speed of the transport and filesystem complexity. For fast transports it
|
371
|
+
# should be low (1-3), for slower transports higher (3-6).
|
372
|
+
def volumefs(name, options = {})
|
373
|
+
{ type_id: VOLUMEFS, name: name, state: options.to_json }
|
374
|
+
end
|
375
|
+
|
376
|
+
# transport requests that Wash use a built-in transport with the supplied
|
377
|
+
# transport options to implement Exec. When using this feature, you must
|
378
|
+
# also declare the 'exec' method so it's included in the schema. You may
|
379
|
+
# use this to implement a fallback implementation for entries where the
|
380
|
+
# transport feature is not used.
|
381
|
+
#
|
382
|
+
# @example
|
383
|
+
# class Foo
|
384
|
+
# def initialize(name)
|
385
|
+
# transport :ssh, host: name, user: 'root'
|
386
|
+
# end
|
387
|
+
#
|
388
|
+
# def exec
|
389
|
+
# raise 'implemented by transport'
|
390
|
+
# end
|
391
|
+
# end
|
392
|
+
#
|
393
|
+
# @param [Symbol] klass The transport to use. Only `:ssh` is supported
|
394
|
+
# @param [Hash] options For SSH: :host (required), :user, :fallback_user,
|
395
|
+
# :password, :identity_file, :known_hosts, :host_key_alias, :retries, :port
|
396
|
+
def transport(klass, options = {})
|
397
|
+
@transport = [klass, options]
|
398
|
+
end
|
399
|
+
|
346
400
|
# schema returns the entry's schema. It should not be overridden.
|
347
401
|
def schema
|
348
402
|
schemaHash = {}
|
data/lib/wash/method.rb
CHANGED
@@ -42,17 +42,17 @@ module Wash
|
|
42
42
|
# the size and offset
|
43
43
|
args = args.map(&:to_i)
|
44
44
|
end
|
45
|
-
|
45
|
+
$stdout.print(entry.read(*args))
|
46
46
|
end
|
47
47
|
|
48
48
|
method(:write) do |entry, _|
|
49
|
-
entry.write(
|
49
|
+
entry.write($stdin)
|
50
50
|
end
|
51
51
|
|
52
52
|
method(:exec) do |entry, *args|
|
53
53
|
opts, cmd, args = Wash.send(:parse_json, args[0]), args[1], args[2..-1]
|
54
54
|
if opts[:stdin]
|
55
|
-
opts[:stdin] =
|
55
|
+
opts[:stdin] = $stdin
|
56
56
|
else
|
57
57
|
opts[:stdin] = nil
|
58
58
|
end
|
data/lib/wash/streamer.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for building Wash external plugins
|
14
14
|
email:
|
@@ -40,8 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
|
44
|
-
rubygems_version: 2.7.3
|
43
|
+
rubygems_version: 3.0.3
|
45
44
|
signing_key:
|
46
45
|
specification_version: 4
|
47
46
|
summary: A library for building Wash external plugins
|