hiera-eyaml-gpg 0.5 → 0.6.rc1

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: d242d1b87c6d3e32f596825c3e12ea6a2eca674b
4
- data.tar.gz: d60b66d7831ff97bca0400b500a7f5e39f5203a5
3
+ metadata.gz: 4311fd310b650c1251a0a49efd95999c714e9853
4
+ data.tar.gz: 480ed21891bc8818ca8709e20febafe467e5e368
5
5
  SHA512:
6
- metadata.gz: 897ac15882a34951e0e41b247ffaea743a1770c6dcd27797b17eed5fca6faef2140023b43b571008a34142e85b1b2c75e5812ee73adf26e0b575873483a5af77
7
- data.tar.gz: 59952cce538d8c64f6154140746bb14a00ace299f9d428ebf7436ed282d14ee78278709f8efd2eaf38637be8c5b87f263e9cb3a704aa1c52b875c9e192908092
6
+ metadata.gz: c9d84dd9a9a90ebb0b7f867c81936296a96afe6d4dec6233e972dd69ea08f07effa6d97d61040041b1e6e29015cac0f0db587d153b73ca80e0be2bb8d94f4d06
7
+ data.tar.gz: 3e870d0cf9b14611734423096d638b8dc85942713572543f12de5a6083bdb677534e5e189b7bb1939bbc097ccdd14f7e61f8968d36521c5622b63094084b9094
@@ -3,7 +3,7 @@ class Hiera
3
3
  module Eyaml
4
4
  module Encryptors
5
5
  module Gpg
6
- VERSION = "0.5"
6
+ VERSION = "0.6.rc1"
7
7
  end
8
8
  end
9
9
  end
@@ -26,7 +26,7 @@ class Hiera
26
26
  self.options = {
27
27
  :gnupghome => { :desc => "Location of your GNUPGHOME directory",
28
28
  :type => :string,
29
- :default => "#{ENV[["HOME", "HOMEPATH"].detect { |h| ENV[h] != nil }]}/.gnupg" },
29
+ :default => "#{["HOME", "HOMEPATH"].reject { |h| ENV[h].nil? }.map { |h| ENV[h]+"/.gnupg" }.first || ""}",
30
30
  :always_trust => { :desc => "Assume that used keys are fully trusted",
31
31
  :type => :boolean,
32
32
  :default => false },
@@ -57,6 +57,20 @@ class Hiera
57
57
  end
58
58
  end
59
59
 
60
+ def self.gnupghome
61
+ gnupghome = self.option :gnupghome
62
+ debug("GNUPGHOME is #{gnupghome}")
63
+ if gnupghome.nil? || gnupghome.empty?
64
+ warn("No GPG home directory configured, check gpg_gnupghome configuration value is correct")
65
+ raise ArgumentError, "No GPG home directory configured, check gpg_gnupghome configuration value is correct"
66
+ elsif !File.directory?(gnupghome)
67
+ warn("Configured GPG home directory #{gnupghome} doesn't exist, check gpg_gnupghome configuration value is correct")
68
+ raise ArgumentError, "Configured GPG home directory #{gnupghome} doesn't exist, check gpg_gnupghome configuration value is correct"
69
+ else
70
+ gnupghome
71
+ end
72
+ end
73
+
60
74
  def self.find_recipients
61
75
  recipient_option = self.option :recipients
62
76
  recipients = if !recipient_option.nil?
@@ -86,7 +100,7 @@ class Hiera
86
100
  selected_file = nil
87
101
  path.descend{|path| path
88
102
  potential_file = path.join('hiera-eyaml-gpg.recipients')
89
- selected_file = potential_file if potential_file.exist?
103
+ selected_file = potential_file if potential_file.exist?
90
104
  }
91
105
  debug("Using file at #{selected_file}")
92
106
  selected_file
@@ -94,7 +108,9 @@ class Hiera
94
108
  end
95
109
 
96
110
  unless recipient_file.nil?
97
- recipient_file.readlines.map{ |line| line.strip }
111
+ recipient_file.readlines.map{ |line|
112
+ line.strip unless line.start_with? '#'
113
+ }.compact
98
114
  else
99
115
  []
100
116
  end
@@ -106,9 +122,7 @@ class Hiera
106
122
  raise RecoverableError, "Encryption is only supported when using the 'gpgme' gem"
107
123
  end
108
124
 
109
- gnupghome = self.option :gnupghome
110
- GPGME::Engine.home_dir = gnupghome
111
- debug("GNUPGHOME is #{gnupghome}")
125
+ GPGME::Engine.home_dir = self.gnupghome
112
126
 
113
127
  ctx = GPGME::Ctx.new
114
128
 
@@ -117,9 +131,9 @@ class Hiera
117
131
 
118
132
  raise RecoverableError, 'No recipients provided, don\'t know who to encrypt to' if recipients.empty?
119
133
 
120
- keys = recipients.map {|r|
121
- key_to_use = ctx.keys(r).first
122
- if key_to_use.nil?
134
+ keys = recipients.map {|r|
135
+ key_to_use = ctx.keys(r).first
136
+ if key_to_use.nil?
123
137
  raise RecoverableError, "No key found on keyring for #{r}"
124
138
  end
125
139
  key_to_use
@@ -146,8 +160,7 @@ class Hiera
146
160
  end
147
161
 
148
162
  def self.decrypt ciphertext
149
- gnupghome = self.option :gnupghome
150
- debug("GNUPGHOME is #{gnupghome}")
163
+ gnupghome = self.gnupghome
151
164
 
152
165
  unless defined?(GPGME)
153
166
  RubyGpg.config.homedir = gnupghome if gnupghome
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-eyaml-gpg
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: 0.6.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Hildrew
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-21 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hiera-eyaml
@@ -55,9 +55,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - '>='
58
+ - - '>'
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: 1.3.1
61
61
  requirements: []
62
62
  rubyforge_project:
63
63
  rubygems_version: 2.0.14