hiera-eyaml 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,24 +43,28 @@ This creates a public and private key with default names in the default location
43
43
 
44
44
  ### Encryption
45
45
 
46
- To encrypt something, you only need the public_key, so distribute that to people creating hiera properties
46
+ To encrypt something, you only need the public_key, so distribute that to people creating hiera properties
47
47
 
48
48
  $ eyaml -e -f filename # Encrypt a file
49
49
  $ eyaml -e -s 'hello there' # Encrypt a string
50
50
  $ eyaml -e -p # Encrypt a password (prompt for it)
51
51
 
52
+ Use the -l parameter to pass in a label for the encrypted value
53
+
54
+ $ eyaml -e -l 'my-secret-key' -s 'very secret stuffs'
55
+
52
56
  ### Decryption
53
57
 
54
- To decrypt something, you need the public_key and the private_key.
58
+ To decrypt something, you need the public_key and the private_key.
55
59
 
56
- To test decryption you can also use the eyaml tool if you have both keys
60
+ To test decryption you can also use the eyaml tool if you have both keys
57
61
 
58
62
  $ eyaml -d -f filename # Decrypt a file
59
63
  $ eyaml -d -s 'ENC[PKCS7,.....]' # Decrypt a string
60
64
 
61
- ### EYaml files
65
+ ### eYaml files
62
66
 
63
- Once you have created a few eyaml files, with a mixture of encrypted and non-encrypted properties, you can edit the encrypted values in place, using the special edit mode of the eyaml utility
67
+ Once you have created a few eyaml files, with a mixture of encrypted and non-encrypted properties, you can edit the encrypted values in place, using the special edit mode of the eyaml utility
64
68
 
65
69
  $ eyaml -i filename.eyaml # Edit an eyaml file in place
66
70
 
@@ -151,6 +155,18 @@ things:
151
155
  - nested thing 2.1
152
156
  </pre>
153
157
 
158
+ Tests
159
+ =====
160
+
161
+ In order to run the tests, simply run `cucumber` in the top level directory of the project.
162
+
163
+ You'll need to have a few requirements installed:
164
+
165
+ * `expect` (via yum/apt-get or system package)
166
+ * `aruba` (gem)
167
+ * `cucumber` (gem)
168
+ * `puppet` (gem)
169
+
154
170
  Notes
155
171
  =====
156
172
 
@@ -2,7 +2,7 @@ class Hiera
2
2
  module Backend
3
3
  module Eyaml
4
4
 
5
- VERSION = "1.3.3"
5
+ VERSION = "1.3.4"
6
6
 
7
7
  def self.default_encryption_scheme= new_encryption
8
8
  @@default_encryption_scheme = new_encryption
@@ -12,7 +12,7 @@ class Hiera
12
12
 
13
13
  def self.execute
14
14
 
15
- output_data = case Eyaml::Options[:source]
15
+ case Eyaml::Options[:source]
16
16
  when :eyaml
17
17
  encryptions = []
18
18
 
@@ -26,7 +26,7 @@ class Hiera
26
26
  }
27
27
 
28
28
  # strings
29
- output.gsub!( REGEX_DECRYPTED_STRING ) { |match|
29
+ output.gsub( REGEX_DECRYPTED_STRING ) { |match|
30
30
  encryption_scheme = parse_encryption_scheme( $1 )
31
31
  encryptor = Encryptor.find encryption_scheme
32
32
  ciphertext = encryptor.encode( encryptor.encrypt($2) ).gsub(/\n/, "")
@@ -36,11 +36,9 @@ class Hiera
36
36
  else
37
37
  encryptor = Encryptor.find
38
38
  ciphertext = encryptor.encode( encryptor.encrypt(Eyaml::Options[:input_data]) )
39
- "ENC[#{encryptor.tag},#{ciphertext}]"
39
+ self.format :data => "ENC[#{encryptor.tag},#{ciphertext}]", :structure => Eyaml::Options[:output], :label => Eyaml::Options[:label]
40
40
  end
41
41
 
42
- self.format :data => output_data, :structure => Eyaml::Options[:output], :label => Eyaml::Options[:label]
43
-
44
42
  end
45
43
 
46
44
  protected
@@ -38,13 +38,15 @@ class Hiera
38
38
 
39
39
  protected
40
40
 
41
+ def self.plugin_classname
42
+ self.to_s.split("::").last.downcase
43
+ end
44
+
41
45
  def self.register
42
- plugin_classname = self.to_s.split("::").last.downcase
43
46
  Hiera::Backend::Eyaml::Plugins.register_options :options => self.options, :plugin => plugin_classname
44
47
  end
45
48
 
46
49
  def self.option name
47
- plugin_classname = self.to_s.split("::").last.downcase
48
50
  Eyaml::Options[ "#{plugin_classname}_#{name}" ] || self.options[ "#{plugin_classname}_#{name}" ]
49
51
  end
50
52
 
@@ -63,6 +65,30 @@ class Hiera
63
65
  end
64
66
  end
65
67
 
68
+ def self.hiera?
69
+ "hiera".eql? Eyaml::Options[:source]
70
+ end
71
+
72
+ def self.format_message msg
73
+ "[eyaml_#{plugin_classname}]: #{msg}"
74
+ end
75
+
76
+ def self.debug msg
77
+ if self.hiera?
78
+ Hiera.debug format_message msg
79
+ else
80
+ STDERR.puts format_message msg
81
+ end
82
+ end
83
+
84
+ def self.warn msg
85
+ if self.hiera?
86
+ Hiera.warn format_message msg
87
+ else
88
+ STDERR.puts format_message msg
89
+ end
90
+ end
91
+
66
92
  end
67
93
 
68
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-eyaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-04 00:00:00.000000000 Z
12
+ date: 2013-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: trollop