sambot 0.1.170 → 0.1.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecbe0a3db2399c37336a17169ab9c860dbf99786
|
4
|
+
data.tar.gz: 50d1391592f310d8045de5ef6c97ef6e538e9133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad5bdc3cf3cc9978729fdc8a8bca632741ec3e5e9a9ba47541f218280affc6556e57269452c17aa57533cdb28301404ccc807f9b0b59d15506042f79adbf395
|
7
|
+
data.tar.gz: 6e2f307c140ba88bcf67d971677287903afe08514236a020e4829d52ffad984ed5c0dc218f3d5f5df8519bf7c93a20b2f87ee63209fad910369a226c229722a5
|
@@ -1,11 +1,35 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'vault'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def info(msg)
|
5
|
+
puts msg
|
6
|
+
end
|
7
|
+
|
8
|
+
def read_secrets(filename)
|
9
|
+
info("Reading the secrets file at '.vault.yml'")
|
10
|
+
contents = File.read(filename)
|
11
|
+
if contents.empty?
|
12
|
+
info("No secrets were found in the '.vault.yml' secrets file")
|
13
|
+
else
|
14
|
+
store_secrets(contents)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def store_secrets(contents)
|
19
|
+
secrets = YAML.load(contents)
|
20
|
+
secrets.each { |secret| store_secret(secret) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def store_secret(secret)
|
7
24
|
data = secret['contents']
|
8
25
|
data = File.read(data.gsub(/file::/, '')) if data.start_with?('file::')
|
9
26
|
Vault.logical.write(secret['path'], value: data)
|
10
27
|
puts "Updated the secret located at #{secret['path']}"
|
11
28
|
end
|
29
|
+
|
30
|
+
filename = File.expand_path(File.join(File.dirname(__FILE__), '../../.vault.yml'))
|
31
|
+
if File.exist?(filename)
|
32
|
+
read_secrets(filename)
|
33
|
+
else
|
34
|
+
info("No '.vault.yml' file is available so Vault was not populated with any secrets")
|
35
|
+
end
|
data/lib/sambot/version.rb
CHANGED