vaulty 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7c7dbd18027d85422fd9b764cabc3acb107bbd3f
4
- data.tar.gz: da99bc09d1f9c4334c712680abadbf206792d470
2
+ SHA256:
3
+ metadata.gz: a0715f5f20855b4563adbae4462cd1a4051fca8716de66c565c5b888f4ce7032
4
+ data.tar.gz: 402b71892d2866615d8ff32f466df0c21eedf7c60eaf8dd04817321647e4b0de
5
5
  SHA512:
6
- metadata.gz: 3c724876d426647cb1786e74fcf8bbeb6de6f0bb80181a2f3a6d4b395e5fb8652a9ee013ad2b9195af74ca9c873827713ee1a5de36965be2df6dc5e3915c629d
7
- data.tar.gz: b44b647ca87762201faa9a48c6676939d287851c92d30c26cbc82d984c53d5c3bf3095f0219228ea1de6c15bcac80827d9b7de390f6016a2eaa45702b9785789
6
+ metadata.gz: 220f29d553cc026c0eced71319f164a6a10a07f8bc5ec66f765a66539331b7da4e43ca78732eebaa4b0e155fca5d942010925a7eca76db13dfa7a7e28745e425
7
+ data.tar.gz: ed54109416df5ad16fea177c9c7e45e21c122e7a0a51239163e3113af83abcab5cb72fcebecd9f8d44bdd3b67011778a271b586286c0968203efd7cb0eb8174e
data/.rubocop.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+ require:
3
+ - rubocop-rspec
2
4
 
3
5
  AllCops:
4
- TargetRubyVersion: 2.3
6
+ TargetRubyVersion: 2.5
5
7
  Exclude:
6
8
  - 'bin/*'
7
- - 'spec/**/*'
8
9
 
9
10
  # Don't care about frozen strings
10
11
  Style/FrozenStringLiteralComment:
@@ -15,16 +16,16 @@ Style/Documentation:
15
16
  Enabled: false
16
17
 
17
18
  Metrics/LineLength:
18
- Max: 90
19
+ Max: 120
19
20
 
20
- Style/AlignHash:
21
+ Layout/AlignHash:
21
22
  EnforcedColonStyle: key
22
23
  EnforcedHashRocketStyle: key
23
24
 
24
- Style/AlignParameters:
25
+ Layout/AlignParameters:
25
26
  Enabled: false
26
27
 
27
- Style/IndentHash:
28
+ Layout/IndentHash:
28
29
  EnforcedStyle: consistent
29
30
 
30
31
  # Only exclude the CLI app since we cannot split this up in the current form
@@ -32,6 +33,10 @@ Metrics/ClassLength:
32
33
  Exclude:
33
34
  - 'lib/vaulty/cli_app.rb'
34
35
 
36
+ Metrics/BlockLength:
37
+ Exclude:
38
+ - 'spec/**/*.rb'
39
+
35
40
  Style/PercentLiteralDelimiters:
36
41
  PreferredDelimiters:
37
42
  default: ()
@@ -40,3 +45,54 @@ Style/PercentLiteralDelimiters:
40
45
  '%r': '{}'
41
46
  '%w': '()'
42
47
  '%W': '()'
48
+
49
+ # -----------------------------------------------------------------------------
50
+ # RSpec
51
+ # -----------------------------------------------------------------------------
52
+ # Conceptually right but practical with ActiveRecord models nearly impossible
53
+ RSpec/AnyInstance:
54
+ Enabled: false
55
+
56
+ # For API and feature specs this makes no sense
57
+ RSpec/DescribeClass:
58
+ Enabled: false
59
+
60
+ # For testing json response bodies we easily hit this limit
61
+ RSpec/ExampleLength:
62
+ Enabled: false
63
+
64
+ # Don't really have a preference and first seems odd
65
+ RSpec/LeadingSubject:
66
+ Enabled: false
67
+
68
+ # let! is very handy so allowed
69
+ RSpec/LetSetup:
70
+ Enabled: false
71
+
72
+ # Not really a preference and sometimes there is no way around it
73
+ RSpec/MessageSpies:
74
+ Enabled: false
75
+
76
+ # Sometimes its clear enough
77
+ RSpec/NamedSubject:
78
+ Enabled: false
79
+
80
+ # If we got more then 5 then probably we are testing to much in one block
81
+ RSpec/MultipleExpectations:
82
+ Max: 20
83
+
84
+ # Probably will disable this one, for some api specs this is needed
85
+ RSpec/NestedGroups:
86
+ Max: 6
87
+
88
+ # If your it is multiline then you cannot use short hand syntax, wonky
89
+ RSpec/ImplicitSubject:
90
+ Enabled: false
91
+
92
+ # For now disable, not sure if this matches up with Gems
93
+ RSpec/FilePath:
94
+ Enabled: false
95
+
96
+ # Shared contexts don't need to start with when, with or without
97
+ RSpec/ContextWording:
98
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -8,4 +8,4 @@
8
8
 
9
9
  # Offense count: 2
10
10
  Metrics/AbcSize:
11
- Max: 25
11
+ Max: 30
data/.travis.yml CHANGED
@@ -9,27 +9,24 @@ before_install:
9
9
  - mkdir -p ~/bin
10
10
  - mv vault ~/bin
11
11
  - export PATH="~/bin:$PATH"
12
- - gem update --remote bundler
12
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
+ - chmod +x ./cc-test-reporter
14
+ - ./cc-test-reporter before-build
13
15
 
14
16
  install:
15
17
  - bundle install --retry=3
16
18
 
17
19
  env:
18
- - VAULT_VERSION=0.7.0
19
- - VAULT_VERSION=0.8.3
20
+ - VAULT_VERSION=1.0.2
21
+ - VAULT_VERSION=0.11.6
20
22
 
21
23
  rvm:
22
- - 2.3.5
23
- - 2.4.2
24
+ - 2.5.3
25
+ - 2.6.0
24
26
 
25
27
  script:
26
28
  - 'bundle exec rake spec'
27
29
  - 'bundle exec rubocop'
28
30
 
29
- addons:
30
- code_climate:
31
- repo_token:
32
- secure: "nof51qBnGYKwvJGsFrECGdnsttHoihTFKBOPlJV7M9qIO5WKGdg/hHFTA1oIaq8njlrGs166IA9gD8IUFpVaesSVMr9W9l7LdgbcMNf+hmTLA8MmrIjTJMsyBSSXK5H7nmd36VS+XzFjhviYeVgSVppZdv+Rxyo3neieq6R6u/Ik3VLTp7RjA38Yh45iiRd549OO+A0ufZ9oOySuA03WPAiPWhyjjScK2L8+HYH5G6pEhhm6+GfN6DZU6QWbNPBCGEDk5RnLb1SfoxYDNlXZlEMre+gzO+78bquZVQOqEGF7VJUD/kDW8ZO4abEvWeDL6tlEsU5EnDAu5EIwDSZFVQUSbsqoyyX8r64EHzomaF4QAIuRZ7/5N8hJ6h+qAlxOJ3NML1+tALQriY5e5vh7ler1IjC3tozfGouMIoKFTe6FVBZir799Dm5jjVfvTDoYoLj1QcsplFtZw0s6lUQc3fNMFNPmS9t/xIDqPGNJvd5jCKYkdXs1bld9XdvjklyZglNp+cU8RMzEr6R9XvQGvjZSZqyO8IOOXMwwJpTNJ6Swt+kmAmogG5s30STE296+4Sp8/u9xfRoYbwKLbj7LwMl7IVnfQLqCfdJxVfRlCw3mxPn1mECXys2C+GFjqh0u/wPci1qAqyBBKnG1kSScfBdvuQqIoAs6nfDZFShLxlg="
33
-
34
- after_success:
35
- - bundle exec codeclimate-test-reporter
31
+ after_script:
32
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile CHANGED
@@ -3,11 +3,11 @@ gemspec
3
3
 
4
4
  group :test do
5
5
  gem 'activesupport'
6
- gem 'codeclimate-test-reporter', '~> 1.0.0'
7
6
  gem 'coveralls', require: false
8
7
  gem 'rdoc'
9
8
  gem 'rspec'
10
9
  gem 'rubocop'
10
+ gem 'rubocop-rspec'
11
11
  gem 'simplecov'
12
12
  gem 'yard'
13
13
  end
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Test Coverage](https://codeclimate.com/github/playpasshq/vaulty/badges/coverage.svg)](https://codeclimate.com/github/playpasshq/vaulty/coverage)
5
5
  [![Code Climate](https://codeclimate.com/github/playpasshq/vaulty/badges/gpa.svg)](https://codeclimate.com/github/playpasshq/vaulty)
6
6
  [![Issue Count](https://codeclimate.com/github/playpasshq/vaulty/badges/issue_count.svg)](https://codeclimate.com/github/playpasshq/vaulty)
7
- [![Dependency Status](https://gemnasium.com/badges/github.com/playpasshq/vaulty.svg)](https://gemnasium.com/github.com/playpasshq/vaulty)
8
7
  [![Inline docs](http://inch-ci.org/github/playpasshq/vaulty.svg)](http://inch-ci.org/github/playpasshq/vaulty)
9
8
  [![git.legal](https://git.legal/projects/3808/badge.svg?key=f71d4e011a263b65c8f7 "Number of libraries approved")](https://git.legal/projects/3808)
10
9
 
@@ -13,7 +12,27 @@ Only tested on the generic backend!
13
12
 
14
13
  ## Project Status
15
14
 
16
- Very alpha, only 3 commands are supported.
15
+ ```shell
16
+ NAME
17
+ vaulty - Vault CLI on steriods
18
+
19
+ SYNOPSIS
20
+ vaulty [global options] command [command options] [arguments...]
21
+
22
+ VERSION
23
+ 0.0.3
24
+
25
+ GLOBAL OPTIONS
26
+ --help - Show this message
27
+ --version - Display the program version
28
+
29
+ COMMANDS
30
+ add - Add a new key/value to the given path, multiple "key:value" can be provided
31
+ delete - Deletes everything under the path recursively
32
+ help - Shows a list of commands or help for one command
33
+ remove - Removes a specific key under the path
34
+ tree - Represents the path as a tree
35
+ ```
17
36
 
18
37
  :include:vaulty.rdoc
19
38
 
data/lib/vaulty.rb CHANGED
@@ -7,7 +7,9 @@ require 'gli'
7
7
  require 'vault'
8
8
  require 'hirb'
9
9
  require 'hashdiff'
10
- require 'tty'
10
+ require 'pastel'
11
+ require 'tty-table'
12
+ require 'tty-spinner'
11
13
  require 'tty-prompt'
12
14
 
13
15
  require 'vaulty/cli_app'
@@ -17,6 +19,7 @@ require 'vaulty/vault_tree'
17
19
  require 'vaulty/cli/command'
18
20
  require 'vaulty/cli/add'
19
21
  require 'vaulty/cli/delete'
22
+ require 'vaulty/cli/remove'
20
23
  require 'vaulty/cli/tree'
21
24
 
22
25
  require 'vaulty/output/banner'
@@ -35,6 +38,14 @@ module Vaulty
35
38
  end
36
39
  end
37
40
 
41
+ class MissingKeys < GLI::CustomExit
42
+ # @param [String] path
43
+ # @param [Array<String>, String] keys
44
+ def initialize(path, keys)
45
+ super("Path #{path.inspect} does not contain #{Array(keys).join(', ')}", -1)
46
+ end
47
+ end
48
+
38
49
  # Returns the prompt instance so it's always the same instance
39
50
  # @return [TTY::Prompt]
40
51
  #
@@ -17,6 +17,7 @@ module Vaulty
17
17
  table(catacomb.read, highlight: { matching: matching_keys, color: :red })
18
18
  # If we have matching keys and we don't want to continue, we exit
19
19
  return if matching_keys.any? && prompt.no?('Existing secret found, overwrite?')
20
+
20
21
  # Print we are writing and merge the content
21
22
  banner("Writing data to #{catacomb.path.inspect}", color: :red)
22
23
  catacomb.merge(data)
@@ -0,0 +1,35 @@
1
+ module Vaulty
2
+ module CLI
3
+ class Remove < Command
4
+ attr_reader :catacomb, :keys
5
+ def initialize(catacomb:, keys:)
6
+ @catacomb = catacomb
7
+ @keys = keys
8
+ end
9
+
10
+ def call
11
+ found_keys = Array(catacomb.matching_keys(keys))
12
+ raise Vaulty::MissingKeys.new(catacomb.path, keys) if found_keys.empty?
13
+
14
+ banner("Found keys #{found_keys.join(', ')} at #{catacomb.path.inspect}")
15
+ table(catacomb.read, highlight: { matching: found_keys, color: :red })
16
+ return if prompt.no?('All above data will be deleted! Are you sure?', color: :red)
17
+
18
+ delete_keys(found_keys)
19
+ prompt.ok("Successfully deleted keys #{found_keys.join(', ')} at #{catacomb.path.inspect}")
20
+ end
21
+
22
+ private
23
+
24
+ def delete_keys(keys)
25
+ current_data = catacomb.read
26
+ new_data = current_data.reject { |k, _v| keys.include?(k.to_s) }
27
+ if new_data.empty?
28
+ catacomb.delete
29
+ else
30
+ catacomb.write(new_data)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -14,6 +14,7 @@ module Vaulty
14
14
  spinner.stop
15
15
 
16
16
  raise Vaulty::EmptyPath, catacomb.path if vaulty_tree.empty?
17
+
17
18
  Vaulty::Output::Tree.render(vaulty_tree, prompt: prompt)
18
19
  vaulty_tree
19
20
  end
@@ -13,7 +13,7 @@ module Vaulty
13
13
  Hash[*value.split(':')]
14
14
  end
15
15
 
16
- desc 'Add a new key/value to the given `PATH`, multiple `key:value` can be provided'
16
+ desc 'Add a new key/value to the given path, multiple "key:value" can be provided'
17
17
  arg(:path)
18
18
  command :add do |c|
19
19
  c.flag %i(secret s), desc: 'Key/Values to save', type: Array, multiple: true,
@@ -39,6 +39,17 @@ module Vaulty
39
39
  end
40
40
  end
41
41
 
42
+ desc 'Removes a specific key under the path'
43
+ arg(:path)
44
+ command :remove do |c|
45
+ c.flag %i(key k), desc: 'key to remove', type: String, required: true, multiple: true
46
+ c.action do |_global_options, options, _args|
47
+ catacomb = options[:catacomb]
48
+ keys = options[:key]
49
+ Vaulty::CLI::Remove.call(catacomb: catacomb, keys: keys)
50
+ end
51
+ end
52
+
42
53
  desc 'Represents the path as a tree'
43
54
  arg(:path)
44
55
  command :tree do |c|
@@ -1,3 +1,3 @@
1
1
  module Vaulty
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
data/vaulty.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.homepage = 'https://fritz.ninja'
13
13
  s.license = 'MIT'
14
14
 
15
- s.required_ruby_version = '~> 2.3'
15
+ s.required_ruby_version = '~> 2.5'
16
16
 
17
17
  s.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
@@ -24,10 +24,13 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency 'hashdiff', '~> 0.3.0'
26
26
  s.add_dependency 'hirb', '~> 0.7.3'
27
- s.add_dependency 'tty', '~> 0.7.0'
28
- s.add_dependency 'vault', '~> 0.10.1'
27
+ s.add_dependency 'pastel', '~> 0.7.2'
28
+ s.add_dependency 'tty-prompt', '~> 0.18.0'
29
+ s.add_dependency 'tty-spinner', '~> 0.9.0'
30
+ s.add_dependency 'tty-table', '~> 0.10.0'
31
+ s.add_dependency 'vault', '~> 0.12.0'
29
32
 
30
33
  s.add_development_dependency 'rake'
31
34
 
32
- s.add_runtime_dependency 'gli', '2.17.0'
35
+ s.add_runtime_dependency 'gli', '2.18.0'
33
36
  end
data/vaulty.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  == vaulty - Vault CLI on steriods
2
2
 
3
- v0.0.1
3
+ v0.0.3
4
4
 
5
5
  === Global Options
6
6
  === --help
@@ -15,7 +15,7 @@ Display the program version
15
15
 
16
16
  === Commands
17
17
  ==== Command: <tt>add </tt>
18
- Add a new key/value to the given `PATH`, multiple `key:value` can be provided
18
+ Add a new key/value to the given path, multiple "key:value" can be provided
19
19
 
20
20
 
21
21
  ===== Options
@@ -47,6 +47,18 @@ List commands one per line, to assist with shell completion
47
47
 
48
48
 
49
49
 
50
+ ==== Command: <tt>remove </tt>
51
+ Removes a specific key under the path
52
+
53
+
54
+ ===== Options
55
+ ===== --key|-k arg
56
+
57
+ key to remove
58
+
59
+ [Default Value] None
60
+
61
+
50
62
  ==== Command: <tt>tree </tt>
51
63
  Represents the path as a tree
52
64
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vaulty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Stevens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-02 00:00:00.000000000 Z
11
+ date: 2019-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashdiff
@@ -39,33 +39,75 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.7.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: tty
42
+ name: pastel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.0
47
+ version: 0.7.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.7.0
54
+ version: 0.7.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-prompt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.18.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.18.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-spinner
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-table
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.0
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: vault
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - "~>"
60
102
  - !ruby/object:Gem::Version
61
- version: 0.10.1
103
+ version: 0.12.0
62
104
  type: :runtime
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
108
  - - "~>"
67
109
  - !ruby/object:Gem::Version
68
- version: 0.10.1
110
+ version: 0.12.0
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: rake
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +128,14 @@ dependencies:
86
128
  requirements:
87
129
  - - '='
88
130
  - !ruby/object:Gem::Version
89
- version: 2.17.0
131
+ version: 2.18.0
90
132
  type: :runtime
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
136
  - - '='
95
137
  - !ruby/object:Gem::Version
96
- version: 2.17.0
138
+ version: 2.18.0
97
139
  description: Vault CLI that is based on the Vault Ruby gem
98
140
  email:
99
141
  - jan@playpass.be
@@ -118,6 +160,7 @@ files:
118
160
  - lib/vaulty/cli/add.rb
119
161
  - lib/vaulty/cli/command.rb
120
162
  - lib/vaulty/cli/delete.rb
163
+ - lib/vaulty/cli/remove.rb
121
164
  - lib/vaulty/cli/tree.rb
122
165
  - lib/vaulty/cli_app.rb
123
166
  - lib/vaulty/output/banner.rb
@@ -140,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
183
  requirements:
141
184
  - - "~>"
142
185
  - !ruby/object:Gem::Version
143
- version: '2.3'
186
+ version: '2.5'
144
187
  required_rubygems_version: !ruby/object:Gem::Requirement
145
188
  requirements:
146
189
  - - ">="
@@ -148,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
191
  version: '0'
149
192
  requirements: []
150
193
  rubyforge_project:
151
- rubygems_version: 2.5.2.1
194
+ rubygems_version: 2.7.6
152
195
  signing_key:
153
196
  specification_version: 4
154
197
  summary: A description of your project