mongoid-shell 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +9 -0
- data/lib/mongoid/shell/commands/base.rb +38 -9
- data/lib/mongoid/shell/commands/mongo.rb +8 -17
- data/lib/mongoid/shell/commands/mongodump.rb +16 -27
- data/lib/mongoid/shell/commands/mongoexport.rb +41 -53
- data/lib/mongoid/shell/commands/mongoimport.rb +41 -61
- data/lib/mongoid/shell/commands/mongorestore.rb +16 -25
- data/lib/mongoid/shell/commands/mongostat.rb +8 -18
- data/lib/mongoid/shell/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e80be659912607683e05be144ad4456b51a999
|
4
|
+
data.tar.gz: 9d43a23815209ba7354f1fc22bc8a7f54286d382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7fb5e80531426776aa4828a30e9dd5d328dff0db4430e20e50f5498c8ad72a1146c5b493e688283ec95ef65fc648fbd6fae72db52ff2d15eac0200d8b332aed
|
7
|
+
data.tar.gz: 8a35c2256c55e8fa5c2ac3dcf2b998e7b8e32331b3f35e27fac021ffac1cf676419afd2ad42670443142465a2973a1294f4ccf81fcc53ef3bfb1344f03397ddf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### 0.4.5 (9/7/2017)
|
2
|
+
|
3
|
+
* [#13](https://github.com/mongoid/mongoid-shell/issues/13): Support masking sensitive values with `to_s(mask_sensitive: true)` - [@dblock](https://github.com/dblock).
|
4
|
+
* [#14](https://github.com/mongoid/mongoid-shell/pull/14): Refactored arg definitions into `arg` and `option` - [@dblock](https://github.com/dblock).
|
5
|
+
|
1
6
|
### 0.4.4 (6/4/2017)
|
2
7
|
|
3
8
|
* [#11](https://github.com/mongoid/mongoid-shell/pull/11): Compatibility with Mongoid 6 - [@jbach](https://github.com/jbach).
|
data/README.md
CHANGED
@@ -43,6 +43,15 @@ mongodump = Mongoid::Shell::Commands::Mongodump.new(excludeCollection: %w(users
|
|
43
43
|
system mongodump.to_s # mongodump --excludeCollection users --excludeCollection products
|
44
44
|
```
|
45
45
|
|
46
|
+
To use output in logs, pass the `mask_sensitive` option to `to_s`.
|
47
|
+
|
48
|
+
``` ruby
|
49
|
+
> Mongoid::Shell::Commands::Mongo.new.to_s(mask_sensitive: true)
|
50
|
+
=> "mongo 59.1.22.1:27017/mongoid --username user --password ********"
|
51
|
+
|
52
|
+
> Mongoid::Shell::Commands::Mongo.new.to_s(mask_sensitive: '(masked)')
|
53
|
+
=> "mongo 59.1.22.1:27017/mongoid --username user --password (masked)"
|
54
|
+
```
|
46
55
|
|
47
56
|
Compatibility
|
48
57
|
-------------
|
@@ -5,9 +5,31 @@ module Mongoid
|
|
5
5
|
attr_accessor :session
|
6
6
|
|
7
7
|
class << self
|
8
|
+
attr_accessor :args
|
9
|
+
@args = {}
|
10
|
+
|
11
|
+
def inherit_args(args)
|
12
|
+
@args ||= {}
|
13
|
+
@args.merge(args || {})
|
14
|
+
end
|
15
|
+
|
16
|
+
def inherited(sublass)
|
17
|
+
sublass.inherit_args(@args)
|
18
|
+
end
|
19
|
+
|
8
20
|
def command_for(session)
|
9
21
|
new(session: session)
|
10
22
|
end
|
23
|
+
|
24
|
+
def arg(name, options = {})
|
25
|
+
attr_accessor name unless instance_methods.include?(name)
|
26
|
+
args[name] = { property: name }.merge(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def option(name, options = {})
|
30
|
+
attr_accessor name unless instance_methods.include?(name)
|
31
|
+
args[name] = { key: "--#{name}", property: name }.merge(options)
|
32
|
+
end
|
11
33
|
end
|
12
34
|
|
13
35
|
def initialize(options = nil)
|
@@ -23,24 +45,31 @@ module Mongoid
|
|
23
45
|
self.class.name.downcase.split(':').last
|
24
46
|
end
|
25
47
|
|
26
|
-
def vargs(
|
27
|
-
|
28
|
-
|
48
|
+
def vargs(options = {})
|
49
|
+
mask_sensitive = options[:mask_sensitive]
|
50
|
+
mask_sensitive = '********' if mask_sensitive && mask_sensitive.is_a?(TrueClass)
|
51
|
+
self.class.args.values.map do |arg|
|
52
|
+
key = arg[:key]
|
53
|
+
value = send(arg[:property])
|
29
54
|
next unless value
|
30
55
|
case value
|
31
56
|
when Boolean, TrueClass then key
|
32
57
|
when Array then value.map { |v| "#{key} #{v}" }.join(' ')
|
33
58
|
else
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
59
|
+
if mask_sensitive && arg[:sensitive]
|
60
|
+
value = mask_sensitive
|
61
|
+
else
|
62
|
+
# TODO: quote other special characters?
|
63
|
+
value = value.to_s
|
64
|
+
value = '"' + value + '"' if value.include? ' '
|
65
|
+
end
|
66
|
+
key ? "#{key} #{value}" : value
|
38
67
|
end
|
39
68
|
end
|
40
69
|
end
|
41
70
|
|
42
|
-
def to_s
|
43
|
-
[cmd, vargs].flatten.compact.join(' ')
|
71
|
+
def to_s(options = {})
|
72
|
+
[cmd, vargs(options)].flatten.compact.join(' ')
|
44
73
|
end
|
45
74
|
|
46
75
|
private
|
@@ -7,28 +7,19 @@ module Mongoid
|
|
7
7
|
include Mongoid::Shell::Properties::Username
|
8
8
|
include Mongoid::Shell::Properties::Password
|
9
9
|
|
10
|
-
|
10
|
+
arg :host_port_and_db
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
option :username
|
13
|
+
option :password, sensitive: true
|
14
|
+
option :eval
|
15
|
+
option :nodb
|
16
|
+
option :norc
|
17
|
+
option :quiet
|
18
|
+
option :ipv6
|
15
19
|
|
16
20
|
def host_port_and_db
|
17
21
|
[primary, db].compact.join('/')
|
18
22
|
end
|
19
|
-
|
20
|
-
def vargs
|
21
|
-
super({
|
22
|
-
'db address' => :host_port_and_db,
|
23
|
-
'--username' => :username,
|
24
|
-
'--password' => :password,
|
25
|
-
'--eval' => :eval,
|
26
|
-
'--nodb' => :nodb,
|
27
|
-
'--norc' => :norc,
|
28
|
-
'--quiet' => :quiet,
|
29
|
-
'--ipv6' => :ipv6
|
30
|
-
})
|
31
|
-
end
|
32
23
|
end
|
33
24
|
end
|
34
25
|
end
|
@@ -7,33 +7,22 @@ module Mongoid
|
|
7
7
|
include Mongoid::Shell::Properties::Username
|
8
8
|
include Mongoid::Shell::Properties::Password
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
'--query' => :query,
|
27
|
-
'--out' => :out,
|
28
|
-
'--directoryperdb' => :directoryperdb,
|
29
|
-
'--journal' => :journal,
|
30
|
-
'--oplog' => :oplog,
|
31
|
-
'--repair' => :repair,
|
32
|
-
'--forceTableScan' => :forceTableScan,
|
33
|
-
'--dbpath' => :dbpath,
|
34
|
-
'--ipv6' => :ipv6
|
35
|
-
})
|
36
|
-
end
|
10
|
+
option :host
|
11
|
+
option :db
|
12
|
+
option :username
|
13
|
+
option :password, sensitive: true
|
14
|
+
option :collection
|
15
|
+
option :excludeCollection
|
16
|
+
option :excludeCollectionsWithPrefix
|
17
|
+
option :query
|
18
|
+
option :out
|
19
|
+
option :directoryperdb
|
20
|
+
option :journal
|
21
|
+
option :oplog
|
22
|
+
option :repair
|
23
|
+
option :forceTableScan
|
24
|
+
option :dbpath
|
25
|
+
option :ipv6
|
37
26
|
end
|
38
27
|
end
|
39
28
|
end
|
@@ -7,62 +7,50 @@ module Mongoid
|
|
7
7
|
include Mongoid::Shell::Properties::Username
|
8
8
|
include Mongoid::Shell::Properties::Password
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
# args
|
11
|
+
option :db
|
12
|
+
option :host
|
13
|
+
option :port
|
14
|
+
option :sslCAFile
|
15
|
+
option :sslPEMKeyFile
|
16
|
+
option :sslPEMKeyPassword, sensitive: true
|
17
|
+
option :sslCRLFile
|
18
|
+
option :username
|
19
|
+
option :password, sensitive: true
|
20
|
+
option :authenticationDatabase
|
21
|
+
option :authenticationMechanism
|
22
|
+
option :collection
|
23
|
+
option :fields
|
24
|
+
option :fieldFile
|
25
|
+
option :query
|
26
|
+
option :type
|
27
|
+
option :out
|
28
|
+
option :skip
|
29
|
+
option :limit
|
30
|
+
option :sort
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
|
32
|
+
# boolean options
|
33
|
+
option :verbose
|
34
|
+
option :quiet
|
35
|
+
option :ipv6
|
36
|
+
option :ssl
|
37
|
+
option :sslAllowInvalidCertificates
|
38
|
+
option :sslAllowInvalidHostnames
|
39
|
+
option :sslFIPSMode
|
40
|
+
option :gssapiServiceName
|
41
|
+
option :gssapiHostName
|
42
|
+
option :jsonArray
|
43
|
+
option :pretty
|
44
|
+
option :slaveOk
|
45
|
+
option :forceTableScan
|
21
46
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
47
|
+
# is deprecated from Mongo version 3.0.0, use type instead
|
48
|
+
option :csv
|
25
49
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
'--db' => :db, '--host' => :host, '--port' => :port,
|
31
|
-
'--sslCAFile' => :sslCAFile,
|
32
|
-
'--sslPEMKeyFile' => :sslPEMKeyFile,
|
33
|
-
'--sslPEMKeyPassword' => :sslPEMKeyPassword,
|
34
|
-
'--sslCRLFile' => :sslCRLFile,
|
35
|
-
'--username' => :username,
|
36
|
-
'--password' => :password,
|
37
|
-
'--authenticationDatabase' => :authenticationDatabase,
|
38
|
-
'--authenticationMechanism' => :authenticationMechanism,
|
39
|
-
'--collection' => :collection,
|
40
|
-
'--fields' => :fields, '--fieldFile' => :fieldFile,
|
41
|
-
'--query' => :query,
|
42
|
-
'--type' => :type, '--out' => :out,
|
43
|
-
'--skip' => :skip, '--limit' => :limit, '--sort' => :sort
|
44
|
-
}
|
45
|
-
end
|
46
|
-
|
47
|
-
def boolean_options
|
48
|
-
{
|
49
|
-
'--verbose' => :verbose, '--quiet' => :quiet,
|
50
|
-
'--ipv6' => :ipv6, '--ssl' => :ssl,
|
51
|
-
'--sslAllowInvalidCertificates' => :sslAllowInvalidCertificates,
|
52
|
-
'--sslAllowInvalidHostnames' => :sslAllowInvalidHostnames,
|
53
|
-
'--sslFIPSMode' => :sslFIPSMode,
|
54
|
-
'--gssapiServiceName' => :gssapiServiceName,
|
55
|
-
'--gssapiHostName' => :gssapiHostName,
|
56
|
-
'--jsonArray' => :jsonArray,
|
57
|
-
'--pretty' => :pretty,
|
58
|
-
'--slaveOk' => :slaveOk,
|
59
|
-
'--forceTableScan' => :forceTableScan,
|
60
|
-
'--csv' => :csv, # is deprecated from Mongo version 3.0.0, use type instead
|
61
|
-
# these 3 below are deprecated from Mongo version 3.0.0
|
62
|
-
'--directoryperdb' => :directoryperdb,
|
63
|
-
'--journal' => :journal, '--dbpath' => :dbpath
|
64
|
-
}
|
65
|
-
end
|
50
|
+
# these 3 below are deprecated from Mongo version 3.0.0
|
51
|
+
option :directoryperdb
|
52
|
+
option :journal
|
53
|
+
option :dbpath
|
66
54
|
end
|
67
55
|
end
|
68
56
|
end
|
@@ -7,67 +7,47 @@ module Mongoid
|
|
7
7
|
include Mongoid::Shell::Properties::Username
|
8
8
|
include Mongoid::Shell::Properties::Password
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# these 3 below are deprecated from Mongo version 3.0.0
|
52
|
-
'--directoryperdb' => :directoryperdb,
|
53
|
-
'--journal' => :journal, '--dbpath' => :dbpath
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
def boolean_options
|
58
|
-
{
|
59
|
-
'--verbose' => :verbose, '--quiet' => :quiet,
|
60
|
-
'--ipv6' => :ipv6, '--ssl' => :ssl,
|
61
|
-
'--sslAllowInvalidCertificates' => :sslAllowInvalidCertificates,
|
62
|
-
'--sslAllowInvalidHostnames' => :sslAllowInvalidHostnames,
|
63
|
-
'--sslFIPSMode' => :sslFIPSMode,
|
64
|
-
'--gssapiServiceName' => :gssapiServiceName,
|
65
|
-
'--gssapiHostName' => :gssapiHostName,
|
66
|
-
'--ignoreBlanks' => :ignoreBlanks, '--drop' => :drop,
|
67
|
-
'--headerline' => :headerline, '--upsert' => :upsert,
|
68
|
-
'--stopOnError' => :stopOnError, '--jsonArray' => :jsonArray
|
69
|
-
}
|
70
|
-
end
|
10
|
+
option :db
|
11
|
+
option :host
|
12
|
+
option :port
|
13
|
+
option :sslCAFile
|
14
|
+
option :sslPEMKeyFile
|
15
|
+
option :sslPEMKeyPassword, sensitive: true
|
16
|
+
option :sslCRLFile
|
17
|
+
option :username
|
18
|
+
option :password, sensitive: true
|
19
|
+
option :authenticationDatabase
|
20
|
+
option :authenticationMechanism
|
21
|
+
option :collection
|
22
|
+
option :fields
|
23
|
+
option :fieldFile
|
24
|
+
option :type
|
25
|
+
option :file
|
26
|
+
option :upsertFields
|
27
|
+
option :maintainInsertionOrder
|
28
|
+
option :numInsertionWorkers
|
29
|
+
option :writeConcern
|
30
|
+
|
31
|
+
# these 3 below are deprecated from Mongo version 3.0.0
|
32
|
+
option :directoryperdb
|
33
|
+
option :journal
|
34
|
+
option :dbpath
|
35
|
+
|
36
|
+
option :verbose
|
37
|
+
option :quiet
|
38
|
+
option :ipv6
|
39
|
+
option :ssl
|
40
|
+
option :sslAllowInvalidCertificates
|
41
|
+
option :sslAllowInvalidHostnames
|
42
|
+
option :sslFIPSMode
|
43
|
+
option :gssapiServiceName
|
44
|
+
option :gssapiHostName
|
45
|
+
option :ignoreBlanks
|
46
|
+
option :drop
|
47
|
+
option :headerline
|
48
|
+
option :upsert
|
49
|
+
option :stopOnError
|
50
|
+
option :jsonArray
|
71
51
|
end
|
72
52
|
end
|
73
53
|
end
|
@@ -7,36 +7,27 @@ module Mongoid
|
|
7
7
|
include Mongoid::Shell::Properties::Username
|
8
8
|
include Mongoid::Shell::Properties::Password
|
9
9
|
|
10
|
-
|
10
|
+
option :host
|
11
|
+
option :db
|
12
|
+
option :username
|
13
|
+
option :password, sensitive: true
|
14
|
+
option :collection
|
15
|
+
option :ipv6
|
16
|
+
option :dbpath
|
17
|
+
option :directoryperdb
|
18
|
+
option :journal
|
19
|
+
option :objcheck
|
20
|
+
option :filter
|
21
|
+
option :drop
|
22
|
+
option :oplogReplay
|
23
|
+
option :keepIndexVersion
|
24
|
+
option :noIndexRestore
|
11
25
|
|
12
|
-
|
13
|
-
super
|
14
|
-
end
|
26
|
+
arg :restore
|
15
27
|
|
16
28
|
def host
|
17
29
|
@host || primary
|
18
30
|
end
|
19
|
-
|
20
|
-
def vargs
|
21
|
-
super({
|
22
|
-
'--host' => :host,
|
23
|
-
'--db' => :db,
|
24
|
-
'--username' => :username,
|
25
|
-
'--password' => :password,
|
26
|
-
'--collection' => :collection,
|
27
|
-
'--ipv6' => :ipv6,
|
28
|
-
'--dbpath' => :dbpath,
|
29
|
-
'--directoryperdb' => :directoryperdb,
|
30
|
-
'--journal' => :journal,
|
31
|
-
'--objcheck' => :objcheck,
|
32
|
-
'--filter' => :filter,
|
33
|
-
'--drop' => :drop,
|
34
|
-
'--oplogReplay' => :oplogReplay,
|
35
|
-
'--keepIndexVersion' => :keepIndexVersion,
|
36
|
-
'--noIndexRestore' => :noIndexRestore,
|
37
|
-
'directory or filename to restore from' => :restore
|
38
|
-
})
|
39
|
-
end
|
40
31
|
end
|
41
32
|
end
|
42
33
|
end
|
@@ -7,24 +7,14 @@ module Mongoid
|
|
7
7
|
include Mongoid::Shell::Properties::Username
|
8
8
|
include Mongoid::Shell::Properties::Password
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
'--host' => :host,
|
19
|
-
'--username' => :username,
|
20
|
-
'--password' => :password,
|
21
|
-
'--rowcount' => :rowcount,
|
22
|
-
'--discover' => :discover,
|
23
|
-
'--noheaders' => :noheaders,
|
24
|
-
'--http' => :http,
|
25
|
-
'--all' => :all
|
26
|
-
})
|
27
|
-
end
|
10
|
+
option :host
|
11
|
+
option :username
|
12
|
+
option :password, sensitive: true
|
13
|
+
option :rowcount
|
14
|
+
option :discover
|
15
|
+
option :noheaders
|
16
|
+
option :http
|
17
|
+
option :all
|
28
18
|
end
|
29
19
|
end
|
30
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|