summaryrefslogtreecommitdiff
path: root/lib/license/management
diff options
context:
space:
mode:
Diffstat (limited to 'lib/license/management')
-rw-r--r--lib/license/management/python.rb2
-rw-r--r--lib/license/management/shell.rb21
-rw-r--r--lib/license/management/version.rb2
3 files changed, 21 insertions, 4 deletions
diff --git a/lib/license/management/python.rb b/lib/license/management/python.rb
index 8a1a81a..c5f7107 100644
--- a/lib/license/management/python.rb
+++ b/lib/license/management/python.rb
@@ -5,7 +5,7 @@ module License
class Python
attr_reader :shell
- def initialize(shell: Shell.new)
+ def initialize(shell: ::License::Management.shell)
@shell = shell
end
diff --git a/lib/license/management/shell.rb b/lib/license/management/shell.rb
index a1a1412..691a8ea 100644
--- a/lib/license/management/shell.rb
+++ b/lib/license/management/shell.rb
@@ -3,10 +3,12 @@
module License
module Management
class Shell
- attr_reader :logger
+ attr_reader :custom_certificate_path, :logger
- def initialize(logger: License::Management.logger)
+ def initialize(logger: License::Management.logger, certificate: ENV['ADDITIONAL_CA_CERT_BUNDLE'])
@logger = logger
+ @custom_certificate_path = Pathname.new('/usr/local/share/ca-certificates/custom.crt')
+ trust!(certificate)
end
def execute(command, env: {})
@@ -24,11 +26,26 @@ module License
execute("sh -c '#{expand(command)}'", env: env)
end
+ def custom_certificate_installed?
+ present?(ENV['ADDITIONAL_CA_CERT_BUNDLE']) && custom_certificate_path.exist?
+ end
+
private
def expand(command)
Array(command).map(&:to_s).join(' ')
end
+
+ def trust!(certificate)
+ return unless present?(certificate)
+
+ custom_certificate_path.write(certificate)
+ execute('update-ca-certificates -v')
+ end
+
+ def present?(item)
+ !item.nil? && !item.empty?
+ end
end
end
end
diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb
index edcabbd..b422fd6 100644
--- a/lib/license/management/version.rb
+++ b/lib/license/management/version.rb
@@ -2,6 +2,6 @@
module License
module Management
- VERSION = '3.6.0'
+ VERSION = '3.7.0'
end
end