itamae-secrets 0.1.0 → 0.2.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: df379b9fa313eb7a3516694a0efc764d086d23cf
4
- data.tar.gz: 08e47d784901105a67f80ac1b1340e61e8e6524a
3
+ metadata.gz: 3189e0466cac90d11c20296d8087afaff2d411fc
4
+ data.tar.gz: 7afb09f3eccf8b2d19338666906b4584b0d3f08c
5
5
  SHA512:
6
- metadata.gz: bffd0e6a9b7def10679ef9783cbc908cc909e1cfa778463a31f3a25eec6afc630c270fc92445c2caa6dde0802df4529231211b46e07d708dcc2393d6fa86a446
7
- data.tar.gz: 740a9e5f8bd2d130769b94a7399aad5769d9631a2b1cdb79a8a6e29dacbc9025027e48ce9c74f6613257d225436f522d8fefaef3034fbe851a6e4caec54cc7d9
6
+ metadata.gz: fef9daa15514dd1ecbb90df93e1e14231d3f06cd9ee1bae9d1e709ad28e8c91c12ee4c2173bf88f080bd6fa49443fa0cfc4612358f489b63f6ede6806f4782c1
7
+ data.tar.gz: 0b1e08af8e274d6439fdb17e762ed007daa848ce00f379374419fe00b723c2ae106352695d2e2d61a198528d3b12e8d3d879317749f3dda4f2357819c13c738d
data/README.md CHANGED
@@ -17,8 +17,9 @@ $ gem install itamae-secrets
17
17
  ## Basic
18
18
 
19
19
  - `itamae-secrets` command for storing data or manually reading
20
- - specify base directory to `--base` option
21
- - you should exclude `${base}/keys` from checking into VCS. (`.gitignore` it!)
20
+ - `Itamae::Secrets` interface for itamae recipes
21
+ - Data are stored in _base directory._
22
+ - You must avoid `${base}/keys` from checked into VCS. (`.gitignore` it!)
22
23
 
23
24
  ## Walkthrough
24
25
 
@@ -58,7 +59,7 @@ node[:secrets] = Itamae::Secrets(File.join(__dir__, 'secrets'))
58
59
  p node[:secrets][:awesome_secret]
59
60
  ```
60
61
 
61
- ### Reading data fro CLI
62
+ ### Reading data from CLI
62
63
 
63
64
  ```
64
65
  $ itamae-secrets get --base=./secret awesome_secret
@@ -27,7 +27,7 @@ module Itamae
27
27
  passphrase = ask_noecho('Passphrase:', true)
28
28
  AesKey.generate_pkcs5(name, passphrase)
29
29
  else
30
- raise ArgumentError, "Unknown method: #{name.inspect}"
30
+ raise ArgumentError, "Unknown method: #{options[:method] || config['generate_method']}"
31
31
  end
32
32
 
33
33
  keychain.save(key)
@@ -18,7 +18,7 @@ module Itamae
18
18
 
19
19
  def load(name)
20
20
  AesKey.load_json @path.join(name).read
21
- rescue File::ENOENT
21
+ rescue Errno::ENOENT
22
22
  raise KeyNotFound, "Couldn't find key #{name.inspect}"
23
23
  end
24
24
 
@@ -27,7 +27,15 @@ module Itamae
27
27
  end
28
28
 
29
29
  def [](name)
30
- name = name.to_s
30
+ fetch(name, nil)
31
+ end
32
+
33
+ def fetch(*args)
34
+ if args.size > 2
35
+ raise ArgumentError, "wrong number of arguments (#{args.size} for 1..2)"
36
+ end
37
+
38
+ name = args[0].to_s
31
39
  validate_name!(name)
32
40
 
33
41
  value_path = values_path.join(name)
@@ -37,7 +45,11 @@ module Itamae
37
45
  encrypted_data.key = keychain.load(encrypted_data.key_name)
38
46
  JSON.parse(encrypted_data.plaintext)['value']
39
47
  else
40
- nil
48
+ if args.size == 1
49
+ raise KeyError, "key not found: #{name}"
50
+ else
51
+ args[1]
52
+ end
41
53
  end
42
54
  end
43
55
 
@@ -1,5 +1,5 @@
1
1
  module Itamae
2
2
  module Secrets
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-secrets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.4.5
117
+ rubygems_version: 2.6.8
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Encrypted Data Bag for itamae