awskeyring 0.6.0 → 0.7.0

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
2
  SHA1:
3
- metadata.gz: d212e152f33eeef7c344651706e798f7e8d6c66d
4
- data.tar.gz: e5843ba96c3ae96f82ea3dc8096b577d581d7b47
3
+ metadata.gz: acf4100ecde4dce232c8ab205879ba29569ca81a
4
+ data.tar.gz: 5ea4a9a1dc79b5aa67280a3c412caa455f044674
5
5
  SHA512:
6
- metadata.gz: 3d9652bbd275b6af595b4ccea507a9c779976347acf2fb97b14c5c4131fd0c578e9e3d75ef17f1b7cb8133d58bc57beb100e9a3aaf5fee78b6768360d2d14167
7
- data.tar.gz: 041af8b40538d8a3c8d6a7028fc6849c4bc2bcd81e30c8aa0d10574c44e031e122b9ffbb8847d6006874b2d15446c8465a439d821e32e5ba4319b9dca06a06f0
6
+ metadata.gz: 2f84e0aeb24f28dcab583cb04b26700db189484e81e898df95e6dff02c33f4ff4e70397ae485594b2a8c07c5f5a5cd32d62b051f228316b77f3398f6b1227207
7
+ data.tar.gz: 902baf9cf05652cb081b126589d4e1763e1e65a5868d1c86ec59e375e38f6c5c3c9fbf5b52964717b8f0f931a58e01cfda484f4e3581aad5c614ea52368c9874
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.7.0](https://github.com/vibrato/awskeyring/tree/v0.7.0) (2018-11-26)
4
+ [Full Changelog](https://github.com/vibrato/awskeyring/compare/v0.6.0...v0.7.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Validate existing account. [\#35](https://github.com/vibrato/awskeyring/pull/35) ([tristanmorgan](https://github.com/tristanmorgan))
9
+ - Swap Highline for Thor::LineEditor [\#34](https://github.com/vibrato/awskeyring/pull/34) ([tristanmorgan](https://github.com/tristanmorgan))
10
+
3
11
  ## [v0.6.0](https://github.com/vibrato/awskeyring/tree/v0.6.0) (2018-10-18)
4
12
  [Full Changelog](https://github.com/vibrato/awskeyring/compare/v0.5.3...v0.6.0)
5
13
 
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in awskeyring.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'bundler'
8
+ gem 'github_changelog_generator'
9
+ gem 'rake'
10
+ gem 'rspec'
11
+ gem 'rubocop'
12
+ gem 'yard'
13
+ end
data/awskeyring.gemspec CHANGED
@@ -13,21 +13,13 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/vibrato/awskeyring'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/|^\..*}) }
17
17
  spec.bindir = 'exe'
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency('aws-sdk-iam')
22
- spec.add_dependency('highline')
23
22
  spec.add_dependency('i18n')
24
23
  spec.add_dependency('ruby-keychain')
25
24
  spec.add_dependency('thor')
26
-
27
- spec.add_development_dependency 'bundler'
28
- spec.add_development_dependency 'github_changelog_generator'
29
- spec.add_development_dependency 'rake'
30
- spec.add_development_dependency 'rspec'
31
- spec.add_development_dependency 'rubocop'
32
- spec.add_development_dependency 'yard'
33
25
  end
@@ -1,4 +1,4 @@
1
1
  module Awskeyring
2
2
  # The Gems version number
3
- VERSION = '0.6.0'.freeze
3
+ VERSION = '0.7.0'.freeze
4
4
  end
data/lib/awskeyring.rb CHANGED
@@ -115,13 +115,12 @@ module Awskeyring # rubocop:disable Metrics/ModuleLength
115
115
  #
116
116
  # @param [String] role The role name to add
117
117
  # @param [String] arn The arn of the role
118
- # @param [String] account The account associate (optional)
119
- def self.add_role(role:, arn:, account:)
118
+ def self.add_role(role:, arn:)
120
119
  all_items.create(
121
120
  label: ROLE_PREFIX + role,
122
121
  account: arn,
123
122
  password: '',
124
- comment: account
123
+ comment: ''
125
124
  )
126
125
  end
127
126
 
@@ -280,4 +279,13 @@ module Awskeyring # rubocop:disable Metrics/ModuleLength
280
279
  puts message if message
281
280
  role.delete
282
281
  end
282
+
283
+ # Validate account exists
284
+ #
285
+ # @param [String] account_name the associated account name.
286
+ def self.account_exists(account_name)
287
+ raise 'Account does not exist' unless list_account_names.include?(account_name)
288
+
289
+ account_name
290
+ end
283
291
  end
@@ -1,4 +1,3 @@
1
- require 'highline'
2
1
  require 'i18n'
3
2
  require 'thor'
4
3
 
@@ -68,7 +67,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
68
67
  # Print Env vars
69
68
  def env(account = nil)
70
69
  account = ask_check(
71
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
70
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
72
71
  )
73
72
  cred = age_check_and_get(account: account, no_token: options['no-token'])
74
73
  put_env_string(
@@ -84,7 +83,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
84
83
  # Print JSON for use with credential_process
85
84
  def json(account = nil)
86
85
  account = ask_check(
87
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
86
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
88
87
  )
89
88
  cred = age_check_and_get(account: account, no_token: options['no-token'])
90
89
  expiry = Time.at(cred[:expiry]) unless cred[:expiry].nil?
@@ -149,7 +148,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
149
148
  # Update an Account
150
149
  def update(account = nil) # rubocop:disable Metrics/MethodLength
151
150
  account = ask_check(
152
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
151
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
153
152
  )
154
153
  key = ask_check(
155
154
  existing: options[:key], message: I18n.t('message.key'), validator: Awskeyring::Validate.method(:access_key)
@@ -171,7 +170,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
171
170
  desc 'add-role ROLE', I18n.t('add_role.desc')
172
171
  method_option :arn, type: :string, aliases: '-a', desc: I18n.t('method_option.arn')
173
172
  # Add a role
174
- def add_role(role = nil) # rubocop:disable Metrics/MethodLength
173
+ def add_role(role = nil)
175
174
  role = ask_check(
176
175
  existing: role, message: I18n.t('message.role'),
177
176
  validator: Awskeyring::Validate.method(:role_name)
@@ -180,15 +179,10 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
180
179
  existing: options[:arn], message: I18n.t('message.arn'),
181
180
  validator: Awskeyring::Validate.method(:role_arn)
182
181
  )
183
- account = ask_check(
184
- existing: account, message: I18n.t('message.account'),
185
- optional: true, validator: Awskeyring::Validate.method(:account_name)
186
- )
187
182
 
188
183
  Awskeyring.add_role(
189
184
  role: role,
190
- arn: arn,
191
- account: account
185
+ arn: arn
192
186
  )
193
187
  puts I18n.t('message.addrole', role: role)
194
188
  end
@@ -197,7 +191,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
197
191
  # Remove an account
198
192
  def remove(account = nil)
199
193
  account = ask_check(
200
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
194
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
201
195
  )
202
196
  Awskeyring.delete_account(account: account, message: I18n.t('message.delaccount', account: account))
203
197
  end
@@ -206,7 +200,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
206
200
  # remove a session token
207
201
  def remove_token(account = nil)
208
202
  account = ask_check(
209
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
203
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
210
204
  )
211
205
  Awskeyring.delete_token(account: account, message: I18n.t('message.deltoken', account: account))
212
206
  end
@@ -225,7 +219,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
225
219
  # rotate Account keys
226
220
  def rotate(account = nil) # rubocop:disable Metrics/MethodLength
227
221
  account = ask_check(
228
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
222
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
229
223
  )
230
224
  cred = Awskeyring.get_valid_creds(account: account, no_token: true)
231
225
 
@@ -257,7 +251,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
257
251
  # generate a sessiopn token
258
252
  def token(account = nil, role = nil, code = nil) # rubocop:disable all
259
253
  account = ask_check(
260
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
254
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
261
255
  )
262
256
  role ||= options[:role]
263
257
  if role
@@ -314,7 +308,7 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
314
308
  # Open the AWS Console
315
309
  def console(account = nil) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
316
310
  account = ask_check(
317
- existing: account, message: I18n.t('message.account'), validator: Awskeyring::Validate.method(:account_name)
311
+ existing: account, message: I18n.t('message.account'), validator: Awskeyring.method(:account_exists)
318
312
  )
319
313
  cred = age_check_and_get(account: account, no_token: options['no-token'])
320
314
 
@@ -467,11 +461,11 @@ class AwskeyringCommand < Thor # rubocop:disable Metrics/ClassLength
467
461
 
468
462
  def ask(message:, secure: false, optional: false)
469
463
  if secure
470
- HighLine.new.ask(message.rjust(20) + ': ') { |q| q.echo = '*' }
464
+ Thor::LineEditor.readline(message.rjust(20) + ': ', echo: false)
471
465
  elsif optional
472
- HighLine.new.ask((message + ' (optional)').rjust(20) + ': ')
466
+ Thor::LineEditor.readline((message + ' (optional)').rjust(20) + ': ')
473
467
  else
474
- HighLine.new.ask(message.rjust(20) + ': ')
468
+ Thor::LineEditor.readline(message.rjust(20) + ': ')
475
469
  end
476
470
  end
477
471
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awskeyring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Morgan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-iam
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: highline
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: i18n
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,90 +66,6 @@ dependencies:
80
66
  - - ">="
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: github_changelog_generator
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: yard
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
69
  description: Manages AWS credentials in the macOS keychain
168
70
  email:
169
71
  - tristan@vibrato.com.au
@@ -172,10 +74,6 @@ executables:
172
74
  extensions: []
173
75
  extra_rdoc_files: []
174
76
  files:
175
- - ".gitignore"
176
- - ".rspec"
177
- - ".rubocop.yml"
178
- - ".travis.yml"
179
77
  - CHANGELOG.md
180
78
  - CODE_OF_CONDUCT.md
181
79
  - Gemfile
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /bin/
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --order rand
2
- --format documentation
3
- --color
data/.rubocop.yml DELETED
@@ -1,22 +0,0 @@
1
- ---
2
- Metrics/LineLength:
3
- Max: 120
4
-
5
- Metrics/MethodLength:
6
- Max: 16
7
-
8
- Metrics/BlockLength:
9
- Exclude:
10
- - spec/**/*
11
-
12
- Metrics/AbcSize:
13
- Max: 20
14
-
15
- Bundler/GemComment:
16
- Enabled: false
17
- Include:
18
- - Gemfile
19
-
20
- AllCops:
21
- Exclude:
22
- - bin/*
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- ---
2
- language: ruby
3
- os: osx
4
- rvm:
5
- - 2.3.3
6
- - 2.3.7
7
- before_install: gem install bundler
8
- notifications:
9
- slack:
10
- secure: "okKLlQ93ogj8ut18MZazQD63XTIzCpTfneYQMlKPaLU5HnooAkUFmEpSN8ig\
11
- TJD0GuEQ7Jf8+BkFlhECWl1FwtzIW6z/yMadiiLwY6qA/O1ZVVYZmkS4kpcKtCMrvO0Hf3iPL\
12
- XpJX0sQGfGsMsho6NZuNs0dzlrr4+HX/cEGmDXBocDDxdv2d25HzHtqt4l+4axeJ+PJdHDmYl\
13
- DzhtMAXhkGoPfzws7MPvkVcqY0eZRW2WqccO52zlQrBNcphp7BI8mLTW/BwkEY9YndJf2xoBa\
14
- oEOuaIJbGgHbmskGMRui3vZnd08/fiWkNsCI/EhB5BDJ41bwobsHEtuqu+Qx92kI+hzjtU4D1\
15
- 6k1v/6HDm61T6gh6BTp0QEXJeOkiecjVGyzrMlBf5BEyIB7JfLvGPa7RUbvvvUxFGcEtnSbUZ\
16
- 49cXAG7cKiiSgcNOocCrMNIRAe864Tm606Mud1RbOv8tEiS9BJ96ktOpOfvrYPyYMRFTte2gR\
17
- LwNDwcpXIWTI39CXD2EBxSfRK/OqmggLYMG5AKhxyS/Vl7E2p9gii6syB0LnpFBIZ6t+OSve7\
18
- fZtCU/wruC5IrI/vHtWfApvADYKsXG6FEYJoJ1LsCDjIRlrkwV1dEVsp/HSSO6zRh9KhJ3b7y\
19
- zL97Dyi6dCi+nM7aKGrox/8kvcn9alrdRt8sz3c="