hippo-cli 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/cli/package_values.rb +1 -1
- data/lib/hippo/bootstrap_parser.rb +22 -0
- data/lib/hippo/image.rb +6 -1
- data/lib/hippo/liquid_filters.rb +15 -0
- data/lib/hippo/object_definition.rb +1 -1
- data/lib/hippo/package.rb +1 -1
- data/lib/hippo/secret_manager.rb +7 -3
- data/lib/hippo/stage.rb +2 -1
- data/lib/hippo/version.rb +1 -1
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9340773519ba8065cba065f1e26edd5634df0456c62c5c7367e2e1e557173b1b
|
4
|
+
data.tar.gz: d4e0939fcb6794659b5399a850d9ef76bc02eaad053fb7e32d2701c383480435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bdd945ebe90c00af7b70e8f3a776f2a9ded0cf6b5623f3e3612a41d86c42cb805808623226c29b77d88273c2c452459ff52dd80389e2a960a200bcb40de3fef
|
7
|
+
data.tar.gz: 9f2f4b3ed1a7e8823d3fcc476d71c429422396dbbd1b1b8e18662ddec6aed40775b0f3bb015649fbfd16764ac5a9360b212308898ddbb9f5ecc0be854e6ae98b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/cli/package_values.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'securerandom'
|
4
4
|
require 'secure_random_string'
|
5
|
+
require 'openssl'
|
5
6
|
|
6
7
|
module Hippo
|
7
8
|
class BootstrapParser
|
@@ -54,6 +55,27 @@ module Hippo
|
|
54
55
|
SecureRandom.hex(value['size'] ? value['size'].to_i : 16)
|
55
56
|
when 'random'
|
56
57
|
Base64.encode64(SecureRandom.random_bytes(value['size'] ? value['size'].to_i : 16)).strip
|
58
|
+
when 'rsa'
|
59
|
+
OpenSSL::PKey::RSA.new(value['size'] ? value['size'].to_i : 2048).to_s
|
60
|
+
when 'certificate'
|
61
|
+
key = OpenSSL::PKey::RSA.new(value['key_size'] ? value['key_size'].to_i : 2048)
|
62
|
+
|
63
|
+
cert = OpenSSL::X509::Certificate.new
|
64
|
+
cert.subject = cert.issuer = OpenSSL::X509::Name.new(
|
65
|
+
[
|
66
|
+
['C', value['country'] || 'GB'],
|
67
|
+
['O', value['organization'] || 'Default'],
|
68
|
+
['OU', value['organization_unit'] || 'Default'],
|
69
|
+
['CN', value['common_name'] || 'default']
|
70
|
+
]
|
71
|
+
)
|
72
|
+
cert.not_before = Time.now
|
73
|
+
cert.not_after = Time.now + (60 * 60 * 24 * (value['days'] ? value['days'].to_i : 730))
|
74
|
+
cert.public_key = key.public_key
|
75
|
+
cert.serial = 0x0
|
76
|
+
cert.version = 2
|
77
|
+
cert.sign key, OpenSSL::Digest::SHA256.new
|
78
|
+
{ 'certificate' => cert.to_s, 'key' => key.to_s }
|
57
79
|
when nil
|
58
80
|
raise Error, "A 'type' must be provided for each generated item"
|
59
81
|
else
|
data/lib/hippo/image.rb
CHANGED
@@ -34,7 +34,11 @@ module Hippo
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def image_url
|
37
|
-
|
37
|
+
if host
|
38
|
+
"#{host}/#{image_name}:#{tag}"
|
39
|
+
else
|
40
|
+
"#{image_name}:#{tag}"
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def template_vars
|
@@ -52,6 +56,7 @@ module Hippo
|
|
52
56
|
end
|
53
57
|
|
54
58
|
def exists?
|
59
|
+
return true if host.nil?
|
55
60
|
return true unless can_check_for_existence?
|
56
61
|
|
57
62
|
credentials = Hippo.config.dig('docker', 'credentials', host)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hippo
|
4
|
+
module LiquidFilters
|
5
|
+
def indent(text, depth = 2)
|
6
|
+
text.split("\n").map.each_with_index do |p, i|
|
7
|
+
i == 0 ? p : ' ' * depth + p
|
8
|
+
end.join("\n")
|
9
|
+
end
|
10
|
+
|
11
|
+
def multiline(text)
|
12
|
+
text.inspect
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/hippo/package.rb
CHANGED
data/lib/hippo/secret_manager.rb
CHANGED
@@ -130,9 +130,13 @@ module Hippo
|
|
130
130
|
raise Error, 'Cannot create edit file because no key is available for decryption'
|
131
131
|
end
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
old_contents = decrypt(File.read(path))
|
134
|
+
new_contents = Util.open_in_editor('secret', old_contents)
|
135
|
+
if old_contents != new_contents
|
136
|
+
write_file(new_contents)
|
137
|
+
else
|
138
|
+
puts 'No changes detected. Not re-encrypting secret file.'
|
139
|
+
end
|
136
140
|
end
|
137
141
|
|
138
142
|
def write_file(contents)
|
data/lib/hippo/stage.rb
CHANGED
@@ -4,6 +4,7 @@ require 'liquid'
|
|
4
4
|
require 'open3'
|
5
5
|
require 'hippo/secret_manager'
|
6
6
|
require 'hippo/package'
|
7
|
+
require 'hippo/liquid_filters'
|
7
8
|
|
8
9
|
module Hippo
|
9
10
|
class Stage
|
@@ -67,7 +68,7 @@ module Hippo
|
|
67
68
|
proc do |data|
|
68
69
|
begin
|
69
70
|
template = Liquid::Template.parse(data)
|
70
|
-
template.render(template_vars)
|
71
|
+
template.render(template_vars, filters: [LiquidFilters])
|
71
72
|
rescue Liquid::SyntaxError => e
|
72
73
|
raise Error, "Template error: #{e.message}"
|
73
74
|
end
|
data/lib/hippo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hippo-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
3wUJNGnT5XYq+qvTqmjkTSTfdGvZCM63C6bGdN5CAyMokGOOatGqyCMAONolWnfC
|
31
31
|
gm3t2GWWrxY=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2020-02-
|
33
|
+
date: 2020-02-12 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: encryptor
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/hippo/error.rb
|
175
175
|
- lib/hippo/extensions.rb
|
176
176
|
- lib/hippo/image.rb
|
177
|
+
- lib/hippo/liquid_filters.rb
|
177
178
|
- lib/hippo/manifest.rb
|
178
179
|
- lib/hippo/object_definition.rb
|
179
180
|
- lib/hippo/package.rb
|
metadata.gz.sig
CHANGED
Binary file
|