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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96a621d666288ef2ec40ae5384c0a2ba823f011cd2384db2d0eee53d2dbf6fc1
4
- data.tar.gz: 05cf19519259186bd789f02d996b580ba76a7b7e9f598b308c2705c636d25e6c
3
+ metadata.gz: 9340773519ba8065cba065f1e26edd5634df0456c62c5c7367e2e1e557173b1b
4
+ data.tar.gz: d4e0939fcb6794659b5399a850d9ef76bc02eaad053fb7e32d2701c383480435
5
5
  SHA512:
6
- metadata.gz: 911cfb6bdbbcf16ef73a5dc1d36bd53aa06dc7f94e9f53a9cc0aa964400a266cc25583d97651684ebf3394f340f780520bfb7af0e189a656dd48d2338beed7fb
7
- data.tar.gz: 466ec97e4b4a4a1dcdd223f18be57fbeddb72aea29aacc1d64fc2b728ca807ec0865619024773b49613ac19aa14dcfea275bcdd9a3cdfa6395ea1dc601b67855
6
+ metadata.gz: 5bdd945ebe90c00af7b70e8f3a776f2a9ded0cf6b5623f3e3612a41d86c42cb805808623226c29b77d88273c2c452459ff52dd80389e2a960a200bcb40de3fef
7
+ data.tar.gz: 9f2f4b3ed1a7e8823d3fcc476d71c429422396dbbd1b1b8e18662ddec6aed40775b0f3bb015649fbfd16764ac5a9360b212308898ddbb9f5ecc0be854e6ae98b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -16,7 +16,7 @@ command :'package:values' do
16
16
  puts "\e[33m#{'=' * 80}"
17
17
  puts package.name
18
18
  puts "#{'=' * 80}\e[0m"
19
- puts package.final_values.to_yaml.sub(/\A---\n/, '')
19
+ puts package.final_values.to_yaml(line_width: -1).sub(/\A---\n/, '')
20
20
  end
21
21
  end
22
22
  end
@@ -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
- "#{host}/#{image_name}:#{tag}"
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
@@ -30,7 +30,7 @@ module Hippo
30
30
  end
31
31
 
32
32
  def yaml
33
- @object.to_yaml
33
+ @object.to_yaml(line_width: -1)
34
34
  end
35
35
 
36
36
  def yaml_to_apply
data/lib/hippo/package.rb CHANGED
@@ -93,7 +93,7 @@ module Hippo
93
93
  end
94
94
 
95
95
  def run_install_command(verb, *additional)
96
- run(install_command(verb, *additional), stdin: final_values.to_yaml)
96
+ run(install_command(verb, *additional), stdin: final_values.to_yaml(line_width: -1))
97
97
  true
98
98
  end
99
99
 
@@ -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
- contents = decrypt(File.read(path))
134
- contents = Util.open_in_editor('secret', contents)
135
- write_file(contents)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hippo
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
  end
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.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-10 00:00:00.000000000 Z
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